Skip to content

Commit

Permalink
Updated signature of Parser::GetNextDocument (issue 45)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeder committed Sep 29, 2009
1 parent 94eb7f1 commit 7db39e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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)
Expand All @@ -58,6 +58,8 @@ namespace YAML

// clear anchors from the scanner, which are no longer relevant
m_pScanner->ClearAnchors();

return true;
}

// ParseDirectives
Expand Down
5 changes: 2 additions & 3 deletions util/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 7db39e6

Please sign in to comment.