MCPcopy Create free account
hub / github.com/chen3feng/toft / Encode

Method Encode

encoding/base64.cpp:14–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12namespace toft {
13
14bool Base64::Encode(const StringPiece& input, std::string* output)
15{
16 std::string temp;
17 temp.resize(modp_b64_encode_len(input.size())); // makes room for null byte
18
19 // null terminates result since result is base64 text!
20 int input_size = static_cast<int>(input.size());
21 int output_size = modp_b64_encode(&(temp[0]), input.data(), input_size);
22 if (output_size < 0)
23 return false;
24
25 temp.resize(output_size); // strips off null byte
26 output->swap(temp);
27 return true;
28}
29
30bool Base64::WebSafeEncode(const StringPiece& input, std::string* output)
31{

Callers

nothing calls this directly

Calls 4

resizeMethod · 0.80
dataMethod · 0.80
sizeMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected