Defined in header <fkYAML/node.hpp>
fkyaml::basic_node::get_tag_name¶
Gets the tag name associated to the YAML node.
Some tag name must be set before calling this API.
Calling has_tag_name
to see if the node has any tag name beforehand.
Return Value¶
The tag name associated to the node.
If no tag name has been set, an fkyaml::exception
will be thrown.
Example
#include <iostream>
#include <fkYAML/node.hpp>
int main() {
// create a YAML node.
fkyaml::node n = 123;
// try to get a tag name before any tag name has been set.
try {
std::cout << n.get_tag_name() << std::endl;
}
catch (const fkyaml::exception& e) {
std::cout << e.what() << std::endl;
}
// set a tag name to the node.
n.add_tag_name("!!int");
std::cout << n.get_tag_name() << std::endl;
return 0;
}
output: