Pregunta

I use current(2013/12/12) latest revision of yaml-cpp.

I noticed that both YAML::Load("") and YAML::Load("---\n...") results in a Null node, i.e. YAML::Load("").Type() == YAML::NodeType::Null yet when sent to std::ostream the former outputs an empty string but the latter outputs tilde (~).

I want both nodes to output an empty string. How can I achieve it?

I want to do so because I noticed tilde is interpreted as a string when I use YAML::Load.

Here is the code to show this difference.

#include <yaml-cpp/yaml.h>
#include <iostream>
#include <cassert>

int main() {
    YAML::Node node1 = YAML::Load("");
    YAML::Node node2 = YAML::Load("---\n...");

    assert (node1.Type() == YAML::NodeType::Null);
    assert (node2.Type() == YAML::NodeType::Null);

    std::cout << node1 << std::endl;
    std::cout << node2 << std::endl;
}

/* OUTPUT:

~
*/
¿Fue útil?

Solución

According to the Github Issue, this behavior was fixed in 2016.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top