From 7db39e66b803f5ac2130b314a56362c9f638af71 Mon Sep 17 00:00:00 2001 From: Jesse Beder Date: Tue, 29 Sep 2009 18:25:11 +0000 Subject: [PATCH] Updated signature of Parser::GetNextDocument (issue 45) --- include/parser.h | 2 +- src/parser.cpp | 6 ++++-- util/parse.cpp | 5 ++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/parser.h b/include/parser.h index 0ccea84..f3a487c 100644 --- a/include/parser.h +++ b/include/parser.h @@ -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: diff --git a/src/parser.cpp b/src/parser.cpp index 162364f..9cbfe32 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -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 diff --git a/util/parse.cpp b/util/parse.cpp index 56b1dc1..8a92576 100644 --- a/util/parse.cpp +++ b/util/parse.cpp @@ -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";