add json BJSON_TYPE_BYTES support

This commit is contained in:
MihailRis
2024-09-12 17:22:00 +03:00
parent 6f4a7db910
commit f8fadf8b74
7 changed files with 72 additions and 8 deletions
+4 -4
View File
@@ -319,8 +319,8 @@ std::string util::mangleid(uint64_t value) {
return ss.str();
}
std::vector<ubyte> util::base64_decode(const char* str, size_t size) {
std::vector<ubyte> bytes((size / 4) * 3);
util::Buffer<ubyte> util::base64_decode(const char* str, size_t size) {
util::Buffer<ubyte> bytes((size / 4) * 3);
ubyte* dst = bytes.data();
for (size_t i = 0; i < size;) {
ubyte a = base64_decode_char(ubyte(str[i++]));
@@ -335,12 +335,12 @@ std::vector<ubyte> util::base64_decode(const char* str, size_t size) {
size_t outsize = bytes.size();
if (str[size - 1] == '=') outsize--;
if (str[size - 2] == '=') outsize--;
bytes.resize(outsize);
bytes.resizeFast(outsize);
}
return bytes;
}
std::vector<ubyte> util::base64_decode(const std::string& str) {
util::Buffer<ubyte> util::base64_decode(const std::string& str) {
return base64_decode(str.c_str(), str.size());
}