mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-08 12:21:17 +00:00
Updated signature of Parser::GetNextDocument (issue 45)
This commit is contained in:
@@ -25,7 +25,7 @@ namespace YAML
|
||||
operator bool() const;
|
||||
|
||||
void Load(std::istream& in);
|
||||
void GetNextDocument(Node& document);
|
||||
bool GetNextDocument(Node& document);
|
||||
void PrintTokens(std::ostream& out);
|
||||
|
||||
private:
|
||||
|
@@ -33,7 +33,7 @@ namespace YAML
|
||||
// GetNextDocument
|
||||
// . Reads the next document in the queue (of tokens).
|
||||
// . Throws a ParserException on error.
|
||||
void Parser::GetNextDocument(Node& document)
|
||||
bool Parser::GetNextDocument(Node& document)
|
||||
{
|
||||
// clear node
|
||||
document.Clear();
|
||||
@@ -43,7 +43,7 @@ namespace YAML
|
||||
|
||||
// we better have some tokens in the queue
|
||||
if(m_pScanner->empty())
|
||||
return;
|
||||
return false;
|
||||
|
||||
// first eat doc start (optional)
|
||||
if(m_pScanner->peek().type == Token::DOC_START)
|
||||
@@ -58,6 +58,8 @@ namespace YAML
|
||||
|
||||
// clear anchors from the scanner, which are no longer relevant
|
||||
m_pScanner->ClearAnchors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ParseDirectives
|
||||
|
@@ -11,9 +11,8 @@ int main(int argc, char **argv)
|
||||
std::istream& input = (argc > 1 ? fin : std::cin);
|
||||
try {
|
||||
YAML::Parser parser(input);
|
||||
while(parser) {
|
||||
YAML::Node doc;
|
||||
parser.GetNextDocument(doc);
|
||||
YAML::Node doc;
|
||||
while(parser.GetNextDocument(doc)) {
|
||||
YAML::Emitter emitter;
|
||||
emitter << doc;
|
||||
std::cout << emitter.c_str() << "\n";
|
||||
|
Reference in New Issue
Block a user