Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
varint.hpp
Go to the documentation of this file.
1#pragma once
2#include <stdint.h>
3
4namespace fc {
5
8
9 template<typename T>
11
12 operator uint32_t()const { return value; }
13 //operator uint64_t()const { return value; }
14
15 unsigned_int& operator=( int32_t v ) { value = v; return *this; }
16
18
19 friend bool operator==( const unsigned_int& i, const uint32_t& v ) { return i.value == v; }
20 friend bool operator==( const uint32_t& i, const unsigned_int& v ) { return i == v.value; }
21 friend bool operator==( const unsigned_int& i, const unsigned_int& v ) { return i.value == v.value; }
22
23 friend bool operator!=( const unsigned_int& i, const uint32_t& v ) { return i.value != v; }
24 friend bool operator!=( const uint32_t& i, const unsigned_int& v ) { return i != v.value; }
25 friend bool operator!=( const unsigned_int& i, const unsigned_int& v ) { return i.value != v.value; }
26
27 friend bool operator<( const unsigned_int& i, const uint32_t& v ) { return i.value < v; }
28 friend bool operator<( const uint32_t& i, const unsigned_int& v ) { return i < v.value; }
29 friend bool operator<( const unsigned_int& i, const unsigned_int& v ) { return i.value < v.value; }
30
31 friend bool operator>=( const unsigned_int& i, const uint32_t& v ) { return i.value >= v; }
32 friend bool operator>=( const uint32_t& i, const unsigned_int& v ) { return i >= v.value; }
33 friend bool operator>=( const unsigned_int& i, const unsigned_int& v ) { return i.value >= v.value; }
34};
35
41struct signed_int {
42 signed_int( int32_t v = 0 ):value(v){}
43 operator int32_t()const { return value; }
44 template<typename T>
45 signed_int& operator=( const T& v ) { value = v; return *this; }
46 signed_int operator++(int) { return value++; }
47 signed_int& operator++(){ ++value; return *this; }
48
50
51 friend bool operator==( const signed_int& i, const int32_t& v ) { return i.value == v; }
52 friend bool operator==( const int32_t& i, const signed_int& v ) { return i == v.value; }
53 friend bool operator==( const signed_int& i, const signed_int& v ) { return i.value == v.value; }
54
55 friend bool operator!=( const signed_int& i, const int32_t& v ) { return i.value != v; }
56 friend bool operator!=( const int32_t& i, const signed_int& v ) { return i != v.value; }
57 friend bool operator!=( const signed_int& i, const signed_int& v ) { return i.value != v.value; }
58
59 friend bool operator<( const signed_int& i, const int32_t& v ) { return i.value < v; }
60 friend bool operator<( const int32_t& i, const signed_int& v ) { return i < v.value; }
61 friend bool operator<( const signed_int& i, const signed_int& v ) { return i.value < v.value; }
62
63 friend bool operator>=( const signed_int& i, const int32_t& v ) { return i.value >= v; }
64 friend bool operator>=( const int32_t& i, const signed_int& v ) { return i >= v.value; }
65 friend bool operator>=( const signed_int& i, const signed_int& v ) { return i.value >= v.value; }
66};
67
68class variant;
69
70void to_variant( const signed_int& var, variant& vo );
71void from_variant( const variant& var, signed_int& vo );
72void to_variant( const unsigned_int& var, variant& vo );
73void from_variant( const variant& var, unsigned_int& vo );
74
75} // namespace fc
76
77#include <unordered_map>
78namespace std
79{
80 template<>
81 struct hash<fc::signed_int>
82 {
83 public:
84 size_t operator()(const fc::signed_int &a) const
85 {
86 return std::hash<int32_t>()(a.value);
87 }
88 };
89 template<>
90 struct hash<fc::unsigned_int>
91 {
92 public:
93 size_t operator()(const fc::signed_int &a) const
94 {
95 return std::hash<uint32_t>()(a.value);
96 }
97 };
98}
namespace sysio::chain
Definition authority.cpp:3
void from_variant(const fc::variant &v, sysio::chain::chain_id_type &cid)
void to_variant(const sysio::chain::shared_public_key &var, fc::variant &vo)
Definition authority.cpp:4
Definition name.hpp:106
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
#define T(meth, val, expected)
unsigned int uint32_t
Definition stdint.h:126
signed int int32_t
Definition stdint.h:123
serializes a 32 bit signed interger in as few bytes as possible
Definition varint.hpp:41
friend bool operator>=(const signed_int &i, const int32_t &v)
Definition varint.hpp:63
signed_int & operator++()
Definition varint.hpp:47
friend bool operator!=(const signed_int &i, const int32_t &v)
Definition varint.hpp:55
friend bool operator==(const signed_int &i, const signed_int &v)
Definition varint.hpp:53
int32_t value
Definition varint.hpp:49
signed_int operator++(int)
Definition varint.hpp:46
friend bool operator!=(const int32_t &i, const signed_int &v)
Definition varint.hpp:56
friend bool operator!=(const signed_int &i, const signed_int &v)
Definition varint.hpp:57
friend bool operator==(const signed_int &i, const int32_t &v)
Definition varint.hpp:51
friend bool operator>=(const signed_int &i, const signed_int &v)
Definition varint.hpp:65
signed_int & operator=(const T &v)
Definition varint.hpp:45
friend bool operator<(const signed_int &i, const signed_int &v)
Definition varint.hpp:61
signed_int(int32_t v=0)
Definition varint.hpp:42
friend bool operator>=(const int32_t &i, const signed_int &v)
Definition varint.hpp:64
friend bool operator<(const signed_int &i, const int32_t &v)
Definition varint.hpp:59
friend bool operator<(const int32_t &i, const signed_int &v)
Definition varint.hpp:60
friend bool operator==(const int32_t &i, const signed_int &v)
Definition varint.hpp:52
friend bool operator==(const unsigned_int &i, const uint32_t &v)
Definition varint.hpp:19
friend bool operator!=(const uint32_t &i, const unsigned_int &v)
Definition varint.hpp:24
friend bool operator<(const unsigned_int &i, const uint32_t &v)
Definition varint.hpp:27
unsigned_int(uint32_t v=0)
Definition varint.hpp:7
friend bool operator!=(const unsigned_int &i, const uint32_t &v)
Definition varint.hpp:23
friend bool operator<(const unsigned_int &i, const unsigned_int &v)
Definition varint.hpp:29
friend bool operator!=(const unsigned_int &i, const unsigned_int &v)
Definition varint.hpp:25
friend bool operator==(const uint32_t &i, const unsigned_int &v)
Definition varint.hpp:20
friend bool operator<(const uint32_t &i, const unsigned_int &v)
Definition varint.hpp:28
friend bool operator>=(const unsigned_int &i, const uint32_t &v)
Definition varint.hpp:31
uint32_t value
Definition varint.hpp:17
friend bool operator>=(const uint32_t &i, const unsigned_int &v)
Definition varint.hpp:32
friend bool operator==(const unsigned_int &i, const unsigned_int &v)
Definition varint.hpp:21
unsigned_int & operator=(int32_t v)
Definition varint.hpp:15
friend bool operator>=(const unsigned_int &i, const unsigned_int &v)
Definition varint.hpp:33
size_t operator()(const fc::signed_int &a) const
Definition varint.hpp:84
size_t operator()(const fc::signed_int &a) const
Definition varint.hpp:93