From 2cc6d68c07e8256c96d01db395469114a1c12d80 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: Sun, 31 Mar 2024 14:23:23 +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`txn::open=5Fmap=5Faccede()`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mdbx.h++ | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/mdbx.h++ b/mdbx.h++ index 008dd808..884fb216 100644 --- a/mdbx.h++ +++ b/mdbx.h++ @@ -4386,6 +4386,11 @@ public: const ::mdbx::key_mode key_mode = ::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode = ::mdbx::value_mode::single) const; + /// \brief Open existing key-value map. + inline map_handle open_map_accede(const char *name) const; + /// \brief Open existing key-value map. + inline map_handle open_map_accede(const ::std::string &name) const; + /// \brief Create new or open existing key-value map. inline map_handle create_map(const char *name, @@ -4441,6 +4446,8 @@ public: const ::std::string_view &name, const ::mdbx::key_mode key_mode = ::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode = ::mdbx::value_mode::single) const; + /// \brief Open existing key-value map. + inline map_handle open_map_accede(const ::std::string_view &name) const; /// \brief Create new or open existing key-value map. inline map_handle create_map(const ::std::string_view &name, @@ -6405,6 +6412,14 @@ txn::open_map(const char *name, const ::mdbx::key_mode key_mode, return map; } +inline ::mdbx::map_handle txn::open_map_accede(const char *name) const { + ::mdbx::map_handle map; + error::success_or_throw( + ::mdbx_dbi_open(handle_, name, MDBX_DB_ACCEDE, &map.dbi)); + assert(map.dbi != 0); + return map; +} + inline ::mdbx::map_handle txn::create_map(const char *name, const ::mdbx::key_mode key_mode, const ::mdbx::value_mode value_mode) { @@ -6443,6 +6458,15 @@ txn::open_map(const ::std::string_view &name, const ::mdbx::key_mode key_mode, return map; } +inline ::mdbx::map_handle +txn::open_map_accede(const ::std::string_view &name) const { + ::mdbx::map_handle map; + error::success_or_throw( + ::mdbx_dbi_open2(handle_, ::mdbx::slice(name), MDBX_DB_ACCEDE, &map.dbi)); + assert(map.dbi != 0); + return map; +} + inline ::mdbx::map_handle txn::create_map(const ::std::string_view &name, const ::mdbx::key_mode key_mode, const ::mdbx::value_mode value_mode) { @@ -6467,6 +6491,11 @@ txn::open_map(const ::std::string &name, const ::mdbx::key_mode key_mode, return open_map(::std::string_view(name), key_mode, value_mode); } +inline ::mdbx::map_handle +txn::open_map_accede(const ::std::string &name) const { + return open_map_accede(::std::string_view(name)); +} + inline ::mdbx::map_handle txn::create_map(const ::std::string &name, const ::mdbx::key_mode key_mode, const ::mdbx::value_mode value_mode) { @@ -6493,6 +6522,11 @@ txn::open_map(const ::std::string &name, const ::mdbx::key_mode key_mode, return open_map(name.c_str(), key_mode, value_mode); } +inline ::mdbx::map_handle +txn::open_map_accede(const ::std::string &name) const { + return open_map_accede(name.c_str()); +} + inline ::mdbx::map_handle txn::create_map(const ::std::string &name, const ::mdbx::key_mode key_mode, const ::mdbx::value_mode value_mode) {