mirror of
https://github.com/loot/yaml-cpp.git
synced 2026-07-27 14:13:42 -07:00
Switched YAML::Parse to YAML::Load, and added LoadAll
This commit is contained in:
@@ -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
|
||||||
|
|||||||
+29
-5
@@ -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
|
|||||||
|
|
||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+107
-107
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user