BitShares-Core
7.0.2
BitShares blockchain node software and command-line wallet software
|
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
More...
#include <variant.hpp>
Classes | |
class | visitor |
Public Types | |
enum | type_id { null_type = 0, int64_type = 1, uint64_type = 2, double_type = 3, bool_type = 4, string_type = 5, array_type = 6, object_type = 7, blob_type = 8 } |
Public Member Functions | |
variant () | |
Constructs a null_type variant. More... | |
variant (std::nullptr_t, uint32_t max_depth=1) | |
Constructs a null_type variant. More... | |
variant (const char *str, uint32_t max_depth=1) | |
variant (char *str, uint32_t max_depth=1) | |
variant (wchar_t *str, uint32_t max_depth=1) | |
variant (const wchar_t *str, uint32_t max_depth=1) | |
variant (float val, uint32_t max_depth=1) | |
variant (uint8_t val, uint32_t max_depth=1) | |
variant (int8_t val, uint32_t max_depth=1) | |
variant (uint16_t val, uint32_t max_depth=1) | |
variant (int16_t val, uint32_t max_depth=1) | |
variant (uint32_t val, uint32_t max_depth=1) | |
variant (int32_t val, uint32_t max_depth=1) | |
variant (uint64_t val, uint32_t max_depth=1) | |
variant (int64_t val, uint32_t max_depth=1) | |
variant (double val, uint32_t max_depth=1) | |
variant (bool val, uint32_t max_depth=1) | |
variant (blob val, uint32_t max_depth=1) | |
variant (std::string val, uint32_t max_depth=1) | |
variant (variant_object, uint32_t max_depth=1) | |
variant (mutable_variant_object, uint32_t max_depth=1) | |
variant (variants, uint32_t max_depth=1) | |
variant (const variant &, uint32_t max_depth=1) | |
variant (variant &&, uint32_t max_depth=1) | |
~variant () | |
void | visit (const visitor &v) const |
type_id | get_type () const |
bool | is_null () const |
bool | is_string () const |
bool | is_bool () const |
bool | is_int64 () const |
bool | is_uint64 () const |
bool | is_double () const |
bool | is_object () const |
bool | is_array () const |
bool | is_blob () const |
bool | is_numeric () const |
bool | is_integer () const |
int64_t | as_int64 () const |
uint64_t | as_uint64 () const |
bool | as_bool () const |
double | as_double () const |
blob & | get_blob () |
const blob & | get_blob () const |
blob | as_blob () const |
std::string | as_string () const |
const std::string & | get_string () const |
variants & | get_array () |
const variants & | get_array () const |
variant_object & | get_object () |
const variant_object & | get_object () const |
const variant & | operator[] (const char *) const |
const variant & | operator[] (size_t pos) const |
size_t | size () const |
template<typename T > | |
T | as (uint32_t max_depth) const |
template<typename T > | |
void | as (T &v, uint32_t max_depth) const |
variant & | operator= (variant &&v) |
variant & | operator= (const variant &v) |
template<typename T > | |
variant & | operator= (T &&v) |
template<typename T > | |
variant (const optional< T > &v, uint32_t max_depth) | |
template<typename T > | |
variant (const T &val, uint32_t max_depth) | |
void | clear () |
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
variant's allocate everything but strings, arrays, and objects on the stack and are 'move aware' for values allocated on the heap.
Memory usage on 64 bit systems is 16 bytes and 12 bytes on 32 bit systems.
Definition at line 198 of file variant.hpp.
enum fc::variant::type_id |
Enumerator | |
---|---|
null_type | |
int64_type | |
uint64_type | |
double_type | |
bool_type | |
string_type | |
array_type | |
object_type | |
blob_type |
Definition at line 201 of file variant.hpp.
fc::variant::variant | ( | ) |
Constructs a null_type variant.
Definition at line 30 of file variant.cpp.
fc::variant::variant | ( | std::nullptr_t | , |
uint32_t | max_depth = 1 |
||
) |
Constructs a null_type variant.
Definition at line 35 of file variant.cpp.
fc::variant::variant | ( | const char * | str, |
uint32_t | max_depth = 1 |
||
) |
str | - UTF8 string |
max_depth | - the maximum depth to recurse into |
Definition at line 120 of file variant.cpp.
fc::variant::variant | ( | char * | str, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 114 of file variant.cpp.
fc::variant::variant | ( | wchar_t * | str, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 127 of file variant.cpp.
fc::variant::variant | ( | const wchar_t * | str, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 138 of file variant.cpp.
fc::variant::variant | ( | float | val, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 96 of file variant.cpp.
fc::variant::variant | ( | uint8_t | val, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 40 of file variant.cpp.
fc::variant::variant | ( | int8_t | val, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 46 of file variant.cpp.
fc::variant::variant | ( | uint16_t | val, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 52 of file variant.cpp.
fc::variant::variant | ( | int16_t | val, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 58 of file variant.cpp.
fc::variant::variant | ( | uint32_t | val, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 64 of file variant.cpp.
fc::variant::variant | ( | int32_t | val, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 70 of file variant.cpp.
fc::variant::variant | ( | uint64_t | val, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 76 of file variant.cpp.
fc::variant::variant | ( | int64_t | val, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 90 of file variant.cpp.
fc::variant::variant | ( | double | val, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 102 of file variant.cpp.
fc::variant::variant | ( | bool | val, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 108 of file variant.cpp.
fc::variant::variant | ( | blob | val, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 153 of file variant.cpp.
fc::variant::variant | ( | std::string | val, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 148 of file variant.cpp.
fc::variant::variant | ( | variant_object | obj, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 159 of file variant.cpp.
fc::variant::variant | ( | mutable_variant_object | obj, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 164 of file variant.cpp.
fc::variant::variant | ( | variants | arr, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 170 of file variant.cpp.
fc::variant::variant | ( | const variant & | v, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 200 of file variant.cpp.
fc::variant::variant | ( | variant && | v, |
uint32_t | max_depth = 1 |
||
) |
Definition at line 224 of file variant.cpp.
fc::variant::~variant | ( | ) |
Definition at line 230 of file variant.cpp.
|
inline |
Definition at line 360 of file variant.hpp.
fc::variant::variant | ( | const T & | val, |
uint32_t | max_depth | ||
) |
Definition at line 580 of file variant.hpp.
|
inline |
Definition at line 345 of file variant.hpp.
|
inline |
_types that use non-intrusive variant conversion can implement the following method to implement conversion from variant to T.
void from_variant( const Variant& var, T& val, uint32_t max_depth )
The above form is not always convienant, so the this templated method is used to enable conversion from Variants to other types.
Definition at line 337 of file variant.hpp.
blob fc::variant::as_blob | ( | ) | const |
Definition at line 518 of file variant.cpp.
bool fc::variant::as_bool | ( | ) | const |
Definition at line 441 of file variant.cpp.
double fc::variant::as_double | ( | ) | const |
Definition at line 420 of file variant.cpp.
int64_t fc::variant::as_int64 | ( | ) | const |
Definition at line 377 of file variant.cpp.
string fc::variant::as_string | ( | ) | const |
Convert's double, ints, bools, etc to a string
if | get_type() == array_type | get_type() == object_type |
Definition at line 469 of file variant.cpp.
uint64_t fc::variant::as_uint64 | ( | ) | const |
Definition at line 398 of file variant.cpp.
void fc::variant::clear | ( | ) |
Definition at line 181 of file variant.cpp.
const variants & fc::variant::get_array | ( | ) |
if | get_type() != array_type | null_type |
if | get_type() != array_type |
Definition at line 496 of file variant.cpp.
const variants& fc::variant::get_array | ( | ) | const |
if | get_type() != array_type |
const blob & fc::variant::get_blob | ( | ) |
Definition at line 503 of file variant.cpp.
const blob& fc::variant::get_blob | ( | ) | const |
const variant_object & fc::variant::get_object | ( | ) |
if | get_type() != object_type | null_type |
if | get_type() != object_type |
Definition at line 554 of file variant.cpp.
const variant_object& fc::variant::get_object | ( | ) | const |
if | get_type() != object_type |
const string & fc::variant::get_string | ( | ) | const |
Definition at line 575 of file variant.cpp.
variant::type_id fc::variant::get_type | ( | ) | const |
Definition at line 304 of file variant.cpp.
bool fc::variant::is_array | ( | ) | const |
Definition at line 368 of file variant.cpp.
bool fc::variant::is_blob | ( | ) | const |
Definition at line 372 of file variant.cpp.
bool fc::variant::is_bool | ( | ) | const |
Definition at line 318 of file variant.cpp.
bool fc::variant::is_double | ( | ) | const |
Definition at line 322 of file variant.cpp.
bool fc::variant::is_int64 | ( | ) | const |
Definition at line 330 of file variant.cpp.
bool fc::variant::is_integer | ( | ) | const |
int64, uint64, bool
Definition at line 335 of file variant.cpp.
bool fc::variant::is_null | ( | ) | const |
Definition at line 309 of file variant.cpp.
bool fc::variant::is_numeric | ( | ) | const |
int64, uint64, double,bool
Definition at line 348 of file variant.cpp.
bool fc::variant::is_object | ( | ) | const |
Definition at line 363 of file variant.cpp.
bool fc::variant::is_string | ( | ) | const |
Definition at line 314 of file variant.cpp.
bool fc::variant::is_uint64 | ( | ) | const |
Definition at line 326 of file variant.cpp.
Definition at line 244 of file variant.cpp.
|
inline |
Definition at line 354 of file variant.hpp.
Definition at line 235 of file variant.cpp.
const variant & fc::variant::operator[] | ( | const char * | key | ) | const |
Definition at line 561 of file variant.cpp.
const variant & fc::variant::operator[] | ( | size_t | pos | ) | const |
Definition at line 565 of file variant.cpp.
size_t fc::variant::size | ( | ) | const |
Definition at line 570 of file variant.cpp.
void fc::variant::visit | ( | const visitor & | v | ) | const |
Definition at line 271 of file variant.cpp.