Commit e3d5ec18 authored by Jesse Beder's avatar Jesse Beder
Browse files

Switched YAML::Parse to YAML::Load, and added LoadAll

parent 5be19ccb
...@@ -5,16 +5,21 @@ ...@@ -5,16 +5,21 @@
#pragma once #pragma once
#endif #endif
#include <string>
#include <iosfwd> #include <iosfwd>
#include <string>
#include <vector>
namespace YAML namespace YAML
{ {
class Node; class Node;
Node Parse(const std::string& input); Node Load(const std::string& input);
Node Parse(const char *input); Node Load(const char *input);
Node Parse(std::istream& input); Node Load(std::istream& input);
std::vector<Node> LoadAll(const std::string& input);
std::vector<Node> LoadAll(const char *input);
std::vector<Node> LoadAll(std::istream& input);
} }
#endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_PARSE_H_62B23520_7C8E_11DE_8A39_0800200C9A66
......
...@@ -8,17 +8,17 @@ ...@@ -8,17 +8,17 @@
namespace YAML namespace YAML
{ {
Node Parse(const std::string& input) { Node Load(const std::string& input) {
std::stringstream stream(input); std::stringstream stream(input);
return Parse(stream); return Load(stream);
} }
Node Parse(const char *input) { Node Load(const char *input) {
std::stringstream stream(input); std::stringstream stream(input);
return Parse(stream); return Load(stream);
} }
Node Parse(std::istream& input) { Node Load(std::istream& input) {
Parser parser(input); Parser parser(input);
NodeBuilder builder; NodeBuilder builder;
if(!parser.HandleNextDocument(builder)) if(!parser.HandleNextDocument(builder))
...@@ -26,4 +26,28 @@ namespace YAML ...@@ -26,4 +26,28 @@ namespace YAML
return builder.Root(); return builder.Root();
} }
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;
}
} }
This diff is collapsed.
...@@ -46,7 +46,7 @@ void parse(std::istream& input) ...@@ -46,7 +46,7 @@ void parse(std::istream& input)
std::cout << emitter.c_str() << "\n"; std::cout << emitter.c_str() << "\n";
} }
#else #else
YAML::Node doc = YAML::Parse(input); YAML::Node doc = YAML::Load(input);
std::cout << doc << "\n"; std::cout << doc << "\n";
#endif #endif
} catch(const YAML::Exception& e) { } catch(const YAML::Exception& e) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment