MCPcopy Create free account
hub / github.com/PeterFWS/Structure-PLP-SLAM / base64_encode

Method base64_encode

src/socket_publisher/data_serializer.cc:286–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284 }
285
286 std::string data_serializer::base64_encode(unsigned char const *bytes_to_encode, unsigned int in_len)
287 {
288 static const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
289
290 std::stringstream ss;
291 int i = 0, j = 0;
292 unsigned char char_array_3[3];
293 unsigned char char_array_4[4];
294
295 while (in_len--)
296 {
297 char_array_3[i++] = *(bytes_to_encode++);
298 if (i == 3)
299 {
300 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
301 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
302 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
303 char_array_4[3] = char_array_3[2] & 0x3f;
304 for (i = 0; (i < 4); i++)
305 ss << base64_chars[char_array_4[i]];
306 i = 0;
307 }
308 }
309
310 if (i > 0)
311 {
312 for (j = i; j < 3; j++)
313 char_array_3[j] = '\0';
314 char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
315 char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
316 char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
317 for (j = 0; (j < i + 1); j++)
318 ss << base64_chars[char_array_4[j]];
319 while ((i++ < 3))
320 ss << '=';
321 }
322 return ss.str();
323 }
324
325} // namespace socket_publisher

Callers

nothing calls this directly

Calls 1

strMethod · 0.45

Tested by

no test coverage detected