Value

struct Value

Represents a value that can be one of the following five types:

  • integer (int64_t).

  • floating-point value (double).

  • boolean (bool).

  • string (std::string).

  • empty

It is possible to convert a C++ value to a Value instance and back to a C++ value.

Value also overloads several operators such as addition and multiplication.

Public Functions

inline bool is_empty() const

Returns true if this Value is empty.

inline bool is_integer() const

Returns true if this Value is an integer.

inline bool is_string() const

Returns true if this Value is a string.

inline bool is_bool() const

Returns true if this Value is a boolean.

inline bool is_double() const

Returns true if this Value is a floating-point number.

integer_type to_integer() const

Convert this value to an integer. The data type of this value should be integer, double, or boolean.

std::string to_string() const

Convert this value to a string.

bool to_bool() const

Convert this value to a bool.

double to_double() const

Convert this value to a double.

float to_float() const

Convert this value to a float.

TemplateArg to_template_arg() const

Convert this value to a TemplateArg.

template<typename T>
inline bool is() const

Returns true if this value is convertible to an instance of T.

template<typename T>
inline T to() const

Convert this Value to an instance of type T if this is possible.