class
valueholds a luco value such as <std::
Constructors, destructors, conversion operators
-
template <is_allowed_value_type val_type>value(const val_type& val) noexcept
- constructor for luco::
value - value(const value& other)
- copy constructor for luco::
value - value(const value&& other)
- move constructor for luco::
value - value() noexcept
- constructor which sets an empty luco::
value
Public functions
- auto as_boolean() → bool
- cast luco::
value into a boolean if it is holding a luco boolean (bool) - auto as_double() → double
- cast luco::
value into a number if it is holding a luco number (double) - auto as_integer() → int64_t
- cast luco::
value into a number if it is holding a luco number (int64_t) -
auto as_null() → null_
type - cast luco::
value into a null if it is holding a luco null (luco:: null_type) - auto as_number() → double
- cast luco::
value into a number if it is holding a luco number (double or int64_t) -
auto as_string() → std::
string - cast luco::
value into a string if it is holding a luco string (std:: string) - auto is_boolean() const → bool noexcept
- checks if luco::
value is holding luco boolean (bool) - auto is_double() const → bool noexcept
- checks if luco::
value is holding luco number (double) - auto is_empty() const → bool noexcept
- checks if luco::
value is not holding luco value (luco:: monostate) - auto is_integer() const → bool noexcept
- checks if luco::
value is holding luco number (int64_t) - auto is_null() const → bool noexcept
- checks if luco::
value is holding luco null (luco:: null_type) - auto is_number() const → bool noexcept
- checks if luco::
value is holding luco number (double or int64_t) - auto is_string() const → bool noexcept
- checks if luco::
value is holding luco string (std:: string) - auto operator=(const value& other) → value&
- copy assignment for luco::
value - auto operator=(const value&& other) → value&
- move assignment for luco::
value -
template <is_allowed_value_type val_type>void set_value_type(const val_type& val) noexcept
- sets the value and type of luco::
value -
auto set_value_type(const std::
string& val, value_type type) → expected<monostate, error> - sets the value and type of luco::
value -
auto stringify() const → std::
string noexcept - cast the luco value into a std::
string - auto try_as_boolean() → expected<bool, error> noexcept
- cast luco::
value into a bool if it is holding a luco boolean (bool) - auto try_as_double() → expected<double, error> noexcept
- cast luco::
value into a double if it is holding a luco number (double) - auto try_as_integer() → expected<int64_t, error> noexcept
- cast luco::
value into a int64_t if it is holding a luco number (int64_t) -
auto try_as_null() → expected<null_
type, error> noexcept - cast luco::
value into a luco:: null_type if it is holding a luco null (luco:: null_type) - auto try_as_number() → expected<double, error> noexcept
- cast luco::
value into a double if it is holding a luco number (double or int64_t) -
auto try_as_string() → expected<std::
string, error> noexcept - cast luco::
value into a std:: string if it is holding a luco string (std:: string) - auto type() const → luco::value_type noexcept
- gets the type of the stored luco value
-
auto type_name() const → std::
string noexcept - gets string representation of luco::value_type of the internal value
Function documentation
template <is_allowed_value_type val_type>
luco:: value:: value(const val_type& val) noexcept
constructor for luco::
Parameters | |
---|---|
val | luco value to be set |
luco:: value:: value(const value& other)
copy constructor for luco::
Parameters | |
---|---|
other | luco:: |
luco:: value:: value(const value&& other)
move constructor for luco::
Parameters | |
---|---|
other | luco:: |
bool luco:: value:: as_boolean()
cast luco::
Returns | luco boolean |
---|---|
Exceptions | |
luco:: |
if it doesn't hold luco boolean |
double luco:: value:: as_double()
cast luco::
Returns | luco number |
---|---|
Exceptions | |
luco:: |
if it doesn't hold luco number |
int64_t luco:: value:: as_integer()
cast luco::
Returns | luco number |
---|---|
Exceptions | |
luco:: |
if it doesn't hold luco number |
null_ type luco:: value:: as_null()
cast luco::
Returns | luco null |
---|---|
Exceptions | |
luco:: |
if it doesn't hold luco null |
double luco:: value:: as_number()
cast luco::
Returns | luco number |
---|---|
Exceptions | |
luco:: |
if it doesn't hold luco number |
std:: string luco:: value:: as_string()
cast luco::
Returns | luco string |
---|---|
Exceptions | |
luco:: |
if it doesn't luco string |
bool luco:: value:: is_boolean() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: value:: is_double() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: value:: is_empty() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: value:: is_integer() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: value:: is_null() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: value:: is_number() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: value:: is_string() const noexcept
checks if luco::
Returns | true if it does |
---|
value& luco:: value:: operator=(const value& other)
copy assignment for luco::
Parameters | |
---|---|
other | luco:: |
Returns | the address of the modified luco:: |
value& luco:: value:: operator=(const value&& other)
move assignment for luco::
Parameters | |
---|---|
other | luco:: |
Returns | the address of the modified luco:: |
template <is_allowed_value_type val_type>
void luco:: value:: set_value_type(const val_type& val) noexcept
sets the value and type of luco::
Parameters | |
---|---|
val | luco value to be set |
expected<monostate, error> luco:: value:: set_value_type(const std:: string& val,
value_type type)
sets the value and type of luco::
Parameters | |
---|---|
val | luco value to be set |
type | luco type (luco::value_type) to be set |
Returns | luco:: |
std:: string luco:: value:: stringify() const noexcept
cast the luco value into a std::
Returns | string representation of the value |
---|
expected<bool, error> luco:: value:: try_as_boolean() noexcept
cast luco::
Returns | bool or luco:: |
---|
expected<double, error> luco:: value:: try_as_double() noexcept
cast luco::
Returns | double or luco:: |
---|
expected<int64_t, error> luco:: value:: try_as_integer() noexcept
cast luco::
Returns | int64_t or luco:: |
---|
expected<null_ type, error> luco:: value:: try_as_null() noexcept
cast luco::
Returns | luco:: |
---|
expected<double, error> luco:: value:: try_as_number() noexcept
cast luco::
Returns | double or luco:: |
---|
expected<std:: string, error> luco:: value:: try_as_string() noexcept
cast luco::
Returns | std:: |
---|
luco::expected<std::string, error> string = value.try_as_string(); if (not string) { // handle error std::println("{}", string.error().message()); } else { // success std::string string_value = string.value(); }
std:: string luco:: value:: type_name() const noexcept
gets string representation of luco::value_type of the internal value
Returns | string name of the value_type |
---|