Pergunta

I am using Yaml-Cpp to generate the input string to begin with. It seems I am somehow generating an incorrect serialization of the vector, though, because when I try to access that member from a loaded Yaml Node, I get "TypedBadConversion".

Entirely besides helping understand how to generate the Yaml to begin with (which I am interested in as well!) does anyone see why the string in question is invalid? Here is a test program and its output:

Test Program

#include <yaml-cpp/yaml.h>
using namespace YAML;
using namespace std;
int main( int argc, char* argv[] )
{
std::string         Command( "- ./rsc/cudaExample0.sh\n- 10.62.4.214/16\n- 2.0.19.136\n- 5000\n- 5000\n- 0\n-\n  - b\n  - i\n  - n\n  - \" \"\n  - \"-\"\n  - t\n  - \" \"\n- 72" );
YAML::Node          Test = Load( Command );
std::vector<char>   Payload;
    Payload = Test[6].as<std::vector<char> >();
    std::cout << Payload[1] << std::endl;
return 0;
}

Output

Starting /noname/src/testyaml/TestYaml...
terminate called after throwing an instance of 'YAML::TypedBadConversion<char>'
  what():  yaml-cpp: error at line 0, column 0: bad conversion
The program has unexpectedly finished.
/noname/src/testyaml/TestYaml exited with code 0
Foi útil?

Solução

This is a bug in yaml-cpp; I opened a issue on the project page, and it is fixed at the repository's tip.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top