Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
printer.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Roc Streaming authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_core/printer.h
10//! @brief Console printer.
11
12#ifndef ROC_CORE_PRINTER_H_
13#define ROC_CORE_PRINTER_H_
14
15#include "roc_core/attributes.h"
17#include "roc_core/stddefs.h"
18
19namespace roc {
20namespace core {
21
22//! Printer.
23class Printer : public NonCopyable<> {
24public:
25 enum {
26 BufferSize = 1024, //!< Maximum buffer size.
27 };
28
29 //! Printing function.
30 typedef void (*PrintlnFunc)(const char* buf, size_t bufsz);
31
32 //! Initialize printer.
33 //! If @p println_func is NULL, prints text to console.
35
36 //! Flush and destroy.
38
39 //! Write text.
40 //! @returns size of formatted string (excluding terminating zero byte).
42
44 void flush_(bool force);
45
46 PrintlnFunc println_;
47
48 char buf_[BufferSize + 1];
49 size_t bufsz_;
50};
51
52} // namespace core
53} // namespace roc
54
55#endif // ROC_CORE_PRINTER_H_
Compiler attributes.
#define ROC_ATTR_PRINTF(fmt_pos, args_pos)
Function gets printf-like arguments.
Definition attributes.h:35
Base class for non-copyable objects.
Definition noncopyable.h:23
size_t writef(const char *format,...)
Write text.
@ BufferSize
Maximum buffer size.
Definition printer.h:26
void(* PrintlnFunc)(const char *buf, size_t bufsz)
Printing function.
Definition printer.h:30
Printer(PrintlnFunc println_func=NULL)
Initialize printer. If println_func is NULL, prints text to console.
~Printer()
Flush and destroy.
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
Root namespace.
Non-copyable object.
Commonly used types and functions.