本文整理汇总了C++中JsonOut::start_object方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonOut::start_object方法的具体用法?C++ JsonOut::start_object怎么用?C++ JsonOut::start_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonOut
的用法示例。
在下文中一共展示了JsonOut::start_object方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serialize
void safemode::serialize( JsonOut &json ) const
{
json.start_array();
auto &temp_rules = ( is_character ) ? character_rules : global_rules;
for( auto &elem : temp_rules ) {
json.start_object();
json.member( "rule", elem.rule );
json.member( "active", elem.active );
json.member( "whitelist", elem.whitelist );
json.member( "attitude", elem.attitude );
json.member( "proximity", elem.proximity );
json.end_object();
}
json.end_array();
}
示例2: serialize
void it_artifact_tool::serialize(JsonOut &json) const
{
json.start_object();
json.member("type", "artifact_tool");
// generic data
json.member("id", id);
json.member("name", name);
json.member("description", description);
json.member("sym", sym);
json.member("color", color_to_int(color));
json.member("price", price);
json.member("m1", m1);
json.member("m2", m2);
json.member("volume", volume);
json.member("weight", weight);
json.member("melee_dam", melee_dam);
json.member("melee_cut", melee_cut);
json.member("m_to_hit", m_to_hit);
json.member("item_flags", item_tags);
json.member("techniques", techniques);
// tool data
json.member("ammo", ammo);
json.member("max_charges", max_charges);
json.member("def_charges", def_charges);
json.member("rand_charges", rand_charges);
json.member("charges_per_use", charges_per_use);
json.member("turns_per_charge", turns_per_charge);
json.member("revert_to", revert_to);
// artifact data
json.member("charge_type", charge_type);
json.member("effects_wielded", effects_wielded);
json.member("effects_activated", effects_activated);
json.member("effects_carried", effects_carried);
json.end_object();
}
示例3: serialize
/*
* Save, json ed; serialization that won't break as easily. In theory.
*/
void monster::serialize(JsonOut &json, bool save_contents) const
{
json.start_object();
json.member( "typeid", type->id );
json.member("posx",_posx);
json.member("posy",_posy);
json.member("wandx",wandx);
json.member("wandy",wandy);
json.member("wandf",wandf);
json.member("moves",moves);
json.member("speed",speed);
json.member("hp",hp);
json.member("sp_timeout",sp_timeout);
json.member("friendly",friendly);
json.member("faction_id",faction_id);
json.member("mission_id",mission_id);
json.member("no_extra_death_drops", no_extra_death_drops );
json.member("dead",dead);
json.member("anger",anger);
json.member("morale",morale);
json.member("hallucination",hallucination);
json.member("onstairs",onstairs);
json.member("stairscount",staircount);
json.member("plans", plans);
json.member("ammo", ammo);
json.member("effects", effects);
if ( save_contents ) {
json.member("inv");
json.start_array();
for(int i=0;i<inv.size();i++) {
inv[i].serialize(json, true);
}
json.end_array();
}
json.end_object();
}
示例4: serialize
void serialize( JsonOut &js ) const override {
js.start_object();
js.member( "type", "character" );
js.member( "idx", find_index( who, target() ) );
js.end_object();
}
示例5: npcs
/*
* Prepare a json object for player, including player specific data, and data common to
players and npcs ( which json_save_actor_data() handles ).
*/
void player::serialize(JsonOut &json, bool save_contents) const
{
json.start_object();
json_save_common_variables( json );
// player-specific specifics
if ( prof != NULL ) {
json.member( "profession", prof->ident() );
}
// someday, npcs may drive
json.member( "driving_recoil", int(driving_recoil) );
json.member( "in_vehicle", in_vehicle );
json.member( "controlling_vehicle", controlling_vehicle );
// shopping carts, furniture etc
json.member( "grab_point", grab_point );
json.member( "grab_type", obj_type_name[ (int)grab_type ] );
// misc player specific stuff
json.member( "blocks_left", num_blocks );
json.member( "focus_pool", focus_pool );
json.member( "style_selected", style_selected );
// possibly related to illness[] ?
json.member( "health", health );
// crafting etc
json.member( "activity", activity );
json.member( "backlog", activity );
// mutations; just like traits but can be removed.
json.member( "mutations", my_mutations );
// "The cold wakes you up."
json.member( "temp_cur", std::vector<int>( temp_cur, temp_cur + num_bp ) );
json.member( "temp_conv", std::vector<int>( temp_conv, temp_conv + num_bp ) );
json.member( "frostbite_timer", std::vector<int>( frostbite_timer, frostbite_timer + num_bp ) );
// npc: unimplemented, potentially useful
json.member( "learned_recipes" );
json.start_array();
for (std::map<std::string, recipe*>::const_iterator iter = learned_recipes.begin(); iter != learned_recipes.end(); ++iter) {
json.write( iter->first );
}
json.end_array();
// :(
json.member( "morale", morale );
// mission stuff
json.member("active_mission", active_mission );
json.member( "active_missions", active_missions );
json.member( "completed_missions", completed_missions );
json.member( "failed_missions", failed_missions );
json.member( "player_stats", get_stats() );
if ( save_contents ) {
json.member( "worn", worn ); // also saves contents
json.member("inv");
inv.json_save_items(json);
json.member("invcache");
inv.json_save_invcache(json);
if (!weapon.is_null()) {
json.member( "weapon", weapon ); // also saves contents
}
//FIXME: seperate function, better still another file
/* for( size_t i = 0; i < memorial_log.size(); ++i ) {
ptmpvect.push_back(pv(memorial_log[i]));
}
json.member("memorial",ptmpvect);
*/
}
json.end_object();
}
示例6: json_save_common_variables
/*
* Variables common to player and npc
*/
void player::json_save_common_variables(JsonOut &json) const
{
// assumes already in player object
// positional data
json.member( "posx", posx ); json.member( "posy", posy );
// attributes, current / max levels
json.member( "str_cur", str_cur ); json.member( "str_max", str_max );
json.member( "dex_cur", dex_cur ); json.member( "dex_max", dex_max );
json.member( "int_cur", int_cur ); json.member( "int_max", int_max );
json.member( "per_cur", per_cur ); json.member( "per_max", per_max );
// om-noms or lack thereof
json.member( "hunger", hunger ); json.member( "thirst", thirst );
// energy
json.member( "fatigue", fatigue ); json.member( "stim", stim );
// pain
json.member( "pain", pain ); json.member( "pkill", pkill );
// misc levels
json.member( "radiation", radiation );
json.member( "scent", int(scent) );
// initiative type stuff
json.member( "moves", moves );
json.member( "dodges_left", num_dodges);
// breathing
json.member( "underwater", underwater );
json.member( "oxygen", oxygen );
// gender
json.member( "male", male );
json.member( "cash", cash );
json.member( "recoil", int(recoil) );
// potential incompatibility with future expansion
// todo: consider ["parts"]["head"]["hp_cur"] instead of ["hp_cur"][head_enum_value]
json.member( "hp_cur", std::vector<int>( hp_cur, hp_cur + num_hp_parts ) );
json.member( "hp_max", std::vector<int>( hp_max, hp_max + num_hp_parts ) );
// npc; unimplemented
json.member( "power_level", power_level );
json.member( "max_power_level", max_power_level );
// traits: permanent 'mutations' more or less
json.member( "traits", my_traits );
// skills
json.member( "skills" );
json.start_object();
for (std::vector<Skill*>::iterator aSkill = Skill::skills.begin(); aSkill != Skill::skills.end(); ++aSkill) {
SkillLevel sk = get_skill_level(*aSkill);
json.member((*aSkill)->ident(), sk);
}
json.end_object();
// martial arts
/*for (int i = 0; i < ma_styles.size(); i++) {
ptmpvect.push_back( pv( ma_styles[i] ) );
}*/
json.member( "ma_styles", ma_styles );
// disease
json.member( "illness", illness );
json.member( "effects", effects );
// "Looks like I picked the wrong week to quit smoking." - Steve McCroskey
json.member( "addictions", addictions );
// "Fracking Toasters" - Saul Tigh, toaster
json.member( "my_bionics", my_bionics );
}
示例7: serialize
void item::serialize(JsonOut &json, bool save_contents) const
{
json.start_object();
/////
if (type == NULL) {
debugmsg("Tried to save an item with NULL type!");
}
itype_id ammotmp = "null";
/* TODO: This causes a segfault sometimes, even though we check to make sure
* curammo isn't NULL. The crashes seem to occur most frequently when saving an
* NPC, or when saving map data containing an item an NPC has dropped.
*/
if (curammo != NULL) {
ammotmp = curammo->id;
}
if( std::find(unreal_itype_ids.begin(), unreal_itype_ids.end(),
ammotmp) != unreal_itype_ids.end() &&
std::find(artifact_itype_ids.begin(), artifact_itype_ids.end(),
ammotmp) != artifact_itype_ids.end()
) {
ammotmp = "null"; //Saves us from some bugs, apparently?
}
/////
json.member( "invlet", int(invlet) );
json.member( "typeid", typeId() );
json.member( "bday", bday );
if ( charges != -1 ) json.member( "charges", int(charges) );
if ( damage != 0 ) json.member( "damage", int(damage) );
if ( burnt != 0 ) json.member( "burnt", burnt );
if ( poison != 0 ) json.member( "poison", poison );
if ( ammotmp != "null" ) json.member( "curammo", ammotmp );
if ( mode != "NULL" ) json.member( "mode", mode );
if ( active == true ) json.member( "active", true );
if ( fridge == true ) json.member( "fridge", true );
if ( corpse != NULL ) json.member( "corpse", corpse->id );
if ( owned != -1 ) json.member( "owned", owned );
if ( player_id != -1 ) json.member( "player_id", player_id );
if ( mission_id != -1 ) json.member( "mission_id", mission_id );
if ( ! item_tags.empty() ) {
json.member( "item_tags", item_tags );
}
if ( ! item_vars.empty() ) {
json.member( "item_vars", item_vars );
}
if ( name != type->name ) {
json.member( "name", name );
}
if ( light.luminance != 0 ) {
json.member( "light", int(light.luminance) );
if ( light.width != 0 ) {
json.member( "light_width", int(light.width) );
json.member( "light_dir", int(light.direction) );
}
}
if ( save_contents && contents.size() > 0 ) {
json.member("contents");
json.start_array();
for (int k = 0; k < contents.size(); k++) {
contents[k].serialize(json, false); // no matryoshka dolls
}
json.end_array();
}
json.end_object();
}