Wire Sysio Wire Sysion 1.0.0
|
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. | |
variant (nullptr_t) | |
Constructs a null_type variant. | |
variant (const char *str) | |
variant (char *str) | |
variant (wchar_t *str) | |
variant (const wchar_t *str) | |
variant (float val) | |
variant (uint8_t val) | |
variant (int8_t val) | |
variant (uint16_t val) | |
variant (int16_t val) | |
variant (uint32_t val) | |
variant (int32_t val) | |
variant (uint64_t val) | |
variant (int64_t val) | |
variant (double val) | |
variant (bool val) | |
variant (blob val) | |
variant (fc::string val) | |
variant (variant_object) | |
variant (mutable_variant_object) | |
variant (variants) | |
variant (const variant &) | |
variant (variant &&) | |
~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 |
string | as_string () const |
const 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 |
size_t | estimated_size () const |
template<typename T > | |
T | as () const |
template<typename T > | |
void | as (T &v) const |
variant & | operator= (variant &&v) |
variant & | operator= (const variant &v) |
template<typename T > | |
variant & | operator= (T &&v) |
template<typename T > | |
variant (const std::optional< T > &v) | |
template<typename T > | |
variant (const T &val) | |
template<typename T > | |
variant (const T &val, const fc::yield_function_t &yield) | |
void | clear () |
variant's allocate everything but strings, arrays, and objects on the stack and are 'move aware' for values allcoated on the heap.
Memory usage on 64 bit systems is 16 bytes and 12 bytes on 32 bit systems.
Definition at line 190 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 193 of file variant.hpp.
fc::variant::variant | ( | ) |
Definition at line 24 of file variant.cpp.
fc::variant::variant | ( | fc::nullptr_t | ) |
fc::variant::variant | ( | const char * | str | ) |
str | - UTF8 string |
Definition at line 106 of file variant.cpp.
fc::variant::variant | ( | char * | str | ) |
Definition at line 100 of file variant.cpp.
fc::variant::variant | ( | wchar_t * | str | ) |
fc::variant::variant | ( | const wchar_t * | str | ) |
fc::variant::variant | ( | float | val | ) |
fc::variant::variant | ( | uint8_t | val | ) |
fc::variant::variant | ( | int8_t | val | ) |
fc::variant::variant | ( | uint16_t | val | ) |
fc::variant::variant | ( | int16_t | val | ) |
fc::variant::variant | ( | uint32_t | val | ) |
fc::variant::variant | ( | int32_t | val | ) |
fc::variant::variant | ( | uint64_t | val | ) |
fc::variant::variant | ( | int64_t | val | ) |
fc::variant::variant | ( | double | val | ) |
fc::variant::variant | ( | bool | val | ) |
fc::variant::variant | ( | blob | val | ) |
Definition at line 139 of file variant.cpp.
fc::variant::variant | ( | fc::string | val | ) |
Definition at line 134 of file variant.cpp.
fc::variant::variant | ( | variant_object | obj | ) |
Definition at line 145 of file variant.cpp.
fc::variant::variant | ( | mutable_variant_object | obj | ) |
Definition at line 150 of file variant.cpp.
fc::variant::variant | ( | variants | arr | ) |
fc::variant::variant | ( | const variant & | v | ) |
Definition at line 190 of file variant.cpp.
fc::variant::variant | ( | variant && | v | ) |
fc::variant::~variant | ( | ) |
Definition at line 350 of file variant.hpp.
Definition at line 616 of file variant.hpp.
|
explicit |
_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 )
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 327 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 168 of file variant.cpp.
size_t fc::variant::estimated_size | ( | ) | const |
Definition at line 575 of file variant.cpp.
variants & fc::variant::get_array | ( | ) |
if | get_type() != array_type | null_type |
Definition at line 496 of file variant.cpp.
const variants & fc::variant::get_array | ( | ) | const |
if | get_type() != array_type |
Definition at line 545 of file variant.cpp.
blob & fc::variant::get_blob | ( | ) |
Definition at line 503 of file variant.cpp.
const blob & fc::variant::get_blob | ( | ) | const |
Definition at line 510 of file variant.cpp.
variant_object & fc::variant::get_object | ( | ) |
if | get_type() != object_type | null_type |
Definition at line 554 of file variant.cpp.
const variant_object & fc::variant::get_object | ( | ) | const |
if | get_type() != object_type |
Definition at line 614 of file variant.cpp.
const string & fc::variant::get_string | ( | ) | const |
Definition at line 606 of file variant.cpp.
variant::type_id fc::variant::get_type | ( | ) | const |
bool fc::variant::is_array | ( | ) | const |
Definition at line 368 of file variant.cpp.
bool fc::variant::is_blob | ( | ) | const |
bool fc::variant::is_bool | ( | ) | const |
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 239 of file variant.cpp.
Definition at line 230 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 268 of file variant.cpp.