MCPcopy Create free account
hub / github.com/apache/impala / Base64Decode

Function Base64Decode

be/src/kudu/util/url-coding.cc:166–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166bool Base64Decode(const string& in, string* out) {
167 typedef transform_width<binary_from_base64<string::const_iterator>, 8, 6> base64_decode;
168 string tmp = in;
169 // Replace padding with base64 encoded NULL
170 replace(tmp.begin(), tmp.end(), '=', 'A');
171 try {
172 *out = string(base64_decode(tmp.begin()), base64_decode(tmp.end()));
173 } catch(std::exception& e) {
174 return false;
175 }
176
177 // Remove trailing '\0' that were added as padding. Since \0 is special,
178 // the boost functions get confused so do this manually.
179 int num_padded_chars = 0;
180 for (int i = out->size() - 1; i >= 0; --i) {
181 if ((*out)[i] != '\0') break;
182 ++num_padded_chars;
183 }
184 out->resize(out->size() - num_padded_chars);
185 return true;
186}
187
188void EscapeForHtml(const string& in, std::ostringstream* out) {
189 DCHECK(out != nullptr);

Callers 2

TestBase64Function · 0.70
TEST_FFunction · 0.50

Calls 4

resizeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by 2

TestBase64Function · 0.56
TEST_FFunction · 0.40