From f82aad95337ec4d33a3ddc4fced01bdf37802003 Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Sun, 17 Sep 2023 14:01:08 +0100 Subject: [PATCH] Removing references to boost from nano::error Removes config variable NANO_USE_BOOST_TO_STD_ERROR_BRIDGE. NANO_USE_BOOST_TO_STD_ERROR_BRIDGE appears to only be needed pre boost 1.78, we now use boost as a submodule at version 1.82 --- nano/core_test/logger.cpp | 2 + nano/core_test/toml.cpp | 2 + nano/lib/errors.cpp | 74 ----------------------------- nano/lib/errors.hpp | 58 ---------------------- nano/lib/tlsconfig.cpp | 1 + nano/node/cli.cpp | 1 + nano/node/daemonconfig.cpp | 2 + nano/node/ipc/ipc_access_config.cpp | 1 + nano/node/logging.cpp | 1 + nano/node/rocksdb/rocksdb.cpp | 1 + nano/secure/ledger.cpp | 2 + nano/secure/plat/osx/working.mm | 4 +- nano/secure/plat/posix/working.cpp | 2 + 13 files changed, 18 insertions(+), 133 deletions(-) diff --git a/nano/core_test/logger.cpp b/nano/core_test/logger.cpp index d60cf397..88bccc5a 100644 --- a/nano/core_test/logger.cpp +++ b/nano/core_test/logger.cpp @@ -5,6 +5,8 @@ #include +#include + #include #include #include diff --git a/nano/core_test/toml.cpp b/nano/core_test/toml.cpp index eb3f60b4..b8098dd6 100644 --- a/nano/core_test/toml.cpp +++ b/nano/core_test/toml.cpp @@ -8,6 +8,8 @@ #include +#include + #include #include #include diff --git a/nano/lib/errors.cpp b/nano/lib/errors.cpp index f4eabbd6..822722be 100644 --- a/nano/lib/errors.cpp +++ b/nano/lib/errors.cpp @@ -282,48 +282,11 @@ std::string nano::error_config_messages::message (int ev) const return "Invalid error code"; } -#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE) -char const * nano::error_conversion::detail::generic_category::name () const noexcept -{ - return boost::system::generic_category ().name (); -} - -std::string nano::error_conversion::detail::generic_category::message (int value) const -{ - return boost::system::generic_category ().message (value); -} - -std::error_category const & nano::error_conversion::generic_category () -{ - static detail::generic_category instance; - return instance; -} - -std::error_code nano::error_conversion::convert (boost::system::error_code const & error) -{ - if (error.category () == boost::system::generic_category ()) - { - return std::error_code (error.value (), - nano::error_conversion::generic_category ()); - } - - debug_assert (false); - return nano::error_common::invalid_type_conversion; -} -#endif - nano::error::error (std::error_code code_a) { code = code_a; } -#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE) -nano::error::error (boost::system::error_code const & code_a) -{ - code = std::make_error_code (static_cast (code_a.value ())); -} -#endif - nano::error::error (std::string message_a) { code = nano::error_common::generic; @@ -358,24 +321,6 @@ nano::error & nano::error::operator= (std::error_code const code_a) return *this; } -#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE) -/** Assign boost error code (as converted to std::error_code) */ -nano::error & nano::error::operator= (boost::system::error_code const & code_a) -{ - code = nano::error_conversion::convert (code_a); - message.clear (); - return *this; -} - -/** Assign boost error code (as converted to std::error_code) */ -nano::error & nano::error::operator= (boost::system::errc::errc_t const & code_a) -{ - code = nano::error_conversion::convert (boost::system::errc::make_error_code (code_a)); - message.clear (); - return *this; -} -#endif - /** Set the error to nano::error_common::generic and the error message to \p message_a */ nano::error & nano::error::operator= (std::string message_a) { @@ -398,14 +343,6 @@ bool nano::error::operator== (std::error_code const code_a) const return code == code_a; } -#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE) -/** Return true if this#error_code equals the parameter */ -bool nano::error::operator== (boost::system::error_code const code_a) const -{ - return code.value () == code_a.value (); -} -#endif - /** Call the function iff the current error is zero */ nano::error & nano::error::then (std::function next) { @@ -495,14 +432,3 @@ nano::error & nano::error::clear () message.clear (); return *this; } - -#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE) -// TODO: theoretically, nothing besides template (partial) specializations should ever be added inside std... -namespace std -{ -std::error_code make_error_code (boost::system::errc::errc_t const & e) -{ - return std::error_code (static_cast (e), ::nano::error_conversion::generic_category ()); -} -} -#endif diff --git a/nano/lib/errors.hpp b/nano/lib/errors.hpp index 27e8c6c5..d06b5d02 100644 --- a/nano/lib/errors.hpp +++ b/nano/lib/errors.hpp @@ -1,8 +1,5 @@ #pragma once -#include -#include - #include #include #include @@ -197,51 +194,6 @@ REGISTER_ERROR_CODES (nano, error_rpc); REGISTER_ERROR_CODES (nano, error_process); REGISTER_ERROR_CODES (nano, error_config); -#if BOOST_VERSION >= 107800 -/* no need for error_code bridge */ -#else -#define NANO_USE_BOOST_TO_STD_ERROR_BRIDGE -#endif - -#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE) -/* boost->std error_code bridge */ -namespace nano -{ -namespace error_conversion -{ - std::error_category const & generic_category (); -} -} - -namespace std -{ -template <> -struct is_error_code_enum - : public std::true_type -{ -}; - -std::error_code make_error_code (boost::system::errc::errc_t const & e); -} -namespace nano -{ -namespace error_conversion -{ - namespace detail - { - class generic_category : public std::error_category - { - public: - char const * name () const noexcept override; - std::string message (int value) const override; - }; - } - std::error_category const & generic_category (); - std::error_code convert (boost::system::error_code const & error); -} -} -#endif - namespace nano { /** Adapter for std/boost::error_code, std::exception and bool flags to facilitate unified error handling */ @@ -253,24 +205,14 @@ public: error (nano::error && error_a) = default; error (std::error_code code_a); -#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE) - error (boost::system::error_code const & code_a); -#endif error (std::string message_a); error (std::exception const & exception_a); error & operator= (nano::error const & err_a); error & operator= (nano::error && err_a); error & operator= (std::error_code code_a); -#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE) - error & operator= (boost::system::error_code const & code_a); - error & operator= (boost::system::errc::errc_t const & code_a); -#endif error & operator= (std::string message_a); error & operator= (std::exception const & exception_a); bool operator== (std::error_code code_a) const; -#if defined(NANO_USE_BOOST_TO_STD_ERROR_BRIDGE) - bool operator== (boost::system::error_code code_a) const; -#endif error & then (std::function next); template error & accept (ErrorCode... err) diff --git a/nano/lib/tlsconfig.cpp b/nano/lib/tlsconfig.cpp index d16efcfa..34aade65 100644 --- a/nano/lib/tlsconfig.cpp +++ b/nano/lib/tlsconfig.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include diff --git a/nano/node/cli.cpp b/nano/node/cli.cpp index 5dd2c39f..a1dc89c5 100644 --- a/nano/node/cli.cpp +++ b/nano/node/cli.cpp @@ -6,6 +6,7 @@ #include #include +#include #include namespace diff --git a/nano/node/daemonconfig.cpp b/nano/node/daemonconfig.cpp index 3e232646..26e2f7fe 100644 --- a/nano/node/daemonconfig.cpp +++ b/nano/node/daemonconfig.cpp @@ -3,6 +3,8 @@ #include #include +#include + #include #include diff --git a/nano/node/ipc/ipc_access_config.cpp b/nano/node/ipc/ipc_access_config.cpp index 404ebe80..e7909a2b 100644 --- a/nano/node/ipc/ipc_access_config.cpp +++ b/nano/node/ipc/ipc_access_config.cpp @@ -2,6 +2,7 @@ #include #include +#include namespace { diff --git a/nano/node/logging.cpp b/nano/node/logging.cpp index 6a414f0b..5b342796 100644 --- a/nano/node/logging.cpp +++ b/nano/node/logging.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include diff --git a/nano/node/rocksdb/rocksdb.cpp b/nano/node/rocksdb/rocksdb.cpp index 7beac09a..3d2fdb4d 100644 --- a/nano/node/rocksdb/rocksdb.cpp +++ b/nano/node/rocksdb/rocksdb.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index 91116c64..4bf4c793 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -6,6 +6,8 @@ #include #include +#include + #include namespace diff --git a/nano/secure/plat/osx/working.mm b/nano/secure/plat/osx/working.mm index 48f8c50a..28aa1005 100644 --- a/nano/secure/plat/osx/working.mm +++ b/nano/secure/plat/osx/working.mm @@ -1,5 +1,7 @@ #include +#include + #include namespace nano @@ -12,4 +14,4 @@ boost::filesystem::path app_path () [dir_string release]; return result; } -} \ No newline at end of file +} diff --git a/nano/secure/plat/posix/working.cpp b/nano/secure/plat/posix/working.cpp index 1d36b163..c962bd77 100644 --- a/nano/secure/plat/posix/working.cpp +++ b/nano/secure/plat/posix/working.cpp @@ -1,6 +1,8 @@ #include #include +#include + #include #include