Defined in header <fkYAML/node.hpp>
fkyaml::basic_node::node_t¶
Deprecation
The enum class fkyaml::node_type
replaces the type alias fkyaml::basic_node::node_t
which has been deprecated in version 0.3.12. It will be removed in version 0.4.0. Please replace usages like
with
This enumeration collects the different YAML value types. They are internally used to distinguish the stored values, and the functions is_sequence
, is_mapping
and is_scalar
(with is_null
, is_boolean
, is_integer
, is_float_number
, is_string
) rely on it.
Types of scalars
There are five enumerators for scalars (NULL_OBJECT
, BOOLEAN
, INTEGER
, FLOAT_NUMBER
, STRING
) to distinguish between different types of scalars:
boolean_type
for boolean scalar valuesinteger_type
for integer scalar valuesfloat_number_type
for float number scalar valuesstring_type
for string scalar values
Example
#include <iomanip>
#include <iostream>
#include <fkYAML/node.hpp>
int main() {
// create YAML nodes.
fkyaml::node sequence_node = {1, 2, 3};
fkyaml::node mapping_node = {{"foo", true}, {"bar", false}};
fkyaml::node null_node;
fkyaml::node boolean_node = true;
fkyaml::node integer_node = 256;
fkyaml::node float_node = 3.14;
fkyaml::node string_node = "Hello, world!";
// call type()
std::cout << std::boolalpha;
std::cout << (sequence_node.type() == fkyaml::node::node_t::SEQUENCE) << std::endl;
std::cout << (mapping_node.type() == fkyaml::node::node_t::MAPPING) << std::endl;
std::cout << (null_node.type() == fkyaml::node::node_t::NULL_OBJECT) << std::endl;
std::cout << (boolean_node.type() == fkyaml::node::node_t::BOOLEAN) << std::endl;
std::cout << (integer_node.type() == fkyaml::node::node_t::INTEGER) << std::endl;
std::cout << (float_node.type() == fkyaml::node::node_t::FLOAT_NUMBER) << std::endl;
std::cout << (string_node.type() == fkyaml::node::node_t::STRING) << std::endl;
return 0;
}
output: