"benchmark/git@developer.sourcefind.cn:change/sglang.git" did not exist on "fe0673f1cc8e516dfceef756fb13b3f47a918757"
parse.cpp 1.03 KB
Newer Older
1
2
3
#include "yaml-cpp/node/parse.h"
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/impl.h"
4
#include "yaml-cpp/parser.h"
5
#include "nodebuilder.h"
6
7
8
9
10

#include <sstream>

namespace YAML
{
11
	Node Load(const std::string& input) {
12
		std::stringstream stream(input);
13
		return Load(stream);
14
15
	}
	
16
	Node Load(const char *input) {
17
		std::stringstream stream(input);
18
		return Load(stream);
19
20
	}
	
21
	Node Load(std::istream& input) {
22
		Parser parser(input);
23
		NodeBuilder builder;
24
		if(!parser.HandleNextDocument(builder))
25
			return Node();
26
27
28
		
		return builder.Root();
	}
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

	std::vector<Node> LoadAll(const std::string& input) {
		std::stringstream stream(input);
		return LoadAll(stream);
	}
	
	std::vector<Node> LoadAll(const char *input) {
		std::stringstream stream(input);
		return LoadAll(stream);
	}
	
	std::vector<Node> LoadAll(std::istream& input) {
		std::vector<Node> docs;
		
		Parser parser(input);
		while(1) {
			NodeBuilder builder;
			if(!parser.HandleNextDocument(builder))
				break;
			docs.push_back(builder.Root());
		}
		
		return docs;
	}
53
}