Parse an array with two longs

This commit is contained in:
Benoit Blanchon
2014-10-14 21:48:22 +02:00
parent ee205971e9
commit beb49a9446
4 changed files with 42 additions and 9 deletions

View File

@ -42,6 +42,11 @@ bool JsonParser::isSpace()
return *_ptr == ' ' || *_ptr == '\t' || *_ptr == '\n' || *_ptr == '\r';
}
bool JsonParser::isComma()
{
return *_ptr == ',';
}
void JsonParser::skipOneChar()
{
_ptr++;
@ -52,7 +57,7 @@ void JsonParser::skipSpaces()
while(isSpace()) skipOneChar();
}
JsonNode* JsonParser::parseNode()
JsonNode* JsonParser::parseAnything()
{
skipSpaces();
@ -67,19 +72,32 @@ JsonNode* JsonParser::parseNode()
JsonNode* JsonParser::parseArray()
{
skipOneChar(); // skip the '['
skipSpaces();
JsonNode* node = _buffer->createNode();
node->setAsArray(_buffer);
skipOneChar(); // skip the '['
skipSpaces();
if (isEnd())
return 0;
if (isArrayStop())
return node;
node->addChild(parseNode());
for(;;)
{
node->addChild(parseAnything());
skipSpaces();
if (isArrayStop())
return node;
if (!isComma())
return 0;
skipOneChar(); // skip the ','
}
return node;
}