aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/base64/base64.h
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /library/cpp/string_utils/base64/base64.h
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/string_utils/base64/base64.h')
-rw-r--r--library/cpp/string_utils/base64/base64.h58
1 files changed, 29 insertions, 29 deletions
diff --git a/library/cpp/string_utils/base64/base64.h b/library/cpp/string_utils/base64/base64.h
index f778a6425a..2f59572c51 100644
--- a/library/cpp/string_utils/base64/base64.h
+++ b/library/cpp/string_utils/base64/base64.h
@@ -1,15 +1,15 @@
#pragma once
-
+
#include <util/system/defaults.h>
-#include <util/generic/strbuf.h>
+#include <util/generic/strbuf.h>
#include <util/generic/string.h>
-
+
/* @return Size of the buffer required to decode Base64 encoded data of size `len`.
*/
constexpr size_t Base64DecodeBufSize(const size_t len) noexcept {
return (len + 3) / 4 * 3;
-}
-
+}
+
/* Decode Base64 encoded data. Can decode both regular Base64 and Base64URL encoded data. Can decode
* only valid Base64[URL] data, behaviour for invalid data is unspecified.
*
@@ -21,12 +21,12 @@ constexpr size_t Base64DecodeBufSize(const size_t len) noexcept {
*
* @return Return number of bytes decoded.
*/
-size_t Base64Decode(void* dst, const char* b, const char* e);
-
+size_t Base64Decode(void* dst, const char* b, const char* e);
+
inline TStringBuf Base64Decode(const TStringBuf src, void* dst) {
- return TStringBuf((const char*)dst, Base64Decode(dst, src.begin(), src.end()));
-}
-
+ return TStringBuf((const char*)dst, Base64Decode(dst, src.begin(), src.end()));
+}
+
inline void Base64Decode(const TStringBuf src, TString& dst) {
dst.ReserveAndResize(Base64DecodeBufSize(src.size()));
dst.resize(Base64Decode(src, dst.begin()).size());
@@ -36,9 +36,9 @@ inline void Base64Decode(const TStringBuf src, TString& dst) {
inline TString Base64Decode(const TStringBuf s) {
TString ret;
Base64Decode(s, ret);
- return ret;
-}
-
+ return ret;
+}
+
///
/// @brief Decodes Base64 string with strict verification
/// of invalid symbols, also tries to decode Base64 string with padding
@@ -64,7 +64,7 @@ size_t Base64StrictDecode(void* dst, const char* b, const char* e);
/// @return Returns dst wrapped into TStringBuf.
///
inline TStringBuf Base64StrictDecode(const TStringBuf src, void* dst) {
- return TStringBuf((const char*)dst, Base64StrictDecode(dst, src.begin(), src.end()));
+ return TStringBuf((const char*)dst, Base64StrictDecode(dst, src.begin(), src.end()));
}
///
@@ -91,22 +91,22 @@ inline TString Base64StrictDecode(const TStringBuf src) {
/// Works with strings which length is not divisible by 4.
TString Base64DecodeUneven(const TStringBuf s);
-//encode
+//encode
constexpr size_t Base64EncodeBufSize(const size_t len) noexcept {
return (len + 2) / 3 * 4 + 1;
-}
-
-char* Base64Encode(char* outstr, const unsigned char* instr, size_t len);
-char* Base64EncodeUrl(char* outstr, const unsigned char* instr, size_t len);
-
+}
+
+char* Base64Encode(char* outstr, const unsigned char* instr, size_t len);
+char* Base64EncodeUrl(char* outstr, const unsigned char* instr, size_t len);
+
inline TStringBuf Base64Encode(const TStringBuf src, void* tmp) {
return TStringBuf((const char*)tmp, Base64Encode((char*)tmp, (const unsigned char*)src.data(), src.size()));
-}
-
+}
+
inline TStringBuf Base64EncodeUrl(const TStringBuf src, void* tmp) {
return TStringBuf((const char*)tmp, Base64EncodeUrl((char*)tmp, (const unsigned char*)src.data(), src.size()));
-}
-
+}
+
inline void Base64Encode(const TStringBuf src, TString& dst) {
dst.ReserveAndResize(Base64EncodeBufSize(src.size()));
dst.resize(Base64Encode(src, dst.begin()).size());
@@ -120,11 +120,11 @@ inline void Base64EncodeUrl(const TStringBuf src, TString& dst) {
inline TString Base64Encode(const TStringBuf s) {
TString ret;
Base64Encode(s, ret);
- return ret;
-}
-
+ return ret;
+}
+
inline TString Base64EncodeUrl(const TStringBuf s) {
TString ret;
Base64EncodeUrl(s, ret);
- return ret;
-}
+ return ret;
+}