FC Updates from BitShares and myself #21

Closed
nathanielhourt wants to merge 687 commits from dapp-support into latest-fc
Showing only changes of commit 4d782e894f - Show all commits

View file

@ -461,21 +461,9 @@ namespace fc
{ try { { try {
check_string_depth( utf8_str ); check_string_depth( utf8_str );
fc::stringstream in( utf8_str ); fc::istream_ptr in( new fc::stringstream( utf8_str ) );
//in.exceptions( std::ifstream::eofbit ); fc::buffered_istream bin( in );
switch( ptype ) return from_stream( bin, ptype );
{
case legacy_parser:
return variant_from_stream<fc::stringstream, legacy_parser>( in );
case legacy_parser_with_string_doubles:
return variant_from_stream<fc::stringstream, legacy_parser_with_string_doubles>( in );
case strict_parser:
return json_relaxed::variant_from_stream<fc::stringstream, true>( in );
case relaxed_parser:
return json_relaxed::variant_from_stream<fc::stringstream, false>( in );
default:
FC_ASSERT( false, "Unknown JSON parser type {ptype}", ("ptype", ptype) );
}
} FC_RETHROW_EXCEPTIONS( warn, "", ("str",utf8_str) ) } } FC_RETHROW_EXCEPTIONS( warn, "", ("str",utf8_str) ) }
variants json::variants_from_string( const std::string& utf8_str, parse_type ptype ) variants json::variants_from_string( const std::string& utf8_str, parse_type ptype )
@ -838,25 +826,10 @@ namespace fc
bool json::is_valid( const std::string& utf8_str, parse_type ptype ) bool json::is_valid( const std::string& utf8_str, parse_type ptype )
{ {
if( utf8_str.size() == 0 ) return false; if( utf8_str.size() == 0 ) return false;
fc::stringstream in( utf8_str ); fc::istream_ptr in( new fc::stringstream( utf8_str ) );
switch( ptype ) fc::buffered_istream bin( in );
{ from_stream( bin, ptype );
case legacy_parser: try { bin.peek(); } catch ( const eof_exception& e ) { return true; }
variant_from_stream<fc::stringstream, legacy_parser>( in );
break;
case legacy_parser_with_string_doubles:
variant_from_stream<fc::stringstream, legacy_parser_with_string_doubles>( in );
break;
case strict_parser:
json_relaxed::variant_from_stream<fc::stringstream, true>( in );
break;
case relaxed_parser:
json_relaxed::variant_from_stream<fc::stringstream, false>( in );
break;
default:
FC_ASSERT( false, "Unknown JSON parser type {ptype}", ("ptype", ptype) );
}
try { in.peek(); } catch ( const eof_exception& e ) { return true; }
return false; return false;
} }