Defined in header <fkYAML/node.hpp>
fkyaml::basic_node::get_type¶
Returns the type of the YAML node value as a value from the node_type
enumeration.
Return Value¶
The type of the YAML node value.
Value Type | Return Value |
---|---|
sequence | node_type::SEQUENCE |
mapping | node_type::MAPPING |
null | node_type::NULL_OBJECT |
boolean | node_type::BOOLEAN |
integer | node_type::INTEGER |
floating point number | node_type::FLOAT |
string | node_type::STRING |
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!";
// query node value types by calling get_type().
std::cout << std::boolalpha;
std::cout << (sequence_node.get_type() == fkyaml::node_type::SEQUENCE) << std::endl;
std::cout << (mapping_node.get_type() == fkyaml::node_type::MAPPING) << std::endl;
std::cout << (null_node.get_type() == fkyaml::node_type::NULL_OBJECT) << std::endl;
std::cout << (boolean_node.get_type() == fkyaml::node_type::BOOLEAN) << std::endl;
std::cout << (integer_node.get_type() == fkyaml::node_type::INTEGER) << std::endl;
std::cout << (float_node.get_type() == fkyaml::node_type::FLOAT) << std::endl;
std::cout << (string_node.get_type() == fkyaml::node_type::STRING) << std::endl;
return 0;
}
output: