class
nodethe class that holds a luco node which is either luco::
Constructors, destructors, conversion operators
- node() explicit
- default constructor which creates luco::
node with type luco::node_type::object -
node(enum node_
type type) explicit - constructor to allow setting the type of the luco::
node
Public functions
-
auto as_array() const → std::
shared_ptr<luco:: array> - access the luco::
array the luco:: node is holding, if it exists - auto as_boolean() const → bool
- cast a node into a bool if it is holding luco::
value that is a luco boolean (bool) - auto as_double() const → double
- cast a node into a double if it is holding luco::
value that is a luco number (double) - auto as_integer() const → int64_t
- cast a node into a int64_t if it is holding luco::
value that is a luco number (int64_t) -
auto as_null() const → null_
type - cast a node into a luco::
null_type if it is holding luco:: value that is a luco null (luco:: null_type) - auto as_number() const → double
- cast a node into a double if it is holding luco::
value that is a luco number (int64_t or double) -
auto as_object() const → std::
shared_ptr<luco:: object> - access the luco::
object the luco:: node is holding, if it exists -
auto as_string() const → std::
string - cast a node into a string if it is holding luco::
value that is a luco string (luco:: null_type) -
auto as_value() const → std::
shared_ptr<class value> - access the luco::
value the luco:: node is holding, if it exists -
auto at(const std::
string& object_key) const → class node& - access the node at the specified object key
- auto at(const size_t array_index) const → class node&
- access the node at the specified array index
-
auto contains(const std::
string& key) const → bool noexcept - checks if a key exists in a luco object
-
auto dump_to_file(const std::
filesystem:: path& path, const std:: pair<char, size_t>& indent_conf = {' ', 4}) const → expected<monostate, error> - write luco::
node to a file -
void dump_to_stdout(const std::
pair<char, size_t>& indent_conf = {' ', 4}) const - write luco::
node to stdout -
auto dump_to_string(const std::
pair<char, size_t>& indent_conf = {' ', 4}) const → std:: string - write luco::
node to string - auto is_array() const → bool noexcept
- checks if luco::
node is holding luco:: array - auto is_boolean() const → bool noexcept
- checks if luco::
node is holding luco:: value that is holding luco boolean (bool) - auto is_double() const → bool noexcept
- checks if luco::
node is holding luco:: value that is holding luco number (double) - auto is_integer() const → bool noexcept
- checks if luco::
node is holding luco:: value that is holding luco number (int64_t) - auto is_null() const → bool noexcept
- checks if luco::
node is holding luco:: value that is holding luco null (luco:: null_type) - auto is_number() const → bool noexcept
- checks if luco::
node is holding luco:: value that is holding luco number (double or int64_t) - auto is_object() const → bool noexcept
- checks if luco::
node is holding luco:: object - auto is_string() const → bool noexcept
- checks if luco::
node is holding luco:: value that is holding luco string (std:: string) - auto is_value() const → bool noexcept
- checks if luco::
node is holding luco:: value - auto operator+(const node& other_node) → class node
- add two luco::
node together. they must have the same type and be either object, array, string or number -
template <typename container_or_node_type>auto operator=(const container_or_node_type& node_value) → class node& noexcept
- asign a node with a container_or_node_type
-
template <typename container_or_node_type>void set(const container_or_node_type& node_value) noexcept
- set a node with a container_or_node_type
-
auto stringify() const → std::
string noexcept - stringify the luco (object, array or value) inside the luco::
node -
auto try_as_array() const → expected<std::
shared_ptr<luco:: array>, error> noexcept - access the luco::
array the luco:: node is holding, if it exists - auto try_as_boolean() const → expected<bool, error> noexcept
- cast a node into a bool if it is holding luco::
value that is a luco boolean (bool) - auto try_as_double() const → expected<double, error> noexcept
- cast a node into a double if it is holding luco::
value that is a luco number (double) - auto try_as_integer() const → expected<int64_t, error> noexcept
- cast a node into a int64_t if it is holding luco::
value that is a luco number (int64_t) -
auto try_as_null() const → expected<null_
type, error> noexcept - cast a node into a luco::
null_type if it is holding luco:: value that is a luco null - auto try_as_number() const → expected<double, error> noexcept
- cast a node into a double if it is holding luco::
value that is a luco number (double or int64_t) -
auto try_as_object() const → expected<std::
shared_ptr<luco:: object>, error> noexcept - access the luco::
object the luco:: node is holding, if it exists -
auto try_as_string() const → expected<std::
string, error> noexcept - cast a node into a std::
string if it is holding luco:: value that is a luco string (std:: string) -
auto try_as_value() const → expected<std::
shared_ptr<class value>, error> noexcept - access the luco::
value the luco:: node is holding, if it exists -
auto try_at(const std::
string& object_key) const → expected<std:: reference_wrapper<luco:: node>, luco:: error> noexcept - access the node at the specified object key
-
auto try_at(const size_t array_index) const → expected<std::
reference_wrapper<luco:: node>, luco:: error> noexcept - access the node at the specified array index
-
auto type() const → node_
type noexcept - gets the luco::
node_type of the internal node -
auto type_name() const → std::
string noexcept - gets string representation of luco::
node_type of the internal node -
auto value_type_name() const → std::
string noexcept - gets string representation of luco::value_type of the internal node if it's holding luco::
value - auto valuetype() const → value_type noexcept
- gets the luco::value_type of the node if it's holding luco::
value. otherwise it returns value_type::none
Function documentation
luco:: node:: node(enum node_ type type) explicit
constructor to allow setting the type of the luco::
Parameters | |
---|---|
type | type of node from enum luco:: |
std:: shared_ptr<luco:: array> luco:: node:: as_array() const
access the luco::
Returns | std:: |
---|---|
Exceptions | |
luco:: |
if it doesn't hold luco:: |
bool luco:: node:: as_boolean() const
cast a node into a bool if it is holding luco::
Returns | luco boolean |
---|---|
Exceptions | |
luco:: |
if it doesn't hold a luco:: |
double luco:: node:: as_double() const
cast a node into a double if it is holding luco::
Returns | luco number |
---|---|
Exceptions | |
luco:: |
if it doesn't hold a luco:: |
int64_t luco:: node:: as_integer() const
cast a node into a int64_t if it is holding luco::
Returns | luco number |
---|---|
Exceptions | |
luco:: |
if it doesn't hold a luco:: |
null_ type luco:: node:: as_null() const
cast a node into a luco::
Returns | luco null |
---|---|
Exceptions | |
luco:: |
if it doesn't hold a luco:: |
double luco:: node:: as_number() const
cast a node into a double if it is holding luco::
Returns | luco number |
---|---|
Exceptions | |
luco:: |
if it doesn't hold a luco:: |
std:: shared_ptr<luco:: object> luco:: node:: as_object() const
access the luco::
Returns | std:: |
---|---|
Exceptions | |
luco:: |
if it doesn't hold luco:: |
std:: string luco:: node:: as_string() const
cast a node into a string if it is holding luco::
Returns | luco string |
---|---|
Exceptions | |
luco:: |
if it doesn't hold a luco:: |
std:: shared_ptr<class value> luco:: node:: as_value() const
access the luco::
Returns | std:: |
---|---|
Exceptions | |
luco:: |
if it doesn't hold luco:: |
class node& luco:: node:: at(const std:: string& object_key) const
access the node at the specified object key
Parameters | |
---|---|
object_key | luco key to access in an object |
Returns | luco:: |
bool luco:: node:: contains(const std:: string& key) const noexcept
checks if a key exists in a luco object
Parameters | |
---|---|
key | key to lookup |
Returns | true if it does |
expected<monostate, error> luco:: node:: dump_to_file(const std:: filesystem:: path& path,
const std:: pair<char, size_t>& indent_conf = {' ', 4}) const
write luco::
Parameters | |
---|---|
path | path to write to |
indent_conf | indentation config for writing {char, size} |
void luco:: node:: dump_to_stdout(const std:: pair<char, size_t>& indent_conf = {' ', 4}) const
write luco::
Parameters | |
---|---|
indent_conf | indentation config for writing {char, size} |
std:: string luco:: node:: dump_to_string(const std:: pair<char, size_t>& indent_conf = {' ', 4}) const
write luco::
Parameters | |
---|---|
indent_conf | indentation config for writing {char, size} |
Returns | luco serialized |
bool luco:: node:: is_array() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: node:: is_boolean() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: node:: is_double() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: node:: is_integer() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: node:: is_null() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: node:: is_number() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: node:: is_object() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: node:: is_string() const noexcept
checks if luco::
Returns | true if it does |
---|
bool luco:: node:: is_value() const noexcept
checks if luco::
Returns | true if it does |
---|
luco::node node(luco::node_type::value); if (node.is_value()) { // do something }
class node luco:: node:: operator+(const node& other_node)
add two luco::
Parameters | |
---|---|
other_node | the other node to add to the current node |
Returns | new node containing content of both nodes |
Exceptions | |
luco:: |
if different types or not one of the required types |
luco::node new_node = node1 + node2;
@luco node1_key = "node1_value" @eluco @luco node2_key = "node2_value" @eluco @luco node1_key = "node1_value" node2_key = "node2_value" @eluco
std:: string luco:: node:: stringify() const noexcept
stringify the luco (object, array or value) inside the luco::
Returns | serialized luco |
---|
@luco
key1 = "val1" key2 = "val2"
@eluco
@luco
"val1" "val2" "val3"
@eluco
@luco "value" @eluco
expected<std:: shared_ptr<luco:: array>, error> luco:: node:: try_as_array() const noexcept
access the luco::
Returns | luco:: |
---|
expected<bool, error> luco:: node:: try_as_boolean() const noexcept
cast a node into a bool if it is holding luco::
Returns | bool or luco:: |
---|
expected<double, error> luco:: node:: try_as_double() const noexcept
cast a node into a double if it is holding luco::
Returns | double or luco:: |
---|
expected<int64_t, error> luco:: node:: try_as_integer() const noexcept
cast a node into a int64_t if it is holding luco::
Returns | int64_t or luco:: |
---|
expected<null_ type, error> luco:: node:: try_as_null() const noexcept
cast a node into a luco::
Returns | luco:: |
---|
luco::expected<null_type, error> null = node.try_as_null(); if (not null) { // handle error std::println("{}", null.error().message()); } else { // success luco::null_type null_value = null.value(); }
expected<double, error> luco:: node:: try_as_number() const noexcept
cast a node into a double if it is holding luco::
Returns | double or luco:: |
---|
expected<std:: shared_ptr<luco:: object>, error> luco:: node:: try_as_object() const noexcept
access the luco::
Returns | luco:: |
---|
expected<std:: string, error> luco:: node:: try_as_string() const noexcept
cast a node into a std::
Returns | std:: |
---|
luco::expected<std::string, error> string = node.try_as_string(); if (not string) { // handle error std::println("{}", string.error().message()); } else { // success std::string string_value = string.value(); }
expected<std:: shared_ptr<class value>, error> luco:: node:: try_as_value() const noexcept
access the luco::
Returns | luco:: |
---|
expected<std:: reference_wrapper<luco:: node>, luco:: error> luco:: node:: try_at(const std:: string& object_key) const noexcept
access the node at the specified object key
Parameters | |
---|---|
object_key | luco key to access in an object |
Returns | either std:: |
luco::expected<std::reference_wrapper<luco::node>, luco::error> maybe_node = object_node.try_at("key"); if (maybe_node) { // notice the '&' is neccessary if this reference would be used to modify // the value inside luco::node& node_at_key = maybe_node.value().get(); // .value() to get the expected type, .get() for the node reference // or you can set it like this to avoid forgetting the '&' maybe_node.value().get().set(std::string("new value")); } else { std::println("{}", maybe_node.error().message()); }
expected<std:: reference_wrapper<luco:: node>, luco:: error> luco:: node:: try_at(const size_t array_index) const noexcept
access the node at the specified array index
Parameters | |
---|---|
array_index | luco index to access in an array |
Returns | either std:: |
luco::expected<std::reference_wrapper<luco::node>, luco::error> maybe_node = array_node.try_at(0); if (maybe_node) { // notice the '&' is neccessary if this reference would be used to modify // the value inside luco::node& node_at_key = maybe_node.value().get(); // .value() to get the expected type, .get() for the node reference // or you can set it like this to avoid forgetting the '&' maybe_node.value().get().set(true); } else { std::println("{}", maybe_node.error().message()); }
node_ type luco:: node:: type() const noexcept
gets the luco::
Returns | node_type |
---|
std:: string luco:: node:: type_name() const noexcept
gets string representation of luco::
Returns | string name of the node_type |
---|
std:: string luco:: node:: value_type_name() const noexcept
gets string representation of luco::value_type of the internal node if it's holding luco::
Returns | string name of the value_type |
---|
value_type luco:: node:: valuetype() const noexcept
gets the luco::value_type of the node if it's holding luco::
Returns | value_type |
---|