MCPcopy Create free account
hub / github.com/assimp/assimp / Encode

Function Encode

code/Common/Base64.cpp:73–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void Encode(const uint8_t *in, size_t inLength, std::string &out) {
74 if (in == nullptr || inLength==0) {
75 out.clear();
76 return;
77 }
78
79 size_t outLength = ((inLength + 2) / 3) * 4;
80
81 size_t j = out.size();
82 out.resize(j + outLength);
83
84 for (size_t i = 0; i < inLength; i += 3) {
85 uint8_t b = (in[i] & 0xFC) >> 2;
86 out[j++] = EncodeChar(b);
87
88 b = (in[i] & 0x03) << 4;
89 if (i + 1 < inLength) {
90 b |= (in[i + 1] & 0xF0) >> 4;
91 out[j++] = EncodeChar(b);
92
93 b = (in[i + 1] & 0x0F) << 2;
94 if (i + 2 < inLength) {
95 b |= (in[i + 2] & 0xC0) >> 6;
96 out[j++] = EncodeChar(b);
97
98 b = in[i + 2] & 0x3F;
99 out[j++] = EncodeChar(b);
100 } else {
101 out[j++] = EncodeChar(b);
102 out[j++] = '=';
103 }
104 } else {
105 out[j++] = EncodeChar(b);
106 out[j++] = '=';
107 out[j++] = '=';
108 }
109 }
110}
111
112void Encode(const std::vector<uint8_t> &in, std::string &out) {
113 Encode(in.data(), in.size(), out);

Callers 1

TEST_FFunction · 0.50

Calls 5

EncodeCharFunction · 0.85
clearMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected