Skip to content

Instantly share code, notes, and snippets.

@fuzz-ai
Created December 5, 2018 06:10
Show Gist options
  • Select an option

  • Save fuzz-ai/3b5d09d95700ded0aa2ceb5795812401 to your computer and use it in GitHub Desktop.

Select an option

Save fuzz-ai/3b5d09d95700ded0aa2ceb5795812401 to your computer and use it in GitHub Desktop.
fc::json::stringFromStream snippet
template<typename T>
fc::string stringFromStream( T& in )
...
while( true )
{
switch( c = in.peek() )
{
case '\\':
token << parseEscape( in );
break;
case 0x04:
FC_THROW_EXCEPTION( parse_error_exception, "EOF before closing '\"' in string '${token}'",
("token", token.str() ) );
case '"':
in.get();
return token.str();
default:
token << c;
in.get();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment