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

Function objectFromStream

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

Source from the content-addressed store, hash-verified

169
170 template<typename T, json::parse_type parser_type>
171 variant_object objectFromStream( T& in, uint32_t max_depth )
172 {
173 mutable_variant_object obj;
174 try
175 {
176 char c = in.peek();
177 if( c != '{' )
178 FC_THROW_EXCEPTION( parse_error_exception,
179 "Expected '{', but read '${char}'",
180 ("char",string(&c, &c + 1)) );
181 in.get();
182 while( in.peek() != '}' )
183 {
184 if( in.peek() == ',' )
185 {
186 in.get();
187 continue;
188 }
189 if( skip_white_space(in) ) continue;
190 string key = stringFromStream( in );
191 skip_white_space(in);
192 if( in.peek() != ':' )
193 {
194 FC_THROW_EXCEPTION( parse_error_exception, "Expected ':' after key \"${key}\"",
195 ("key", key) );
196 }
197 in.get();
198 auto val = variant_from_stream<T, parser_type>( in, max_depth - 1 );
199
200 obj(std::move(key),std::move(val));
201 //skip_white_space(in);
202 }
203 if( in.peek() == '}' )
204 {
205 in.get();
206 return obj;
207 }
208 FC_THROW_EXCEPTION( parse_error_exception, "Expected '}' after ${variant}", ("variant", obj ) );
209 }
210 catch( const fc::eof_exception& e )
211 {
212 FC_THROW_EXCEPTION( parse_error_exception, "Unexpected EOF: ${e}", ("e", e.to_detail_string() ) );
213 }
214 catch( const std::ios_base::failure& e )
215 {
216 FC_THROW_EXCEPTION( parse_error_exception, "Unexpected EOF: ${e}", ("e", e.what() ) );
217 } FC_RETHROW_EXCEPTIONS( warn, "Error parsing object" );
218 }
219
220 template<typename T, json::parse_type parser_type>
221 variants arrayFromStream( T& in, uint32_t max_depth )

Callers

nothing calls this directly

Calls 7

stringClass · 0.85
skip_white_spaceFunction · 0.85
to_detail_stringMethod · 0.80
stringFromStreamFunction · 0.70
peekMethod · 0.45
getMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected