From 64a5ad8c0409266aef97b45c2fb68eefce9b65f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Thu, 16 Nov 2023 14:44:49 +0300 Subject: [PATCH] =?UTF-8?q?mdbx++:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=BE?= =?UTF-8?q?=D0=B2=20`buffer::hex=5Fdecode()`,=20`base64=5Fdecode()`,=20`ba?= =?UTF-8?q?se58=5Fdecode()`=20(backport).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mdbx.h++ | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/mdbx.h++ b/mdbx.h++ index eba58b50..468e8df6 100644 --- a/mdbx.h++ +++ b/mdbx.h++ @@ -2410,6 +2410,55 @@ public: wrap_width, allocator); } + /// \brief Decodes hexadecimal dump from the slice content to returned buffer. + static buffer hex_decode(const ::mdbx::slice &source, + bool ignore_spaces = false, + const allocator_type &allocator = allocator_type()) { + return source.template hex_decode(ignore_spaces, + allocator); + } + + /// \brief Decodes [Base58](https://en.wikipedia.org/wiki/Base58) dump + /// from the slice content to returned buffer. + static buffer + base58_decode(const ::mdbx::slice &source, bool ignore_spaces = false, + const allocator_type &allocator = allocator_type()) { + return source.template base58_decode( + ignore_spaces, allocator); + } + + /// \brief Decodes [Base64](https://en.wikipedia.org/wiki/Base64) dump + /// from the slice content to returned buffer. + static buffer + base64_decode(const ::mdbx::slice &source, bool ignore_spaces = false, + const allocator_type &allocator = allocator_type()) { + return source.template base64_decode( + ignore_spaces, allocator); + } + + /// \brief Decodes hexadecimal dump + /// from the buffer content to new returned buffer. + buffer hex_decode(bool ignore_spaces = false, + const allocator_type &allocator = allocator_type()) const { + return hex_decode(slice(), ignore_spaces, allocator); + } + + /// \brief Decodes [Base58](https://en.wikipedia.org/wiki/Base58) dump + /// from the buffer content to new returned buffer. + buffer + base58_decode(bool ignore_spaces = false, + const allocator_type &allocator = allocator_type()) const { + return base58_decode(slice(), ignore_spaces, allocator); + } + + /// \brief Decodes [Base64](https://en.wikipedia.org/wiki/Base64) dump + /// from the buffer content to new returned buffer. + buffer + base64_decode(bool ignore_spaces = false, + const allocator_type &allocator = allocator_type()) const { + return base64_decode(slice(), ignore_spaces, allocator); + } + /// \brief Reserves storage space. void reserve(size_t wanna_headroom, size_t wanna_tailroom) { wanna_headroom = ::std::min(::std::max(headroom(), wanna_headroom),