@@ -66,12 +66,12 @@ class SeparatorToken: public Token
6666
6767 bool start (char c, std::istream& istr)
6868 {
69- if ( c == ' {'
70- || c == ' }'
71- || c == ' ]'
72- || c == ' ['
73- || c == ' ,'
74- || c == ' :' )
69+ if (c == ' {'
70+ || c == ' }'
71+ || c == ' ]'
72+ || c == ' ['
73+ || c == ' ,'
74+ || c == ' :' )
7575 {
7676 _value = c;
7777 return true ;
@@ -109,7 +109,7 @@ class StringToken: public Token
109109
110110 bool start (char c, std::istream& istr)
111111 {
112- if ( c == ' "' )
112+ if (c == ' "' )
113113 {
114114 _value = " " ; // We don't need the quote!
115115 return true ;
@@ -122,7 +122,7 @@ class StringToken: public Token
122122 int c = 0 ;
123123 while ((c = istr.get ()) != -1 )
124124 {
125- if ( c == 0 )
125+ if (c == 0 )
126126 {
127127 throw JSONException (" Null byte not allowed" );
128128 }
@@ -132,7 +132,7 @@ class StringToken: public Token
132132 throw JSONException (format (" Control character 0x%x not allowed" , (unsigned int ) c));
133133 }
134134
135- if ( c == ' "' )
135+ if (c == ' "' )
136136 break ;
137137
138138 if (0x80 <= c && c <= 0xFF )
@@ -160,35 +160,19 @@ class StringToken: public Token
160160 continue ;
161161 }
162162
163- if ( c == ' \\ ' ) // Escaped String
163+ if (c == ' \\ ' ) // Escaped String
164164 {
165165 c = istr.get ();
166166 switch (c)
167167 {
168- case ' "' :
169- c = ' "' ;
170- break ;
171- case ' \\ ' :
172- c = ' \\ ' ;
173- break ;
174- case ' /' :
175- c = ' /' ;
176- break ;
177- case ' b' :
178- c = ' \b ' ;
179- break ;
180- case ' f' :
181- c = ' \f ' ;
182- break ;
183- case ' n' :
184- c = ' \n ' ;
185- break ;
186- case ' r' :
187- c = ' \r ' ;
188- break ;
189- case ' t' :
190- c = ' \t ' ;
191- break ;
168+ case ' "' : c = ' "' ; break ;
169+ case ' \\ ' : c = ' \\ ' ; break ;
170+ case ' /' : c = ' /' ; break ;
171+ case ' b' : c = ' \b ' ; break ;
172+ case ' f' : c = ' \f ' ; break ;
173+ case ' n' : c = ' \n ' ; break ;
174+ case ' r' : c = ' \r ' ; break ;
175+ case ' t' : c = ' \t ' ; break ;
192176 case ' u' : // Unicode
193177 {
194178 Poco::Int32 unicode = decodeUnicode (istr);
@@ -383,7 +367,7 @@ class NumberToken: public Token
383367 if ( c == -1 )
384368 return false ;
385369
386- if ( Ascii::isDigit (c) )
370+ if (Ascii::isDigit (c))
387371 {
388372 if ( c == ' 0' )
389373 {
@@ -397,14 +381,14 @@ class NumberToken: public Token
397381 return true ;
398382 }
399383
400- if ( c == ' -' )
384+ if (c == ' -' )
401385 {
402386 _value = c;
403387
404388 int nc = istr.peek ();
405- if ( Ascii::isDigit (nc) )
389+ if (Ascii::isDigit (nc))
406390 {
407- if ( nc == ' 0' )
391+ if (nc == ' 0' )
408392 {
409393 _value += ' 0' ;
410394 istr.get ();
@@ -427,7 +411,7 @@ class NumberToken: public Token
427411 int c;
428412 while ( (c = istr.peek ()) != -1 )
429413 {
430- if ( Ascii::isDigit (c) )
414+ if (Ascii::isDigit (c))
431415 {
432416 _value += c;
433417 istr.get ();
@@ -438,7 +422,7 @@ class NumberToken: public Token
438422 {
439423 case ' .' : // Float
440424 {
441- if ( _activeClass == Token::FLOAT_LITERAL_TOKEN )
425+ if (_activeClass == Token::FLOAT_LITERAL_TOKEN )
442426 {
443427 throw JSONException (" Invalid float value" );
444428 }
@@ -459,7 +443,7 @@ class NumberToken: public Token
459443 case ' E' :
460444 case ' e' :
461445 {
462- if ( _activeClass == Token::DOUBLE_LITERAL_TOKEN )
446+ if (_activeClass == Token::DOUBLE_LITERAL_TOKEN )
463447 {
464448 throw JSONException (" Invalid double value" );
465449 }
@@ -471,14 +455,14 @@ class NumberToken: public Token
471455
472456 // When the next char is - or + then read the next char
473457 c = istr.peek ();
474- if ( c == ' -' || c == ' +' )
458+ if (c == ' -' || c == ' +' )
475459 {
476460 _value += c;
477461 istr.get ();
478462 c = istr.peek ();
479463 }
480464
481- if ( ! Ascii::isDigit (c) )
465+ if (! Ascii::isDigit (c))
482466 {
483467 throw JSONException (" Invalid double value" );
484468 }
@@ -520,7 +504,7 @@ Parser::~Parser()
520504const Token* Parser::nextToken ()
521505{
522506 const Token* token = _tokenizer.next ();
523- if ( token->is (Token::EOF_TOKEN ) )
507+ if (token->is (Token::EOF_TOKEN ))
524508 {
525509 throw JSONException (" Unexpected EOF found" );
526510 }
@@ -533,14 +517,14 @@ void Parser::parse(std::istream& in)
533517 _tokenizer.attachToStream (in);
534518 const Token* token = nextToken ();
535519
536- if ( token->is (Token::SEPARATOR_TOKEN ) )
520+ if (token->is (Token::SEPARATOR_TOKEN ))
537521 {
538522 // This must be a { or a [
539- if ( token->asChar () == ' {' )
523+ if (token->asChar () == ' {' )
540524 {
541525 readObject ();
542526 }
543- else if ( token->asChar () == ' [' )
527+ else if (token->asChar () == ' [' )
544528 {
545529 readArray ();
546530 }
@@ -549,7 +533,7 @@ void Parser::parse(std::istream& in)
549533 throw JSONException (format (" Invalid separator '%c' found. Expecting { or [" , token->asChar ()));
550534 }
551535 token = _tokenizer.next ();
552- if ( ! token->is (Token::EOF_TOKEN ) )
536+ if (! token->is (Token::EOF_TOKEN ))
553537 {
554538 throw JSONException (format (" EOF expected but found '%s'" , token->asString ()));
555539 }
@@ -563,7 +547,7 @@ void Parser::parse(std::istream& in)
563547
564548void Parser::readObject ()
565549{
566- if ( _handler != NULL )
550+ if (_handler != NULL )
567551 {
568552 _handler->startObject ();
569553 }
@@ -573,7 +557,7 @@ void Parser::readObject()
573557 while (readRow ());
574558 }
575559
576- if ( _handler != NULL )
560+ if (_handler != NULL )
577561 {
578562 _handler->endObject ();
579563 }
@@ -584,12 +568,12 @@ bool Parser::readRow(bool firstCall)
584568{
585569 const Token* token = nextToken ();
586570
587- if ( firstCall && token->tokenClass () == Token::SEPARATOR_TOKEN && token->asChar () == ' }' )
571+ if (firstCall && token->tokenClass () == Token::SEPARATOR_TOKEN && token->asChar () == ' }' )
588572 {
589573 return false ; // End of object is possible for an empty object
590574 }
591575
592- if ( token->tokenClass () == Token::STRING_LITERAL_TOKEN )
576+ if (token->tokenClass () == Token::STRING_LITERAL_TOKEN )
593577 {
594578 std::string propertyName = token->tokenString ();
595579 if ( _handler != NULL )
@@ -599,20 +583,20 @@ bool Parser::readRow(bool firstCall)
599583
600584 token = nextToken ();
601585
602- if ( token->is (Token::SEPARATOR_TOKEN )
603- && token->asChar () == ' :' )
586+ if ( token->is (Token::SEPARATOR_TOKEN )
587+ && token->asChar () == ' :' )
604588 {
605589 readValue (nextToken ());
606590
607591 token = nextToken ();
608592
609- if ( token->is (Token::SEPARATOR_TOKEN ) )
593+ if (token->is (Token::SEPARATOR_TOKEN ))
610594 {
611- if ( token->asChar () == ' ,' )
595+ if (token->asChar () == ' ,' )
612596 {
613597 return true ; // Read next row
614598 }
615- else if ( token->asChar () == ' }' )
599+ else if (token->asChar () == ' }' )
616600 {
617601 return false ; // End of object
618602 }
@@ -649,13 +633,13 @@ void Parser::readValue(const Token* token)
649633 break ;
650634
651635 case Token::INTEGER_LITERAL_TOKEN :
652- if ( _handler != NULL )
636+ if (_handler != NULL )
653637 {
654638#if defined(POCO_HAVE_INT64)
655639 Int64 value = token->asInteger64 ();
656640 // if number is 32-bit, then handle as such
657- if ( value > std::numeric_limits<int >::max ()
658- || value < std::numeric_limits<int >::min () )
641+ if ( value > std::numeric_limits<int >::max ()
642+ || value < std::numeric_limits<int >::min ())
659643 {
660644 _handler->value (value);
661645 }
@@ -671,23 +655,23 @@ void Parser::readValue(const Token* token)
671655 break ;
672656 case Token::KEYWORD_TOKEN :
673657 {
674- if ( token->tokenString ().compare (" null" ) == 0 )
658+ if (token->tokenString ().compare (" null" ) == 0 )
675659 {
676- if ( _handler != NULL )
660+ if (_handler != NULL )
677661 {
678662 _handler->null ();
679663 }
680664 }
681- else if ( token->tokenString ().compare (" true" ) == 0 )
665+ else if (token->tokenString ().compare (" true" ) == 0 )
682666 {
683- if ( _handler != NULL )
667+ if (_handler != NULL )
684668 {
685669 _handler->value (true );
686670 }
687671 }
688- else if ( token->tokenString ().compare (" false" ) == 0 )
672+ else if (token->tokenString ().compare (" false" ) == 0 )
689673 {
690- if ( _handler != NULL )
674+ if (_handler != NULL )
691675 {
692676 _handler->value (false );
693677 }
@@ -701,24 +685,24 @@ void Parser::readValue(const Token* token)
701685 case Token::FLOAT_LITERAL_TOKEN :
702686 // Fall through
703687 case Token::DOUBLE_LITERAL_TOKEN :
704- if ( _handler != NULL )
688+ if (_handler != NULL )
705689 {
706690 _handler->value (token->asFloat ());
707691 }
708692 break ;
709693 case Token::STRING_LITERAL_TOKEN :
710- if ( _handler != NULL )
694+ if (_handler != NULL )
711695 {
712696 _handler->value (token->tokenString ());
713697 }
714698 break ;
715699 case Token::SEPARATOR_TOKEN :
716700 {
717- if ( token->asChar () == ' {' )
701+ if (token->asChar () == ' {' )
718702 {
719703 readObject ();
720704 }
721- else if ( token->asChar () == ' [' )
705+ else if (token->asChar () == ' [' )
722706 {
723707 readArray ();
724708 }
@@ -732,17 +716,17 @@ void Parser::readValue(const Token* token)
732716
733717void Parser::readArray ()
734718{
735- if ( _handler != NULL )
719+ if (_handler != NULL )
736720 {
737721 _handler->startArray ();
738722 }
739723
740- if ( readElements (true ) ) // First call is special: check for empty array
724+ if (readElements (true )) // First call is special: check for empty array
741725 {
742726 while (readElements ());
743727 }
744728
745- if ( _handler != NULL )
729+ if (_handler != NULL )
746730 {
747731 _handler->endArray ();
748732 }
@@ -753,7 +737,7 @@ bool Parser::readElements(bool firstCall)
753737{
754738 const Token* token = nextToken ();
755739
756- if ( firstCall && token->is (Token::SEPARATOR_TOKEN ) && token->asChar () == ' ]' )
740+ if (firstCall && token->is (Token::SEPARATOR_TOKEN ) && token->asChar () == ' ]' )
757741 {
758742 // End of array is possible for an empty array
759743 return false ;
@@ -765,10 +749,10 @@ bool Parser::readElements(bool firstCall)
765749
766750 if ( token->is (Token::SEPARATOR_TOKEN ) )
767751 {
768- if ( token->asChar () == ' ]' )
752+ if (token->asChar () == ' ]' )
769753 return false ; // End of array
770754
771- if ( token->asChar () == ' ,' )
755+ if (token->asChar () == ' ,' )
772756 return true ;
773757
774758 throw JSONException (format (" Invalid separator '%c' found. Expecting , or ]" , token->asChar ()));
0 commit comments