本文整理汇总了C++中JsonArray::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonArray::empty方法的具体用法?C++ JsonArray::empty怎么用?C++ JsonArray::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonArray
的用法示例。
在下文中一共展示了JsonArray::empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deserialize
/*
* load player from ginormous json blob
*/
void player::deserialize(JsonIn &jsin)
{
JsonObject data = jsin.get_object();
JsonArray parray;
json_load_common_variables( data );
std::string prof_ident="(null)";
if ( data.read("profession",prof_ident) && profession::exists(prof_ident) ) {
prof = profession::prof(prof_ident);
} else {
debugmsg("Tried to use non-existent profession '%s'", prof_ident.c_str());
}
data.read("activity",activity);
data.read("backlog",backlog);
data.read("driving_recoil",driving_recoil);
data.read("in_vehicle",in_vehicle);
data.read("controlling_vehicle",controlling_vehicle);
data.read("grab_point", grab_point);
std::string grab_typestr="OBJECT_NONE";
if( grab_point.x != 0 || grab_point.y != 0 ) {
grab_typestr = "OBJECT_VEHICLE";
data.read( "grab_type", grab_typestr);
}
if ( obj_type_id.find(grab_typestr) != obj_type_id.end() ) {
grab_type = (object_type)obj_type_id[grab_typestr];
}
data.read( "blocks_left", num_blocks);
data.read( "focus_pool", focus_pool);
data.read( "style_selected", style_selected );
data.read( "health", health );
data.read( "mutations", my_mutations );
set_highest_cat_level();
drench_mut_calc();
parray = data.get_array("temp_cur");
if ( parray.size() == num_bp ) {
for(int i=0; i < num_bp; i++) {
temp_cur[i]=parray.get_int(i);
}
} else {
debugmsg("Error, incompatible temp_cur in save file %s",parray.str().c_str());
}
parray = data.get_array("temp_conv");
if ( parray.size() == num_bp ) {
for(int i=0; i < num_bp; i++) {
temp_conv[i]=parray.get_int(i);
}
} else {
debugmsg("Error, incompatible temp_conv in save file %s",parray.str().c_str());
}
parray = data.get_array("frostbite_timer");
if ( parray.size() == num_bp ) {
for(int i=0; i < num_bp; i++) {
frostbite_timer[i]=parray.get_int(i);
}
} else {
debugmsg("Error, incompatible frostbite_timer in save file %s",parray.str().c_str());
}
parray = data.get_array("learned_recipes");
if ( !parray.empty() ) {
learned_recipes.clear();
std::string pstr="";
while ( parray.has_more() ) {
if ( parray.read_next(pstr) ) {
learned_recipes[ pstr ] = recipe_by_name( pstr );
}
}
}
data.read("morale", morale);
data.read( "active_mission", active_mission );
data.read( "active_missions", active_missions );
data.read( "failed_missions", failed_missions );
data.read( "completed_missions", completed_missions );
stats & pstats = *lifetime_stats();
data.read("player_stats",pstats);
inv.clear();
if ( data.has_member("inv") ) {
JsonIn* jip = data.get_raw("inv");
inv.json_load_items( *jip );
}
//.........这里部分代码省略.........