19#include <boost/multiprecision/cpp_int.hpp>
20#include <boost/interprocess/containers/string.hpp>
21#include <boost/interprocess/allocators/allocator.hpp>
22#include <boost/interprocess/managed_mapped_file.hpp>
29 using shared_string = bip::basic_string< char, std::char_traits< char >, bip::allocator<char, bip::managed_mapped_file::segment_manager> >;
32 using UInt = boost::multiprecision::number<
33 boost::multiprecision::cpp_int_backend<Size, Size, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void> >;
35 using Int = boost::multiprecision::number<
36 boost::multiprecision::cpp_int_backend<Size, Size, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void> >;
41 template<
typename Stream,
typename T>
void pack(
Stream&
s,
const boost::multiprecision::number<T>& n );
42 template<
typename Stream,
typename T>
void unpack(
Stream&
s, boost::multiprecision::number<T>& n );
44 template<
typename Stream,
typename Arg0,
typename... Args>
50 template<
typename Stream>
58 template<
typename Stream>
62 std::string
name, what;
73 template<
typename Stream>
78 template<
typename Stream>
86 template<
typename Stream>
92 template<
typename Stream>
100 template<
typename Stream>
104 s.write( (
const char*)&usec,
sizeof(usec) );
107 template<
typename Stream>
111 s.read( (
char*)&sec,
sizeof(sec) );
115 template<
typename Stream>
119 s.write( (
const char*)&usec,
sizeof(usec) );
122 template<
typename Stream>
126 s.read( (
char*)&usec,
sizeof(usec) );
130 template<
typename Stream>
134 s.write( (
const char*)&usec_as_int64,
sizeof(usec_as_int64) );
137 template<
typename Stream>
141 s.read( (
char*)&usec_as_int64,
sizeof(usec_as_int64) );
145 template<
typename Stream,
typename T,
size_t N>
153 template<
typename Stream,
typename T,
size_t N>
157 s.write((
const char*)&v.data[0],
N*
sizeof(
T));
160 template<
typename Stream,
typename T,
size_t N>
168 template<
typename Stream,
typename T,
size_t N>
172 s.read((
char*)&v.data[0],
N*
sizeof(
T));
175 template<
typename Stream,
typename T,
size_t N>
182 template<
typename Stream,
typename T,
size_t N>
191 template<
typename Stream,
typename T>
198 template<
typename Stream,
typename T>
210 b |= ((val > 0) << 7);
211 s.write((
char*)&b,1);
220 b |= ((val > 0) << 7);
221 s.write((
char*)&b,1);
226 uint32_t v = 0;
char b = 0;
int by = 0;
232 vi.
value= (v>>1) ^ (~(v&1)+1ull);
241 }
while(
uint8_t(b) & 0x80 && by < 32 );
245 template<
typename Stream,
typename T>
inline void unpack(
Stream&
s,
const T& vi )
254 template<
typename Stream,
typename T>
257 template<
typename Stream,
typename T>
260 template<
typename Stream,
typename T,
unsigned int S,
typename Align>
265 template<
typename Stream,
typename T,
unsigned int S,
typename Align>
271 template<
typename Stream,
typename T>
277 template<
typename Stream,
typename T>
303 if( v.size() )
s.write( v.c_str(), v.size() );
309 v =
fc::string(tmp.data(),tmp.data()+tmp.size());
317 if( v.size() )
s.write( v.c_str(), v.size() );
324 v.append(tmp.begin(), tmp.end());
340 template<
typename Stream,
typename Class>
345 template<
typename T,
typename C, T(C::*p)>
354 template<
typename Stream,
typename Class>
359 template<
typename T,
typename C, T(C::*p)>
369 template<
typename IsClass=fc::true_type>
371 template<
typename Stream,
typename T>
373 template<
typename Stream,
typename T>
379 template<
typename Stream,
typename T>
381 s.write( (
char*)&v,
sizeof(v) );
383 template<
typename Stream,
typename T>
385 s.read( (
char*)&v,
sizeof(v) );
389 template<
typename IsEnum=fc::false_type>
391 template<
typename Stream,
typename T>
395 template<
typename Stream,
typename T>
402 template<
typename Stream,
typename T>
406 template<
typename Stream,
typename T>
414 template<
typename IsReflected=fc::false_type>
416 template<
typename Stream,
typename T>
420 template<
typename Stream,
typename T>
427 template<
typename Stream,
typename T>
431 template<
typename Stream,
typename T>
442 template<
typename Stream,
typename T>
446 auto itr =
value.begin();
447 auto end =
value.end();
448 while( itr != end ) {
453 template<
typename Stream,
typename T>
463 value.insert( std::move(tmp) );
468 template<
typename Stream,
typename K,
typename V>
473 template<
typename Stream,
typename K,
typename V>
480 template<
typename Stream,
typename K,
typename V>
484 auto itr =
value.begin();
485 auto end =
value.end();
486 while( itr != end ) {
491 template<
typename Stream,
typename K,
typename V>
502 value.insert( std::move(tmp) );
505 template<
typename Stream,
typename K,
typename V>
509 auto itr =
value.begin();
510 auto end =
value.end();
511 while( itr != end ) {
516 template<
typename Stream,
typename K,
typename V>
526 value.insert( std::move(tmp) );
530 template<
typename Stream,
typename T>
534 for(
const auto& i :
value ) {
539 template<
typename Stream,
typename T>
544 for(
auto& i :
value ) {
549 template<
typename Stream,
typename T,
typename...
U>
553 for(
const auto& i :
value ) {
558 template<
typename Stream,
typename T,
typename...
U>
564 for(
auto& i :
value ) {
569 template<
typename Stream,
typename T>
573 for(
const auto& i :
value ) {
578 template<
typename Stream,
typename T>
583 for(
auto& i :
value ) {
588 template<
typename Stream,
typename T>
592 for(
const auto& i :
value ) {
597 template<
typename Stream,
typename T>
601 while( size.
value-- ) {
604 value.emplace_back( std::move( i ) );
608 template<
typename Stream,
typename T>
612 auto itr =
value.begin();
613 auto end =
value.end();
614 while( itr != end ) {
620 template<
typename Stream,
typename T>
628 value.insert( std::move(tmp) );
632 template<
typename Stream,
typename T, std::
size_t S>
633 inline auto pack(
Stream&
s,
const std::array<T, S>&
value ) -> std::enable_if_t<is_trivial_array<T>>
635 s.write((
const char*)
value.data(),
S *
sizeof(
T));
638 template<
typename Stream,
typename T, std::
size_t S>
639 inline auto pack(
Stream&
s,
const std::array<T, S>&
value ) -> std::enable_if_t<!is_trivial_array<T>>
641 for( std::size_t i = 0; i <
S; ++i ) {
646 template<
typename Stream,
typename T, std::
size_t S>
649 s.read((
char*)
value.data(),
S *
sizeof(
T));
652 template<
typename Stream,
typename T, std::
size_t S>
653 inline auto unpack(
Stream&
s, std::array<T, S>&
value ) -> std::enable_if_t<!is_trivial_array<T>>
655 for( std::size_t i = 0; i <
S; ++i ) {
660 template<
typename Stream,
typename T>
664 template<
typename Stream,
typename T>
679 inline std::vector<char>
pack(
const T& v ) {
682 std::vector<char> vec(ps.tellp());
691 template<
typename T,
typename... Next>
692 inline std::vector<char>
pack(
const T& v, Next... next ) {
695 std::vector<char> vec(ps.tellp());
715 inline void unpack(
const std::vector<char>&
s,
T& tmp )
743 template<
typename Stream>
756 template<
typename Stream>
770 template<
typename Stream,
typename...
T>
787 template<
typename Stream,
typename T>
void pack(
Stream&
s,
const boost::multiprecision::number<T>& n ) {
788 static_assert(
sizeof( n ) == (std::numeric_limits<boost::multiprecision::number<T>>::digits+1)/8,
"unexpected padding" );
789 s.write( (
const char*)&n,
sizeof(n) );
791 template<
typename Stream,
typename T>
void unpack(
Stream&
s, boost::multiprecision::number<T>& n ) {
792 static_assert(
sizeof( n ) == (std::numeric_limits<boost::multiprecision::number<T>>::digits+1)/8,
"unexpected padding" );
793 s.read( (
char*)&n,
sizeof(n) );
Used to generate a useful error report when an exception is thrown.
const log_messages & get_log() const
const char * name() const
const char * what() const noexcept override
Used to forward declare value types.
aggregates a message along with the context and associated meta-information.
constexpr int64_t count() const
wraps boost::filesystem::path to provide platform independent path manipulation.
std::string generic_string() const
constexpr uint32_t sec_since_epoch() const
constexpr const microseconds & time_since_epoch() const
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
Concept for reading and writing characters.
Defines exception's used by fc.
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
#define FC_RETHROW_EXCEPTIONS(LOG_LEVEL, FORMAT,...)
Catchs all exception's, std::exceptions, and ... and rethrows them after appending the provided log m...
void unpack(Stream &s, std::deque< T > &value)
constexpr bool has_feature_reflector_init_on_unpacked_reflected_types
void pack(Stream &s, const std::deque< T > &value)
bip::basic_string< char, std::char_traits< char >, bip::allocator< char, bip::managed_mapped_file::segment_manager > > shared_string
size_t pack_size(const T &v)
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< Size, Size, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > UInt
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< Size, Size, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void > > Int
std::vector< log_message > log_messages
constexpr microseconds seconds(int64_t s)
void from_index(variant &v, int index)
#define S(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
#define T(meth, val, expected)
unsigned __int64 uint64_t
static void unpack(Stream &s, T &v)
static void pack(Stream &s, const T &v)
static void unpack(Stream &s, T &v)
static void pack(Stream &s, const T &v)
static void pack(Stream &s, const T &v)
static void unpack(Stream &s, T &v)
static void pack(Stream &s, const T &v)
static void unpack(Stream &s, T &v)
static void pack(Stream &s, const T &v)
static void unpack(Stream &s, T &v)
static void pack(Stream &s, const T &v)
static void unpack(Stream &s, T &v)
void operator()(const char *name) const
pack_object_visitor(const Class &_c, Stream &_s)
unpack_object_visitor(Class &_c, Stream &_s)
void operator()(const char *name) const
pack_static_variant(Stream &s)
void operator()(const T &v) const
unpack_static_variant(Stream &s)
void operator()(T &v) const
defines visit functions for T Unless this is specialized, visit() will not be defined for T.
serializes a 32 bit signed interger in as few bytes as possible
#define MAX_SIZE_OF_BYTE_ARRAYS
#define MAX_NUM_ARRAY_ELEMENTS