|
byteme
C++ wrappers for buffered inputs
|
Buffered wrapper around a Writer.
More...
#include <BufferedWriter.hpp>

Public Member Functions | |
| unsigned long long | number () |
| void | write (Type_ input) |
| void | write (const Type_ *input, std::size_t number) |
| void | flush () |
| virtual void | finish ()=0 |
Buffered wrapper around a Writer.
| Type_ | Type of the input bytes, usually char for text or unsigned char for binary. |
In some applications, we may need to write many small chunks of bytes or even individual bytes. Naively calling Writer::write() for each request may be inefficient if the underlying implementation attempts to write to some storage device for each call. Instead, we can wrap our Writer in a BufferedWriter instance, which stores user-supplied data into a large intermediate buffer. It then calls Writer::write() every now and then to flush the buffer to the underlying representation.
Check out SerialBufferedWriter and ParallelBufferedWriter for subclasses.
|
pure virtual |
Flush all currently-buffered bytes to the underlying Writer instance and call Writer::finish(). This terminates the write stream so no further calls to write(), flush() or finish() may be performed. It is not called automatically upon BufferedWriter destruction, as the user may want to write further bytes to the same Writer instance after exiting the BufferedWriter wrapper.
|
inline |
Flush all currently-buffered bytes to the underlying Writer instance. This can be called at any time, before or after other calls to write() or flush(). It is also automatically called upon BufferedWriter destruction.
|
inline |
write().
|
inline |
Write an array of bytes to the buffer. This may trigger a multiple calls to flush().
| [in] | input | Pointer to an array of bytes to be written. |
| number | Length of the array in input. |
|
inline |
Write a single byte to the buffer. This may trigger a call to flush().
| input | Byte to be written. |