Applied variant_from_stream fix from regular to relaxed
This commit is contained in:
parent
4bb8bf7832
commit
d336af82a6
1 changed files with 41 additions and 49 deletions
|
|
@ -626,56 +626,48 @@ namespace fc { namespace json_relaxed
|
||||||
variant variant_from_stream( T& in )
|
variant variant_from_stream( T& in )
|
||||||
{
|
{
|
||||||
skip_white_space(in);
|
skip_white_space(in);
|
||||||
variant var;
|
signed char c = in.peek();
|
||||||
while( signed char c = in.peek() )
|
switch( c )
|
||||||
{
|
{
|
||||||
switch( c )
|
case '"':
|
||||||
{
|
return json_relaxed::stringFromStream<T, strict>( in );
|
||||||
case ' ':
|
case '{':
|
||||||
case '\t':
|
return json_relaxed::objectFromStream<T, strict>( in );
|
||||||
case '\n':
|
case '[':
|
||||||
case '\r':
|
return json_relaxed::arrayFromStream<T, strict>( in );
|
||||||
in.get();
|
case '-':
|
||||||
continue;
|
case '+':
|
||||||
case '"':
|
case '.':
|
||||||
return json_relaxed::stringFromStream<T, strict>( in );
|
case '0':
|
||||||
case '{':
|
case '1':
|
||||||
return json_relaxed::objectFromStream<T, strict>( in );
|
case '2':
|
||||||
case '[':
|
case '3':
|
||||||
return json_relaxed::arrayFromStream<T, strict>( in );
|
case '4':
|
||||||
case '-':
|
case '5':
|
||||||
case '+':
|
case '6':
|
||||||
case '.':
|
case '7':
|
||||||
case '0':
|
case '8':
|
||||||
case '1':
|
case '9':
|
||||||
case '2':
|
return json_relaxed::numberFromStream<T, strict>( in );
|
||||||
case '3':
|
// null, true, false, or 'warning' / string
|
||||||
case '4':
|
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
|
||||||
case '5':
|
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p':
|
||||||
case '6':
|
case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x':
|
||||||
case '7':
|
case 'y': case 'z':
|
||||||
case '8':
|
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H':
|
||||||
case '9':
|
case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P':
|
||||||
return json_relaxed::numberFromStream<T, strict>( in );
|
case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
|
||||||
// null, true, false, or 'warning' / string
|
case 'Y': case 'Z':
|
||||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
|
case '_': case '/':
|
||||||
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p':
|
return json_relaxed::wordFromStream<T, strict>( in );
|
||||||
case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x':
|
case 0x04: // ^D end of transmission
|
||||||
case 'y': case 'z':
|
case EOF:
|
||||||
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H':
|
FC_THROW_EXCEPTION( eof_exception, "unexpected end of file" );
|
||||||
case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': case 'O': case 'P':
|
case 0:
|
||||||
case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
|
default:
|
||||||
case 'Y': case 'Z':
|
FC_THROW_EXCEPTION( parse_error_exception, "Unexpected char '${c}' in \"${s}\"",
|
||||||
case '_': case '/':
|
("c", c)("s", stringFromToken(in)) );
|
||||||
return json_relaxed::wordFromStream<T, strict>( in );
|
|
||||||
case 0x04: // ^D end of transmission
|
|
||||||
case EOF:
|
|
||||||
FC_THROW_EXCEPTION( eof_exception, "unexpected end of file" );
|
|
||||||
default:
|
|
||||||
FC_THROW_EXCEPTION( parse_error_exception, "Unexpected char '${c}' in \"${s}\"",
|
|
||||||
("c", c)("s", stringFromToken(in)) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return variant();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} } // fc::json_relaxed
|
} } // fc::json_relaxed
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue