mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-08 12:21:17 +00:00
Fixed bug where the parser doesn't find the end of a map or seq flow
This commit is contained in:
@@ -1,12 +1,32 @@
|
||||
#include "yaml-cpp/yaml.h"
|
||||
#include "yaml-cpp/eventhandler.h"
|
||||
#include <iostream>
|
||||
|
||||
class NullEventHandler: public YAML::EventHandler
|
||||
{
|
||||
public:
|
||||
typedef YAML::Mark Mark;
|
||||
typedef YAML::anchor_t anchor_t;
|
||||
|
||||
NullEventHandler() {}
|
||||
|
||||
virtual void OnDocumentStart(const Mark&) {}
|
||||
virtual void OnDocumentEnd() {}
|
||||
virtual void OnNull(const Mark&, anchor_t) {}
|
||||
virtual void OnAlias(const Mark&, anchor_t) {}
|
||||
virtual void OnScalar(const Mark&, const std::string&, anchor_t, const std::string&) {}
|
||||
virtual void OnSequenceStart(const Mark&, const std::string&, anchor_t) {}
|
||||
virtual void OnSequenceEnd() {}
|
||||
virtual void OnMapStart(const Mark&, const std::string&, anchor_t) {}
|
||||
virtual void OnMapEnd() {}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
YAML::Emitter out(std::cout);
|
||||
out << YAML::BeginSeq;
|
||||
out << "item 1";
|
||||
out << YAML::BeginSeq << "foo 1" << "bar 2" << YAML::EndSeq;
|
||||
out << YAML::EndSeq;
|
||||
std::stringstream stream("---{header: {id: 1");
|
||||
YAML::Parser parser(stream);
|
||||
// parser.PrintTokens(std::cout);
|
||||
NullEventHandler handler;
|
||||
parser.HandleNextDocument(handler);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user