Skip to content

Defined in header <fkYAML/node_type.hpp>

fkyaml::node_type

enum class node_type : std::uint32_t
{
    SEQUENCE,
    MAPPING,
    NULL_OBJECT,
    BOOLEAN,
    INTEGER,
    FLOAT,
    STRING,
};

This enumeration collects the different YAML value types. They are internally used to distinguish the stored values, and the following basic_node's functions rely on it:

Types of scalars

There are five enumerators for scalars (NULL_OBJECT, BOOLEAN, INTEGER, FLOAT, STRING) to distinguish between different types of scalars:

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:

true
true
true
true
true
true
true

See Also