MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / decodeBase64

Function decodeBase64

include/engine/base64.hpp:101–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99
100// Decodes into a chunk of memory that is at least as large as the input.
101template <typename OutputIter> void decodeBase64(const std::string &encoded, OutputIter out)
102{
103 auto unpadded = encoded;
104
105 const auto num_padded = std::count(begin(encoded), end(encoded), '=');
106 std::replace(begin(unpadded), end(unpadded), '=', 'A'); // A_64 == \0
107
108 std::string decoded{detail::BinaryFromBase64{begin(unpadded)},
109 detail::BinaryFromBase64{begin(unpadded) + unpadded.length()}};
110
111 decoded.erase(end(decoded) - num_padded, end(decoded));
112 std::copy(begin(decoded), end(decoded), out);
113}
114
115// Convenience specialization, filling string instead of byte-dumping into it.
116inline std::string decodeBase64(const std::string &encoded)

Callers 2

BOOST_AUTO_TEST_CASEFunction · 0.85
decodeBase64BytewiseFunction · 0.85

Calls 1

copyFunction · 0.85

Tested by

no test coverage detected