Merge branch 'phoenix' of https://github.com/InvictusInnovations/fc into phoenix
This commit is contained in:
commit
07affde1f2
2 changed files with 54 additions and 38 deletions
|
|
@ -264,12 +264,14 @@ namespace fc {
|
||||||
|
|
||||||
istream& operator>>( istream& o, std::string& v )
|
istream& operator>>( istream& o, std::string& v )
|
||||||
{
|
{
|
||||||
|
assert(false && "not implemented");
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_FC_STRING
|
#ifdef USE_FC_STRING
|
||||||
istream& operator>>( istream& o, fc::string& v )
|
istream& operator>>( istream& o, fc::string& v )
|
||||||
{
|
{
|
||||||
|
assert(false && "not implemented");
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -282,51 +284,61 @@ namespace fc {
|
||||||
|
|
||||||
istream& operator>>( istream& o, double& v )
|
istream& operator>>( istream& o, double& v )
|
||||||
{
|
{
|
||||||
|
assert(false && "not implemented");
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
istream& operator>>( istream& o, float& v )
|
istream& operator>>( istream& o, float& v )
|
||||||
{
|
{
|
||||||
|
assert(false && "not implemented");
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
istream& operator>>( istream& o, int64_t& v )
|
istream& operator>>( istream& o, int64_t& v )
|
||||||
{
|
{
|
||||||
|
assert(false && "not implemented");
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
istream& operator>>( istream& o, uint64_t& v )
|
istream& operator>>( istream& o, uint64_t& v )
|
||||||
{
|
{
|
||||||
|
assert(false && "not implemented");
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
istream& operator>>( istream& o, int32_t& v )
|
istream& operator>>( istream& o, int32_t& v )
|
||||||
{
|
{
|
||||||
|
assert(false && "not implemented");
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
istream& operator>>( istream& o, uint32_t& v )
|
istream& operator>>( istream& o, uint32_t& v )
|
||||||
{
|
{
|
||||||
|
assert(false && "not implemented");
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
istream& operator>>( istream& o, int16_t& v )
|
istream& operator>>( istream& o, int16_t& v )
|
||||||
{
|
{
|
||||||
|
assert(false && "not implemented");
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
istream& operator>>( istream& o, uint16_t& v )
|
istream& operator>>( istream& o, uint16_t& v )
|
||||||
{
|
{
|
||||||
|
assert(false && "not implemented");
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
istream& operator>>( istream& o, int8_t& v )
|
istream& operator>>( istream& o, int8_t& v )
|
||||||
{
|
{
|
||||||
|
assert(false && "not implemented");
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
istream& operator>>( istream& o, uint8_t& v )
|
istream& operator>>( istream& o, uint8_t& v )
|
||||||
{
|
{
|
||||||
|
assert(false && "not implemented");
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -211,32 +211,29 @@ namespace fc
|
||||||
template<typename T>
|
template<typename T>
|
||||||
variant number_from_stream( T& in )
|
variant number_from_stream( T& in )
|
||||||
{
|
{
|
||||||
char buf[30];
|
fc::stringstream ss;
|
||||||
memset( buf, 0, sizeof(buf) );
|
|
||||||
char* pos = buf;
|
|
||||||
bool dot = false;
|
bool dot = false;
|
||||||
bool neg = false;
|
bool neg = false;
|
||||||
if( in.peek() == '-')
|
if( in.peek() == '-')
|
||||||
{
|
{
|
||||||
neg = true;
|
neg = true;
|
||||||
*pos = in.get();
|
ss.put( in.get() );
|
||||||
++pos;
|
|
||||||
}
|
}
|
||||||
bool done = false;
|
bool done = false;
|
||||||
while( !done)
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
char c = in.peek();
|
char c;
|
||||||
|
while((c = in.peek()) && !done)
|
||||||
|
{
|
||||||
|
|
||||||
switch( c )
|
switch( c )
|
||||||
{
|
{
|
||||||
case '.':
|
case '.':
|
||||||
{
|
if (dot)
|
||||||
if( dot )
|
FC_THROW_EXCEPTION(parse_error_exception, "Can't parse a number with two decimal places");
|
||||||
{
|
|
||||||
done = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
dot = true;
|
dot = true;
|
||||||
}
|
|
||||||
case '0':
|
case '0':
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
|
|
@ -247,18 +244,25 @@ namespace fc
|
||||||
case '7':
|
case '7':
|
||||||
case '8':
|
case '8':
|
||||||
case '9':
|
case '9':
|
||||||
*pos = c;
|
ss.put( in.get() );
|
||||||
++pos;
|
|
||||||
in.get();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
done = true;
|
done = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( dot ) return to_double(buf);
|
}
|
||||||
if( neg ) return to_int64(buf);
|
catch (fc::eof_exception&)
|
||||||
return to_uint64(buf);
|
{
|
||||||
|
}
|
||||||
|
fc::string str = ss.str();
|
||||||
|
if (str == "-." || str == ".") // check the obviously wrong things we could have encountered
|
||||||
|
FC_THROW_EXCEPTION(parse_error_exception, "Can't parse token \"${token}\" as a JSON numeric constant", ("token", str));
|
||||||
|
if( dot )
|
||||||
|
return to_double(str);
|
||||||
|
if( neg )
|
||||||
|
return to_int64(str);
|
||||||
|
return to_uint64(str);
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
variant token_from_stream( T& in )
|
variant token_from_stream( T& in )
|
||||||
|
|
@ -269,7 +273,7 @@ namespace fc
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
while( (c = in.peek()) && !parsed_unexpected_character)
|
while((c = in.peek()) && !parsed_unexpected_character)
|
||||||
{
|
{
|
||||||
switch( c )
|
switch( c )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue