10Duke Enterprise C++ SDK
Loading...
Searching...
No Matches
StringSink.h
1#ifndef TENDUKE_CLIENT_CORE_STRINGSINK_H
2#define TENDUKE_CLIENT_CORE_STRINGSINK_H
3
4#include "./DataSink.h"
5
6#include <string>
7
8namespace tenduke { namespace utl {
9
15class StringSink : public virtual ::tenduke::utl::DataSink
16{
17public:
18 explicit StringSink(std::string &buffer)
19 : buffer(buffer)
20 {
21 }
22
23 void append(const std::uint8_t *data, std::size_t size) override
24 {
25 this->buffer.append(reinterpret_cast<const char *>(data), size);
26 }
27
28 void append(const DataSpan &data) override
29 {
30 this->buffer.append(reinterpret_cast<const char *>(data.data()), data.size_bytes());
31 }
32
33 void append(std::uint8_t byte) override
34 {
35 this->buffer.push_back(static_cast<char>(byte));;
36 }
37
38private:
39 std::string &buffer;
40};
41
42
43}}
44
45#endif //TENDUKE_CLIENT_CORE_STRINGSINK_H
A sink to which binary data can be appended.
Definition DataSink.h:14
A span of binary data.
Definition DataSpan.h:16
virtual const unsigned char * data() const =0
Returns a pointer to the beginning of the underlying sequence.
virtual std::size_t size_bytes() const =0
Returns the size of the span in bytes.
void append(const DataSpan &data) override
Appends a DataSpan to the sink.
Definition StringSink.h:28
void append(std::uint8_t byte) override
Appends a single byte to the sink.
Definition StringSink.h:33
void append(const std::uint8_t *data, std::size_t size) override
Appends binary data to the sink.
Definition StringSink.h:23
Utilities.
Definition Base64Decoder.h:10
Root for classes, functions and globals of 10Duke C++ Client.
Definition APIRequest.h:4