MCPcopy Create free account
hub / github.com/Clarionos/clarion / stringFromStream

Function stringFromStream

libraries/fc/src/io/json.cpp:89–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87
88 template<typename T>
89 std::string stringFromStream( T& in )
90 {
91 std::stringstream token;
92 try
93 {
94 char c = in.peek();
95
96 if( c != '"' )
97 FC_THROW_EXCEPTION( parse_error_exception,
98 "Expected '\"' but read '${char}'",
99 ("char", string(&c, (&c) + 1) ) );
100 in.get();
101 while( !in.eof() )
102 {
103 switch( c = in.peek() )
104 {
105 case '\\':
106 token << parseEscape( in );
107 break;
108 case 0x04:
109 FC_THROW_EXCEPTION( parse_error_exception, "EOF before closing '\"' in string '${token}'",
110 ("token", token.str() ) );
111 case '"':
112 in.get();
113 return token.str();
114 default:
115 token << c;
116 in.get();
117 }
118 }
119 FC_THROW_EXCEPTION( parse_error_exception, "EOF before closing '\"' in string '${token}'",
120 ("token", token.str() ) );
121 } FC_RETHROW_EXCEPTIONS( warn, "while parsing token '${token}'",
122 ("token", token.str() ) );
123 }
124 template<typename T>
125 std::string stringFromToken( T& in )
126 {

Callers 2

objectFromStreamFunction · 0.70
variant_from_streamFunction · 0.70

Calls 6

stringClass · 0.85
parseEscapeFunction · 0.85
peekMethod · 0.45
getMethod · 0.45
eofMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected