5 namespace tdc {
namespace io {
15 std::ostream* m_stream;
17 bool m_saw_escape =
false;
18 bool m_saw_null =
false;
28 inline void internal_flush() {
32 inline void push_unescape(uint8_t c) {
33 auto put_internal = [&](uint8_t d){
34 m_stream->put(
char(d));
67 m_fast_unescape_map(
EscapeMap(restrictions)) {}
75 DCHECK(m_saw_null) <<
"Text to be unescaped did not end with a 0";
81 if (ch == traits_type::eof()) {
84 push_unescape(traits_type::to_char_type(ch));
96 std::istream* m_stream;
98 int m_char_buf = traits_type::eof();
99 bool m_nt_done =
false;
102 inline int pull_escape() {
103 if (m_char_buf != traits_type::eof()) {
104 int tmp = m_char_buf;
105 m_char_buf = traits_type::eof();
110 if (m_stream->get(c)) {
111 auto byte = uint8_t(c);
123 return traits_type::eof();
131 m_fast_escape_map(
EscapeMap(restrictions)) {
132 m_current = pull_escape();
146 inline virtual int uflow()
override {
148 m_current = pull_escape();
bool null_terminate() const
bool has_escape_bytes() const
Contains the text compression and encoding framework.
Adapter class over a std::ostream that reverse the escaping and null termination of data written to i...
RestrictedOStreamBuf()=delete
uint8_t escape_byte() const
uint8_t lookup_byte(size_t i) const
uint8_t lookup_flag(size_t i) const
RestrictedOStreamBuf(std::ostream &stream, const InputRestrictions &restrictions)
uint8_t lookup_byte(size_t i) const
bool null_terminate() const
virtual int overflow(int ch) override
Adapter class over a std::istream that escapes and null terminates the data read from it according to...
virtual int uflow() override
virtual ~RestrictedIStreamBuf()
virtual ~RestrictedOStreamBuf()
RestrictedIStreamBuf(std::istream &stream, InputRestrictions restrictions)
uint8_t escape_byte() const
virtual int underflow() override