byteme
C++ wrappers for buffered inputs
Loading...
Searching...
No Matches
RawBufferWriter.hpp
Go to the documentation of this file.
1#ifndef BYTEME_RAW_BUFFER_WRITER_HPP
2#define BYTEME_RAW_BUFFER_WRITER_HPP
3
4#include "Writer.hpp"
5#include <vector>
6
13namespace byteme {
14
21class RawBufferWriter : public Writer {
22public:
26 RawBufferWriter(size_t reserve = 0) {
27 output.reserve(reserve);
28 }
29
30public:
31 using Writer::write;
32
33 void write(const unsigned char* buffer, size_t n) {
34 output.insert(output.end(), buffer, buffer + n);
35 }
36
37 void finish() {}
38
39public:
43 // Exposed for back-compatibility only.
44 std::vector<unsigned char> output;
53 std::vector<unsigned char>& get_output() {
54 return output;
55 }
56};
57
58}
59
60#endif
Write to an output sink.
Write bytes to a raw buffer.
Definition RawBufferWriter.hpp:21
std::vector< unsigned char > & get_output()
Definition RawBufferWriter.hpp:53
void finish()
Definition RawBufferWriter.hpp:37
void write(const unsigned char *buffer, size_t n)
Definition RawBufferWriter.hpp:33
RawBufferWriter(size_t reserve=0)
Definition RawBufferWriter.hpp:26
Virtual class for writing bytes to a sink.
Definition Writer.hpp:18
virtual void write(const unsigned char *buffer, size_t n)=0
Simple byte readers and writers.