Lagrange
Value Class Reference

Public Types

typedef std::vector< ValueArray
 
typedef std::map< std::string, ValueObject
 
typedef std::vector< unsigned char > Buffer
 
using variant_type = std::variant< bool, int, double, std::string, Buffer, Array, Object >
 

Public Member Functions

 Value (bool b)
 
 Value (int i)
 
 Value (double n)
 
 Value (std::string s)
 
 Value (std::string_view s)
 
 Value (const char *s)
 
 Value (span< unsigned char > s)
 
 Value (const Buffer &v)
 
 Value (Buffer &&v)
 
 Value (const Array &a)
 
 Value (Array &&a)
 
 Value (const Object &o)
 
 Value (Object &&o)
 
template<typename T >
bool is_type () const
 
bool is_bool () const
 
bool is_int () const
 
bool is_real () const
 
bool is_number () const
 
bool is_string () const
 
bool is_buffer () const
 
bool is_array () const
 
bool is_object () const
 
size_t get_type_index () const
 
template<typename T >
const T & get () const
 
template<typename T >
T & get ()
 
bool get_bool () const
 
int get_int () const
 
double get_real () const
 
const std::string & get_string () const
 
std::string get_string ()
 
const Buffer & get_buffer () const
 
Buffer & get_buffer ()
 
const Array & get_array () const
 
Array & get_array ()
 
const Object & get_object () const
 
Object & get_object ()
 
template<typename T >
void set (T t)
 
void set_bool (bool b)
 
void set_int (int i)
 
void set_real (double n)
 
const Valueoperator[] (size_t idx) const
 
Valueoperator[] (size_t idx)
 
bool has (const std::string &key) const
 
const Valueoperator[] (const std::string &key) const
 
Valueoperator[] (const std::string &key)
 
size_t size () const
 

Static Public Member Functions

template<typename T >
static constexpr bool is_variant_type ()
 Checks if the type is in the variant.
 
template<typename T , std::size_t index = 0>
static constexpr std::size_t variant_index ()
 Returns index of the element type in the variant. More...
 
static constexpr size_t bool_index ()
 
static constexpr size_t int_index ()
 
static constexpr size_t real_index ()
 
static constexpr size_t string_index ()
 
static constexpr size_t buffer_index ()
 
static constexpr size_t array_index ()
 
static constexpr size_t object_index ()
 
static Value create_buffer ()
 
static Value create_array ()
 
static Value create_object ()
 

Protected Attributes

variant_type value
 

Member Function Documentation

◆ variant_index()

static constexpr std::size_t variant_index ( )
inlinestaticconstexpr

Returns index of the element type in the variant.

Returns variant size if not found.


The documentation for this class was generated from the following file: