本文整理汇总了C++中JsonIn::eat_whitespace方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonIn::eat_whitespace方法的具体用法?C++ JsonIn::eat_whitespace怎么用?C++ JsonIn::eat_whitespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonIn
的用法示例。
在下文中一共展示了JsonIn::eat_whitespace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_all_from_json
void DynamicDataLoader::load_all_from_json(JsonIn &jsin)
{
char ch;
jsin.eat_whitespace();
// examine first non-whitespace char
ch = jsin.peek();
if (ch == '{') {
// find type and dispatch single object
JsonObject jo = jsin.get_object();
load_object(jo);
jo.finish();
// if there's anything else in the file, it's an error.
jsin.eat_whitespace();
if (jsin.good()) {
jsin.error( string_format( "expected single-object file but found '%c'", jsin.peek() ) );
}
} else if (ch == '[') {
jsin.start_array();
// find type and dispatch each object until array close
while (!jsin.end_array()) {
jsin.eat_whitespace();
ch = jsin.peek();
if (ch != '{') {
jsin.error( string_format( "expected array of objects but found '%c', not '{'", ch ) );
}
JsonObject jo = jsin.get_object();
load_object(jo);
jo.finish();
}
} else {
// not an object or an array?
jsin.error( string_format( "expected object or array, but found '%c'", ch ) );
}
}
示例2: load_all_from_json
void DynamicDataLoader::load_all_from_json( JsonIn &jsin, const std::string &src, loading_ui &,
const std::string &base_path, const std::string &full_path )
{
if( jsin.test_object() ) {
// find type and dispatch single object
JsonObject jo = jsin.get_object();
load_object( jo, src, base_path, full_path );
jo.finish();
// if there's anything else in the file, it's an error.
jsin.eat_whitespace();
if( jsin.good() ) {
jsin.error( string_format( "expected single-object file but found '%c'", jsin.peek() ) );
}
} else if( jsin.test_array() ) {
jsin.start_array();
// find type and dispatch each object until array close
while( !jsin.end_array() ) {
JsonObject jo = jsin.get_object();
load_object( jo, src, base_path, full_path );
jo.finish();
}
} else {
// not an object or an array?
jsin.error( "expected object or array" );
}
}
示例3: load_all_from_json
void DynamicDataLoader::load_all_from_json(JsonIn &jsin)
{
char ch;
std::string type = "";
jsin.eat_whitespace();
// examine first non-whitespace char
ch = jsin.peek();
if (ch == '{') {
// find type and dispatch single object
JsonObject jo = jsin.get_object();
load_object(jo);
jo.finish();
// if there's anything else in the file, it's an error.
jsin.eat_whitespace();
if (jsin.good()) {
std::stringstream err;
err << jsin.line_number() << ": ";
err << "expected single-object file but found '";
err << jsin.peek() << "'";
throw err.str();
}
} else if (ch == '[') {
jsin.start_array();
// find type and dispatch each object until array close
while (!jsin.end_array()) {
jsin.eat_whitespace();
ch = jsin.peek();
if (ch != '{') {
std::stringstream err;
err << jsin.line_number() << ": ";
err << "expected array of objects but found '";
err << ch << "', not '{'";
throw err.str();
}
JsonObject jo = jsin.get_object();
load_object(jo);
jo.finish();
}
} else {
// not an object or an array?
std::stringstream err;
err << jsin.line_number() << ": ";
err << "expected object or array, but found '" << ch << "'";
throw err.str();
}
}