1 #ifndef MASTERCORE_VALUES_H
2 #define MASTERCORE_VALUES_H
7 #include <boost/utility/enable_if.hpp>
8 #include <boost/type_traits/is_arithmetic.hpp>
48 inline bool IsEcosystem(T value,
typename boost::enable_if<boost::is_arithmetic<T> >::type* dummy = 0)
50 uint8_t n =
static_cast<uint8_t
>(value);
51 return (ECOSYSTEM_MAIN == n ||
63 inline bool IsBlockInterval(T value,
typename boost::enable_if<boost::is_arithmetic<T> >::type* dummy = 0)
65 uint8_t n =
static_cast<uint8_t
>(value);
66 return (BLOCK_INTERVAL_MIN <= n &&
67 BLOCK_INTERVAL_MAX >= n);
78 inline bool IsDexAction(T value,
typename boost::enable_if<boost::is_arithmetic<T> >::type* dummy = 0)
80 switch (static_cast<uint8_t>(value)) {
82 case DEX_ACTION_UPDATE:
83 case DEX_ACTION_CANCEL:
97 inline bool IsMetaDexAction(T value,
typename boost::enable_if<boost::is_arithmetic<T> >::type* dummy = 0)
99 switch (static_cast<uint8_t>(value)) {
100 case MDEX_ACTION_ADD:
101 case MDEX_ACTION_CANCEL_AT_PRICE:
102 case MDEX_ACTION_CANCEL_ALL_FOR_PAIR:
103 case MDEX_ACTION_CANCEL_CANCEL_EVERYTHING:
117 inline bool IsSubAction(T value,
typename boost::enable_if<boost::is_arithmetic<T> >::type* dummy = 0)
131 inline bool IsPropertyType(T value,
typename boost::enable_if<boost::is_arithmetic<T> >::type* dummy = 0)
133 switch (static_cast<uint8_t>(value)) {
134 case PROPERTY_TYPE_INDIVISIBLE:
135 case PROPERTY_TYPE_DIVISIBLE:
136 case PROPERTY_TYPE_INDIVISIBLE_REPLACING:
137 case PROPERTY_TYPE_DIVISIBLE_REPLACING:
138 case PROPERTY_TYPE_INDIVISIBLE_APPENDING:
139 case PROPERTY_TYPE_DIVISIBLE_APPENDING:
153 inline bool IsPropertyId(T value,
typename boost::enable_if<boost::is_arithmetic<T> >::type* dummy = 0)
155 uint32_t n =
static_cast<uint32_t
>(value);
156 return (PROPERTY_ID_MIN <= n &&
157 PROPERTY_ID_MAX >= n);
168 inline bool IsDivisibleAmount(T value,
typename boost::enable_if<boost::is_arithmetic<T> >::type* dummy = 0)
170 long double n =
static_cast<long double>(value);
171 return (AMOUNT_DIVISIBLE_MIN <= n &&
172 AMOUNT_DIVISIBLE_MAX >= n);
183 inline bool IsIndivisibleAmount(T value,
typename boost::enable_if<boost::is_arithmetic<T> >::type* dummy = 0)
185 uint64_t n =
static_cast<uint64_t
>(value);
186 return (AMOUNT_INDIVISIBLE_MIN <= n &&
187 AMOUNT_INDIVISIBLE_MAX >= n);
198 inline bool IsTokenAmount(T value,
typename boost::enable_if<boost::is_arithmetic<T> >::type* dummy = 0)
208 #endif // MASTERCORE_VALUES_H
const uint8_t BLOCK_INTERVAL_MAX
Maximum interval measured in blocks.
const uint64_t AMOUNT_INDIVISIBLE_MIN
Minimum indivisible amount.
bool IsMetaDexAction(T value, typename boost::enable_if< boost::is_arithmetic< T > >::type *dummy=0)
Checks whether the value describes an action of the distributed token exchange.
const uint16_t PROPERTY_TYPE_DIVISIBLE
Divisible property type.
const uint32_t PROPERTY_ID_MIN
Minimum property identifier value.
const uint16_t PROPERTY_TYPE_DIVISIBLE_APPENDING
Indivisible property type when appending a property.
const uint8_t DEX_ACTION_NEW
New offer action value.
const uint8_t MDEX_ACTION_ADD
Add offer action value.
const uint8_t DEX_ACTION_CANCEL
Cancel offer action value.
bool IsDexAction(T value, typename boost::enable_if< boost::is_arithmetic< T > >::type *dummy=0)
Checks whether the value describes an action of the distributed exchange.
const uint8_t ECOSYSTEM_TEST
Test ecosystem value.
const uint8_t ECOSYSTEM_MAIN
Main ecosystem value.
bool IsBlockInterval(T value, typename boost::enable_if< boost::is_arithmetic< T > >::type *dummy=0)
Checks whether the value describes an interval measured in blocks.
const uint16_t PROPERTY_TYPE_INDIVISIBLE_REPLACING
Indivisible property type when replacing a property.
const uint8_t MDEX_ACTION_CANCEL_CANCEL_EVERYTHING
Cancel every offer action value.
bool IsTokenAmount(T value, typename boost::enable_if< boost::is_arithmetic< T > >::type *dummy=0)
Checks whether the value describes either a divisible or indivisible amount.
bool IsEcosystem(T value, typename boost::enable_if< boost::is_arithmetic< T > >::type *dummy=0)
Checks whether the value describes an ecosystem.
bool IsPropertyId(T value, typename boost::enable_if< boost::is_arithmetic< T > >::type *dummy=0)
Checks whether the value describes a property identifier.
const uint8_t BLOCK_INTERVAL_MIN
Minimum interval measured in blocks.
const uint8_t MDEX_ACTION_CANCEL_AT_PRICE
Cancel offers at price action value.
bool IsPropertyType(T value, typename boost::enable_if< boost::is_arithmetic< T > >::type *dummy=0)
Checks whether the value describes a property type.
const uint16_t PROPERTY_TYPE_INDIVISIBLE_APPENDING
Indivisible property type when appending a property.
const uint8_t DEX_ACTION_UPDATE
Update offer action value.
const uint16_t PROPERTY_TYPE_INDIVISIBLE
Indivisible property type.
const long double AMOUNT_DIVISIBLE_MAX
Maximum divisible amount.
bool IsSubAction(T value, typename boost::enable_if< boost::is_arithmetic< T > >::type *dummy=0)
Checks whether the value describes a subaction.
const uint16_t PROPERTY_TYPE_DIVISIBLE_REPLACING
Divisible property type when replacing a property.
bool IsDivisibleAmount(T value, typename boost::enable_if< boost::is_arithmetic< T > >::type *dummy=0)
Checks whether the value describes a divisible amount.
const uint32_t PROPERTY_ID_MAX
Maximum property identifier value.
const uint8_t MDEX_ACTION_CANCEL_ALL_FOR_PAIR
Cancel all offers of property pair action value.
bool IsIndivisibleAmount(T value, typename boost::enable_if< boost::is_arithmetic< T > >::type *dummy=0)
Checks whether the value describes an indivisible amount.
const long double AMOUNT_DIVISIBLE_MIN
Minimum divisible amount.
const uint64_t AMOUNT_INDIVISIBLE_MAX
Maximum indivisible amount.
int atoi(const std::string &str)