parse.cpp 575 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "yaml-cpp/value/parse.h"
#include "yaml-cpp/value/value.h"
#include "yaml-cpp/value/impl.h"
#include "yaml-cpp/parser.h"
#include "valuebuilder.h"

#include <sstream>

namespace YAML
{
	Value Parse(const std::string& input) {
		std::stringstream stream(input);
		return Parse(stream);
	}
	
	Value Parse(const char *input) {
		std::stringstream stream(input);
		return Parse(stream);
	}
	
	Value Parse(std::istream& input) {
		Parser parser(input);
		ValueBuilder builder;
		if(!parser.HandleNextDocument(builder))
			return Value();
		
		return builder.Root();
	}
}