From 4bed5d177960cbf79f68453adbc8911eb95afd75 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 13:46:35 +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=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=87?= =?UTF-8?q?=D0=B5=D1=81=D0=BA=D0=B8=D1=85=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4?= =?UTF-8?q?=D0=BE=D0=B2=20`buffer::hex()`,=20`base64()`,=20`base58()`=20(b?= =?UTF-8?q?ackport).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mdbx.h++ | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/mdbx.h++ b/mdbx.h++ index f9626036..fb7fb166 100644 --- a/mdbx.h++ +++ b/mdbx.h++ @@ -2339,6 +2339,77 @@ public: return slice_.as_pod(); } + /// \brief Returns a new buffer with a hexadecimal dump of the slice content. + static buffer hex(const ::mdbx::slice &source, bool uppercase = false, + unsigned wrap_width = 0, + const allocator_type &allocator = allocator_type()) { + return source.template encode_hex( + uppercase, wrap_width, allocator); + } + + /// \brief Returns a new buffer with a + /// [Base58](https://en.wikipedia.org/wiki/Base58) dump of the slice content. + static buffer base58(const ::mdbx::slice &source, unsigned wrap_width = 0, + const allocator_type &allocator = allocator_type()) { + return source.template encode_base58(wrap_width, + allocator); + } + /// \brief Returns a new buffer with a + /// [Base64](https://en.wikipedia.org/wiki/Base64) dump of the slice content. + static buffer base64(const ::mdbx::slice &source, unsigned wrap_width = 0, + const allocator_type &allocator = allocator_type()) { + return source.template encode_base64(wrap_width, + allocator); + } + + /// \brief Returns a new buffer with a hexadecimal dump of the given pod. + template + static buffer hex(const POD &pod, bool uppercase = false, + unsigned wrap_width = 0, + const allocator_type &allocator = allocator_type()) { + return hex(mdbx::slice::wrap(pod), uppercase, wrap_width, allocator); + } + + /// \brief Returns a new buffer with a + /// [Base58](https://en.wikipedia.org/wiki/Base58) dump of the given pod. + template + static buffer base58(const POD &pod, unsigned wrap_width = 0, + const allocator_type &allocator = allocator_type()) { + return base58(mdbx::slice::wrap(pod), wrap_width, allocator); + } + + /// \brief Returns a new buffer with a + /// [Base64](https://en.wikipedia.org/wiki/Base64) dump of the given pod. + template + static buffer base64(const POD &pod, unsigned wrap_width = 0, + const allocator_type &allocator = allocator_type()) { + return base64(mdbx::slice::wrap(pod), wrap_width, allocator); + } + + /// \brief Returns a new buffer with a hexadecimal dump of the slice content. + buffer encode_hex(bool uppercase = false, unsigned wrap_width = 0, + const allocator_type &allocator = allocator_type()) const { + return slice().template encode_hex( + uppercase, wrap_width, allocator); + } + + /// \brief Returns a new buffer with a + /// [Base58](https://en.wikipedia.org/wiki/Base58) dump of the slice content. + buffer + encode_base58(unsigned wrap_width = 0, + const allocator_type &allocator = allocator_type()) const { + return slice().template encode_base58( + wrap_width, allocator); + } + /// \brief Returns a new buffer with a + /// [Base64](https://en.wikipedia.org/wiki/Base64) dump of the slice content. + buffer + encode_base64(unsigned wrap_width = 0, + const allocator_type &allocator = allocator_type()) const { + return slice().template encode_base64( + wrap_width, allocator); + } + /// \brief Reserves storage space. void reserve(size_t wanna_headroom, size_t wanna_tailroom) { wanna_headroom = ::std::min(::std::max(headroom(), wanna_headroom),