diff --git a/nano/core_test/block.cpp b/nano/core_test/block.cpp index 8e1e3c7ea8..ac0450595b 100644 --- a/nano/core_test/block.cpp +++ b/nano/core_test/block.cpp @@ -1,5 +1,5 @@ +#include #include -#include #include #include diff --git a/nano/core_test/message.cpp b/nano/core_test/message.cpp index fcec2417bc..082a600978 100644 --- a/nano/core_test/message.cpp +++ b/nano/core_test/message.cpp @@ -1,7 +1,7 @@ #include +#include #include #include -#include #include #include diff --git a/nano/core_test/network_filter.cpp b/nano/core_test/network_filter.cpp index e21af52cd8..21f6f7ec58 100644 --- a/nano/core_test/network_filter.cpp +++ b/nano/core_test/network_filter.cpp @@ -1,5 +1,5 @@ +#include #include -#include #include #include #include diff --git a/nano/lib/CMakeLists.txt b/nano/lib/CMakeLists.txt index d0207325cb..4acaf59bb6 100644 --- a/nano/lib/CMakeLists.txt +++ b/nano/lib/CMakeLists.txt @@ -25,6 +25,7 @@ add_library( blockbuilders.cpp blocks.hpp blocks.cpp + char_traits.hpp cli.hpp cli.cpp config.hpp diff --git a/nano/lib/char_traits.hpp b/nano/lib/char_traits.hpp new file mode 100644 index 0000000000..b21f2364a0 --- /dev/null +++ b/nano/lib/char_traits.hpp @@ -0,0 +1,75 @@ +#pragma once + +#include +#include + +/** + * A traits class to allow us to use uint8_t as a char type for streams + * Using `char_traits` directly is not specified by the standard, is deprecated and scheduled for removal + * Based on implementation from clang + */ +struct uint8_char_traits +{ + using char_type = uint8_t; + using int_type = std::char_traits::int_type; + using off_type = std::char_traits::off_type; + using pos_type = std::char_traits::pos_type; + using state_type = std::char_traits::state_type; + + static inline void assign (char_type & a, const char_type & b) noexcept + { + a = b; + } + static inline bool eq (char_type a, char_type b) noexcept + { + return a == b; + } + static inline bool lt (char_type a, char_type b) noexcept + { + return a < b; + } + static int compare (const char_type * a, const char_type * b, size_t size) + { + return std::char_traits::compare (reinterpret_cast (a), reinterpret_cast (b), size); + } + static inline size_t length (const char_type * a) + { + return std::char_traits::length (reinterpret_cast (a)); + } + static inline const char_type * find (const char_type * a, size_t size, const char_type & b) + { + return reinterpret_cast (std::char_traits::find (reinterpret_cast (a), size, reinterpret_cast (b))); + } + static char_type * move (char_type * a, const char_type * b, size_t size) + { + return reinterpret_cast (std::char_traits::move (reinterpret_cast (a), reinterpret_cast (b), size)); + } + static char_type * copy (char_type * a, const char_type * b, size_t size) + { + return reinterpret_cast (std::char_traits::copy (reinterpret_cast (a), reinterpret_cast (b), size)); + } + static char_type * assign (char_type * a, size_t size, char_type b) + { + return reinterpret_cast (std::char_traits::assign (reinterpret_cast (a), size, reinterpret_cast (b))); + } + static inline int_type not_eof (int_type v) noexcept + { + return std::char_traits::not_eof (v); + } + static inline char_type to_char_type (int_type v) noexcept + { + return char_type (v); + } + static inline int_type to_int_type (char_type v) noexcept + { + return int_type (v); + } + static inline bool eq_int_type (int_type a, int_type b) noexcept + { + return a == b; + } + static inline int_type eof () noexcept + { + return std::char_traits::eof (); + } +}; \ No newline at end of file diff --git a/nano/lib/stream.hpp b/nano/lib/stream.hpp index 77bb86185c..895719e801 100644 --- a/nano/lib/stream.hpp +++ b/nano/lib/stream.hpp @@ -1,15 +1,23 @@ #pragma once +#include #include #include +#include +#include +#include #include +#include +#include namespace nano { // We operate on streams of uint8_t by convention -using stream = std::basic_streambuf; +using stream = std::basic_streambuf; +using bufferstream = boost::iostreams::stream_buffer, uint8_char_traits>; +using vectorstream = boost::iostreams::stream_buffer>, uint8_char_traits>; // Read a raw byte stream the size of `T' and fill value. Returns true if there was an error, false otherwise template diff --git a/nano/node/bootstrap/block_deserializer.cpp b/nano/node/bootstrap/block_deserializer.cpp index 6eaaf29049..23a4d30d83 100644 --- a/nano/node/bootstrap/block_deserializer.cpp +++ b/nano/node/bootstrap/block_deserializer.cpp @@ -1,7 +1,7 @@ #include +#include #include #include -#include nano::bootstrap::block_deserializer::block_deserializer () : read_buffer{ std::make_shared> () } diff --git a/nano/node/common.cpp b/nano/node/common.cpp index 52b7dce80c..9a4de71724 100644 --- a/nano/node/common.cpp +++ b/nano/node/common.cpp @@ -1,11 +1,11 @@ #include #include +#include #include #include #include #include #include -#include #include diff --git a/nano/node/messages.cpp b/nano/node/messages.cpp index 2417eddf18..0f4699c009 100644 --- a/nano/node/messages.cpp +++ b/nano/node/messages.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 049e940c69..0c764d9de4 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -12,7 +13,6 @@ #include #include #include -#include #include #include diff --git a/nano/secure/CMakeLists.txt b/nano/secure/CMakeLists.txt index b3691dea8e..b294503712 100644 --- a/nano/secure/CMakeLists.txt +++ b/nano/secure/CMakeLists.txt @@ -39,7 +39,6 @@ add_library( ${PLATFORM_SECURE_SOURCE} ${CMAKE_BINARY_DIR}/bootstrap_weights_live.cpp ${CMAKE_BINARY_DIR}/bootstrap_weights_beta.cpp - buffer.hpp common.hpp common.cpp ledger.hpp diff --git a/nano/secure/buffer.hpp b/nano/secure/buffer.hpp deleted file mode 100644 index d1a4511789..0000000000 --- a/nano/secure/buffer.hpp +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once - -#include -#include -#include - -#include - -namespace nano -{ -using bufferstream = boost::iostreams::stream_buffer>; -using vectorstream = boost::iostreams::stream_buffer>>; -} diff --git a/nano/secure/network_filter.cpp b/nano/secure/network_filter.cpp index 4b84f5e334..059cddb30e 100644 --- a/nano/secure/network_filter.cpp +++ b/nano/secure/network_filter.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include diff --git a/nano/store/component.hpp b/nano/store/component.hpp index 5b1d4e44ac..a6584c9b84 100644 --- a/nano/store/component.hpp +++ b/nano/store/component.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include @@ -33,8 +33,8 @@ class ledger_cache; namespace store { /** - * Store manager - */ + * Store manager + */ class component { friend class rocksdb_block_store_tombstone_count_Test; diff --git a/nano/store/db_val.hpp b/nano/store/db_val.hpp index 9a52ffb0ac..957492e23e 100644 --- a/nano/store/db_val.hpp +++ b/nano/store/db_val.hpp @@ -1,6 +1,7 @@ #pragma once + #include -#include +#include #include #include #include diff --git a/nano/store/lmdb/lmdb.cpp b/nano/store/lmdb/lmdb.cpp index 6bf1539980..e1385ac6da 100644 --- a/nano/store/lmdb/lmdb.cpp +++ b/nano/store/lmdb/lmdb.cpp @@ -1,5 +1,5 @@ +#include #include -#include #include #include #include