2011-09-11 02:57:23 +04:00
|
|
|
#include "yaml-cpp/node/parse.h"
|
|
|
|
|
#include "yaml-cpp/node/node.h"
|
|
|
|
|
#include "yaml-cpp/node/impl.h"
|
2011-09-10 08:40:19 +04:00
|
|
|
#include "yaml-cpp/parser.h"
|
2011-09-11 02:57:23 +04:00
|
|
|
#include "nodebuilder.h"
|
2011-09-10 08:40:19 +04:00
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
namespace YAML
|
|
|
|
|
{
|
2011-09-11 02:57:23 +04:00
|
|
|
Node Parse(const std::string& input) {
|
2011-09-10 08:40:19 +04:00
|
|
|
std::stringstream stream(input);
|
|
|
|
|
return Parse(stream);
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-11 02:57:23 +04:00
|
|
|
Node Parse(const char *input) {
|
2011-09-10 08:40:19 +04:00
|
|
|
std::stringstream stream(input);
|
|
|
|
|
return Parse(stream);
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-11 02:57:23 +04:00
|
|
|
Node Parse(std::istream& input) {
|
2011-09-10 08:40:19 +04:00
|
|
|
Parser parser(input);
|
2011-09-11 02:57:23 +04:00
|
|
|
NodeBuilder builder;
|
2011-09-10 08:40:19 +04:00
|
|
|
if(!parser.HandleNextDocument(builder))
|
2011-09-11 02:57:23 +04:00
|
|
|
return Node();
|
2011-09-10 08:40:19 +04:00
|
|
|
|
|
|
|
|
return builder.Root();
|
|
|
|
|
}
|
|
|
|
|
}
|