MCPcopy Create free account
hub / github.com/acl-dev/acl / encode

Method encode

lib_acl_cpp/src/mime/mime_code.cpp:96–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96void mime_code::encode(string *out)
97{
98 const unsigned char *cp;
99 int count;
100
101 /*
102 * Encode 3 -> 4.
103 */
104 for (cp = (const unsigned char *) m_encodeBuf, count = m_encodeCnt;
105 count > 0; count -= 3, cp += 3) {
106
107 out->push_back((char) m_toTab[cp[0] >> 2]);
108 if (count > 1) {
109 out->push_back((char) m_toTab[(cp[0] & 0x3) << 4 | cp[1] >> 4]);
110 if (count > 2) {
111 out->push_back((char) m_toTab[(cp[1] & 0xf) << 2 | cp[2] >> 6]);
112 out->push_back((char) m_toTab[cp[2] & 0x3f]);
113 } else {
114 out->push_back((char) m_toTab[(cp[1] & 0xf) << 2]);
115 out->push_back(m_fillChar);
116 break;
117 }
118 } else {
119 out->push_back((char) m_toTab[(cp[0] & 0x3) << 4]);
120 out->push_back(m_fillChar);
121 out->push_back(m_fillChar);
122 break;
123 }
124 }
125
126 if (m_addCrLf) {
127 out->push_back('\r');
128 out->push_back('\n');
129 }
130}
131
132void mime_code::decode_update(const char *src, int n, string* out)
133{

Callers

nothing calls this directly

Calls 1

push_backMethod · 0.45

Tested by

no test coverage detected