Skip to content

Defined in header <fkYAML/node.hpp>

fkyaml::basic_node::yaml_version_t

enum class yaml_version_t
{
    VER_1_1,
    VER_1_2,
};

Deprecation

The enum class fkyaml::yaml_version_type replaces the type alias fkyaml::basic_node::yaml_version_t which has been deprecated in version 0.3.12. It will be removed in version 0.4.0. Please replace usages like

fkyaml::node::yaml_version_t v;

with

fkyaml::yaml_version_type v;

This enumeration collects the used versions of YAML specification. It is used as meta data of a basic_node and the functions get_yaml_version and set_yaml_version rely on it.

Example
#include <iomanip>
#include <iostream>
#include <fkYAML/node.hpp>

int main() {
    char input[] = "%YAML 1.2\n"
                   "---\n"
                   "foo: bar\n";

    // deserialize a YAML formatted string.
    fkyaml::node n = fkyaml::node::deserialize(input);

    // call get_yaml_version().
    fkyaml::node::yaml_version_t yaml_ver = n.get_yaml_version();
    std::cout << std::boolalpha;
    std::cout << (n.get_yaml_version() == fkyaml::node::yaml_version_t::VER_1_2) << std::endl;

    // overwrite the YAML version to 1.1.
    n.set_yaml_version(fkyaml::node::yaml_version_t::VER_1_1);

    // call get_yaml_version() again.
    std::cout << (n.get_yaml_version() == fkyaml::node::yaml_version_t::VER_1_1) << std::endl;

    return 0;
}

output:

true
true

See Also