6 namespace tdc {
namespace io {
10 static const std::vector<uint8_t> ESCAPE_BYTE_POOL {
43 if (!m_escape_bytes.empty()) {
47 for (uint8_t byte : ESCAPE_BYTE_POOL) {
49 for (uint8_t x : m_escape_bytes) {
50 if (x == byte) found =
true;
52 if (!found && m_replacement_bytes.size() < (m_escape_bytes.size() + 1)) {
53 m_replacement_bytes.push_back(byte);
58 m_escape_bytes.insert(m_escape_bytes.begin(), m_replacement_bytes.at(0));
63 DCHECK_EQ(m_replacement_bytes.size(), m_escape_bytes.size());
67 return !m_escape_bytes.empty();
72 DCHECK_EQ(m_replacement_bytes.front(), m_escape_bytes.front());
73 return m_replacement_bytes.front();
95 std::array<uint8_t, 256> m_escape_map;
96 std::array<uint8_t, 256> m_escape_map_flag;
97 uint8_t m_escape_byte = 0;
101 for (
size_t i = 0; i < 256; i++) {
103 m_escape_map_flag[i] = 0;
110 for (
size_t i = 0; i < em_eb.size(); i++) {
111 m_escape_map[em_eb[i]] = em_rb[i];
112 m_escape_map_flag[em_eb[i]] = 1;
120 return m_escape_map_flag[i];
124 return lookup_flag(i) != 0;
129 return m_escape_map[i];
133 return m_escape_byte;
143 std::array<uint8_t, 256> m_unescape_map;
144 uint8_t m_escape_byte = 0;
146 bool m_has_escape_bytes =
false;
149 for (
size_t i = 0; i < 256; i++) {
150 m_unescape_map[i] = i;
157 for (
size_t i = 0; i < em_eb.size(); i++) {
158 m_unescape_map[em_rb[i]] = em_eb[i];
167 return m_unescape_map[i];
171 return m_escape_byte;
179 return m_has_escape_bytes;
bool null_terminate() const
bool has_escape_bytes() const
Contains the text compression and encoding framework.
EscapeMap(const InputRestrictions &rest)
uint8_t escape_byte() const
const std::vector< uint8_t > & escape_bytes() const
uint8_t escape_byte() const
uint8_t lookup_byte(size_t i) const
bool lookup_flag_bool(size_t i) const
uint8_t lookup_flag(size_t i) const
uint8_t lookup_byte(size_t i) const
std::vector< uint8_t > m_replacement_bytes
bool null_terminate() const
std::vector< uint8_t > m_escape_bytes
bool null_terminate() const
const std::vector< uint8_t > & replacement_bytes() const
FastEscapeMap(const EscapeMap &em)
uint8_t escape_byte() const
bool has_escape_bytes() const
FastUnescapeMap(const EscapeMap &em)