本文整理汇总了C++中JsonArray::str方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonArray::str方法的具体用法?C++ JsonArray::str怎么用?C++ JsonArray::str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonArray
的用法示例。
在下文中一共展示了JsonArray::str方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
}
//.........这里部分代码省略.........
示例2: json_load_common_variables
void player::json_load_common_variables(JsonObject & data)
{
JsonArray parray;
// todo/maybe:
// std::map<std::string, int*> strmap_common_variables;
// void player::init_strmap_common_variables() {
// strmap_common_variables["posx"]=&posx; // + all this below and in save_common_variables
// }
// load:
// for(std::map<std::string, int*>::iterator it...
// data.read(it->first,it->second);
// save:
// for(...
// json.member( it->first, it->second );
if(!data.read("posx",posx) ) { // uh-oh.
debugmsg("BAD PLAYER/NPC JSON: no 'posx'?");
}
data.read("posy",posy);
data.read("str_cur",str_cur); data.read("str_max",str_max);
data.read("dex_cur",dex_cur); data.read("dex_max",dex_max);
data.read("int_cur",int_cur); data.read("int_max",int_max);
data.read("per_cur",per_cur); data.read("per_max",per_max);
data.read("hunger",hunger); data.read("thirst",thirst);
data.read("fatigue",fatigue); data.read("stim",stim);
data.read("pain",pain); data.read("pkill",pkill);
data.read("radiation",radiation);
data.read("scent",scent);
data.read("moves",moves);
data.read("dodges_left",num_dodges);
data.read("underwater",underwater);
data.read("oxygen",oxygen);
data.read("male",male);
data.read("cash",cash);
data.read("recoil",recoil);
parray = data.get_array("hp_cur");
if ( parray.size() == num_hp_parts ) {
for(int i=0; i < num_hp_parts; i++) {
hp_cur[i] = parray.get_int(i);
}
} else {
debugmsg("Error, incompatible hp_cur in save file '%s'",parray.str().c_str());
}
parray = data.get_array("hp_max");
if ( parray.size() == num_hp_parts ) {
for(int i=0; i < num_hp_parts; i++) {
hp_max[i] = parray.get_int(i);
}
} else {
debugmsg("Error, incompatible hp_max in save file '%s'",parray.str().c_str());
}
data.read("power_level",power_level);
data.read("max_power_level",max_power_level);
data.read("traits",my_traits);
if (data.has_object("skills")) {
JsonObject pmap = data.get_object("skills");
for (std::vector<Skill*>::iterator aSkill = Skill::skills.begin(); aSkill != Skill::skills.end(); ++aSkill) {
if ( pmap.has_object( (*aSkill)->ident() ) ) {
pmap.read( (*aSkill)->ident(), skillLevel(*aSkill) );
} else {
debugmsg("Load (%s) Missing skill %s","",(*aSkill)->ident().c_str() );
}
}
} else {
debugmsg("Skills[] no bueno");
}
data.read("ma_styles",ma_styles);
data.read("illness",illness);
data.read("effects",effects);
data.read("addictions",addictions);
data.read("my_bionics",my_bionics);
}