purely cosmetics

This commit is contained in:
aleks-f 2013-01-04 21:51:26 -06:00
parent 80cf789dcd
commit 8a44e75187

View File

@ -66,12 +66,12 @@ public:
bool start(char c, std::istream& istr)
{
if ( c == '{'
|| c == '}'
|| c == ']'
|| c == '['
|| c == ','
|| c == ':' )
if (c == '{'
|| c == '}'
|| c == ']'
|| c == '['
|| c == ','
|| c == ':')
{
_value = c;
return true;
@ -109,7 +109,7 @@ public:
bool start(char c, std::istream& istr)
{
if ( c == '"')
if (c == '"')
{
_value = ""; // We don't need the quote!
return true;
@ -122,7 +122,7 @@ public:
int c = 0;
while ((c = istr.get()) != -1)
{
if ( c == 0 )
if (c == 0)
{
throw JSONException("Null byte not allowed");
}
@ -132,7 +132,7 @@ public:
throw JSONException(format("Control character 0x%x not allowed", (unsigned int) c));
}
if ( c == '"' )
if (c == '"')
break;
if(0x80 <= c && c <= 0xFF)
@ -160,35 +160,19 @@ public:
continue;
}
if ( c == '\\' ) // Escaped String
if (c == '\\') // Escaped String
{
c = istr.get();
switch(c)
{
case '"' :
c = '"';
break;
case '\\' :
c = '\\';
break;
case '/' :
c = '/';
break;
case 'b' :
c = '\b';
break;
case 'f' :
c = '\f';
break;
case 'n' :
c = '\n';
break;
case 'r' :
c = '\r';
break;
case 't' :
c = '\t';
break;
case '"' : c = '"'; break;
case '\\' : c = '\\'; break;
case '/' : c = '/'; break;
case 'b' : c = '\b'; break;
case 'f' : c = '\f'; break;
case 'n' : c = '\n'; break;
case 'r' : c = '\r'; break;
case 't' : c = '\t'; break;
case 'u' : // Unicode
{
Poco::Int32 unicode = decodeUnicode(istr);
@ -383,7 +367,7 @@ public:
if ( c == -1 )
return false;
if ( Ascii::isDigit(c) )
if (Ascii::isDigit(c))
{
if ( c == '0' )
{
@ -397,14 +381,14 @@ public:
return true;
}
if ( c == '-' )
if (c == '-')
{
_value = c;
int nc = istr.peek();
if ( Ascii::isDigit(nc) )
if (Ascii::isDigit(nc))
{
if ( nc == '0' )
if (nc == '0')
{
_value += '0';
istr.get();
@ -427,7 +411,7 @@ public:
int c;
while( (c = istr.peek()) != -1)
{
if ( Ascii::isDigit(c) )
if (Ascii::isDigit(c))
{
_value += c;
istr.get();
@ -438,7 +422,7 @@ public:
{
case '.': // Float
{
if ( _activeClass == Token::FLOAT_LITERAL_TOKEN )
if (_activeClass == Token::FLOAT_LITERAL_TOKEN)
{
throw JSONException("Invalid float value");
}
@ -459,7 +443,7 @@ public:
case 'E':
case 'e':
{
if ( _activeClass == Token::DOUBLE_LITERAL_TOKEN )
if (_activeClass == Token::DOUBLE_LITERAL_TOKEN)
{
throw JSONException("Invalid double value");
}
@ -471,14 +455,14 @@ public:
// When the next char is - or + then read the next char
c = istr.peek();
if ( c == '-' || c == '+' )
if (c == '-' || c == '+')
{
_value += c;
istr.get();
c = istr.peek();
}
if ( ! Ascii::isDigit(c) )
if (! Ascii::isDigit(c))
{
throw JSONException("Invalid double value");
}
@ -520,7 +504,7 @@ Parser::~Parser()
const Token* Parser::nextToken()
{
const Token* token = _tokenizer.next();
if ( token->is(Token::EOF_TOKEN) )
if (token->is(Token::EOF_TOKEN))
{
throw JSONException("Unexpected EOF found");
}
@ -533,14 +517,14 @@ void Parser::parse(std::istream& in)
_tokenizer.attachToStream(in);
const Token* token = nextToken();
if ( token->is(Token::SEPARATOR_TOKEN) )
if (token->is(Token::SEPARATOR_TOKEN))
{
// This must be a { or a [
if ( token->asChar() == '{' )
if (token->asChar() == '{')
{
readObject();
}
else if ( token->asChar() == '[' )
else if (token->asChar() == '[')
{
readArray();
}
@ -549,7 +533,7 @@ void Parser::parse(std::istream& in)
throw JSONException(format("Invalid separator '%c' found. Expecting { or [", token->asChar()));
}
token = _tokenizer.next();
if ( ! token->is(Token::EOF_TOKEN) )
if (! token->is(Token::EOF_TOKEN))
{
throw JSONException(format("EOF expected but found '%s'", token->asString()));
}
@ -563,7 +547,7 @@ void Parser::parse(std::istream& in)
void Parser::readObject()
{
if ( _handler != NULL )
if (_handler != NULL)
{
_handler->startObject();
}
@ -573,7 +557,7 @@ void Parser::readObject()
while(readRow());
}
if ( _handler != NULL )
if (_handler != NULL)
{
_handler->endObject();
}
@ -584,12 +568,12 @@ bool Parser::readRow(bool firstCall)
{
const Token* token = nextToken();
if ( firstCall && token->tokenClass() == Token::SEPARATOR_TOKEN && token->asChar() == '}' )
if (firstCall && token->tokenClass() == Token::SEPARATOR_TOKEN && token->asChar() == '}')
{
return false; // End of object is possible for an empty object
}
if ( token->tokenClass() == Token::STRING_LITERAL_TOKEN )
if (token->tokenClass() == Token::STRING_LITERAL_TOKEN)
{
std::string propertyName = token->tokenString();
if ( _handler != NULL )
@ -599,20 +583,20 @@ bool Parser::readRow(bool firstCall)
token = nextToken();
if ( token->is(Token::SEPARATOR_TOKEN)
&& token->asChar() == ':' )
if ( token->is(Token::SEPARATOR_TOKEN)
&& token->asChar() == ':')
{
readValue(nextToken());
token = nextToken();
if ( token->is(Token::SEPARATOR_TOKEN) )
if (token->is(Token::SEPARATOR_TOKEN))
{
if ( token->asChar() == ',' )
if (token->asChar() == ',')
{
return true; // Read next row
}
else if ( token->asChar() == '}' )
else if (token->asChar() == '}')
{
return false; // End of object
}
@ -649,13 +633,13 @@ void Parser::readValue(const Token* token)
break;
case Token::INTEGER_LITERAL_TOKEN:
if ( _handler != NULL )
if (_handler != NULL)
{
#if defined(POCO_HAVE_INT64)
Int64 value = token->asInteger64();
// if number is 32-bit, then handle as such
if ( value > std::numeric_limits<int>::max()
|| value < std::numeric_limits<int>::min() )
if ( value > std::numeric_limits<int>::max()
|| value < std::numeric_limits<int>::min())
{
_handler->value(value);
}
@ -671,23 +655,23 @@ void Parser::readValue(const Token* token)
break;
case Token::KEYWORD_TOKEN:
{
if ( token->tokenString().compare("null") == 0 )
if (token->tokenString().compare("null") == 0)
{
if ( _handler != NULL )
if (_handler != NULL)
{
_handler->null();
}
}
else if ( token->tokenString().compare("true") == 0 )
else if (token->tokenString().compare("true") == 0)
{
if ( _handler != NULL )
if (_handler != NULL)
{
_handler->value(true);
}
}
else if ( token->tokenString().compare("false") == 0 )
else if (token->tokenString().compare("false") == 0)
{
if ( _handler != NULL )
if (_handler != NULL)
{
_handler->value(false);
}
@ -701,24 +685,24 @@ void Parser::readValue(const Token* token)
case Token::FLOAT_LITERAL_TOKEN:
// Fall through
case Token::DOUBLE_LITERAL_TOKEN:
if ( _handler != NULL )
if (_handler != NULL)
{
_handler->value(token->asFloat());
}
break;
case Token::STRING_LITERAL_TOKEN:
if ( _handler != NULL )
if (_handler != NULL)
{
_handler->value(token->tokenString());
}
break;
case Token::SEPARATOR_TOKEN:
{
if ( token->asChar() == '{' )
if (token->asChar() == '{')
{
readObject();
}
else if ( token->asChar() == '[' )
else if (token->asChar() == '[')
{
readArray();
}
@ -732,17 +716,17 @@ void Parser::readValue(const Token* token)
void Parser::readArray()
{
if ( _handler != NULL )
if (_handler != NULL)
{
_handler->startArray();
}
if ( readElements(true) ) // First call is special: check for empty array
if (readElements(true)) // First call is special: check for empty array
{
while(readElements());
}
if ( _handler != NULL )
if (_handler != NULL)
{
_handler->endArray();
}
@ -753,7 +737,7 @@ bool Parser::readElements(bool firstCall)
{
const Token* token = nextToken();
if ( firstCall && token->is(Token::SEPARATOR_TOKEN) && token->asChar() == ']' )
if (firstCall && token->is(Token::SEPARATOR_TOKEN) && token->asChar() == ']')
{
// End of array is possible for an empty array
return false;
@ -765,10 +749,10 @@ bool Parser::readElements(bool firstCall)
if ( token->is(Token::SEPARATOR_TOKEN) )
{
if ( token->asChar() == ']' )
if (token->asChar() == ']')
return false; // End of array
if ( token->asChar() == ',' )
if (token->asChar() == ',')
return true;
throw JSONException(format("Invalid separator '%c' found. Expecting , or ]", token->asChar()));