VAPOR3 3.9.4
Base16StringStream.h
Go to the documentation of this file.
1#pragma once
2
3#include <streambuf>
4#include <ostream>
5#include <istream>
6#include <memory>
7#include <vapor/common.h>
8
9
15
16class COMMON_API Base16StreamBuf : public std::streambuf {
17public:
18 std::string _string;
19 int _i = 0;
20 virtual int_type overflow(int_type c) override;
21};
22
23
29
30class COMMON_API Base16StringStream : public std::ostream {
31 Base16StreamBuf _buf;
32
33public:
34 Base16StringStream() : std::ostream(&_buf) {}
35 const std::string &ToString() { return _buf._string; }
36};
37
38
39
45
46class COMMON_API Base16DecoderStream : public std::istream {
47 struct MemBuf : std::streambuf {
48 MemBuf(char *buf, size_t size) { this->setg(buf, buf, buf + size); }
49 };
50
51 static void Base16Decode(const std::string &in, char *out);
52
53 std::unique_ptr<char> _data;
54 MemBuf _buf;
55
56public:
57 Base16DecoderStream(const std::string &s);
58};
Creates a raw std istream from a base16 encoded string.
Base16DecoderStream(const std::string &s)
A custom std stream buffer that saves data piped through it into a base16 encoded string.
virtual int_type overflow(int_type c) override
An implementation similar to std::stringstream which results in a base16 encoded string.
const std::string & ToString()
#define COMMON_API
Definition: common.h:72