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

Function Base64Encode

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

Source from the content-addressed store, hash-verified

119}
120
121static inline void Base64Encode(const char* in, int in_len, std::ostringstream* out) {
122 typedef base64_from_binary<transform_width<const char*, 6, 8> > base64_encode;
123 // Base64 encodes 8 byte chars as 6 bit values.
124 std::ostringstream::pos_type len_before = out->tellp();
125 copy(base64_encode(in), base64_encode(in + in_len), std::ostream_iterator<char>(*out));
126 int bytes_written = out->tellp() - len_before;
127 // Pad with = to make it valid base64 encoded string
128 int num_pad = bytes_written % 4;
129 if (num_pad != 0) {
130 num_pad = 4 - num_pad;
131 for (int i = 0; i < num_pad; ++i) {
132 (*out) << "=";
133 }
134 }
135 DCHECK_EQ(out->str().size() % 4, 0);
136}
137
138void Base64Encode(const vector<uint8_t>& in, string* out) {
139 if (in.empty()) {

Callers 2

TestBase64Function · 0.70
TEST_FFunction · 0.50

Calls 3

sizeMethod · 0.45
strMethod · 0.45
emptyMethod · 0.45

Tested by 2

TestBase64Function · 0.56
TEST_FFunction · 0.40