Extracted function for skipping entire sections.

This commit is contained in:
2016-06-08 00:13:53 +02:00
parent abfa3b3ca1
commit 9360f4295a
3 changed files with 65 additions and 66 deletions

46
include/plasp/pddl/IO.h Normal file
View File

@@ -0,0 +1,46 @@
#ifndef __PLASP__PDDL__IO_H
#define __PLASP__PDDL__IO_H
#include <iostream>
#include <plasp/utils/Parser.h>
namespace plasp
{
namespace pddl
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// IO
//
////////////////////////////////////////////////////////////////////////////////////////////////////
const auto skipSection =
[](utils::Parser &parser)
{
size_t openParentheses = 1;
while (true)
{
const auto character = parser.currentCharacter();
parser.advance();
if (character == '(')
openParentheses++;
else if (character == ')')
{
openParentheses--;
if (openParentheses == 0)
return;
}
}
};
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif