当前位置: 首页>>代码示例>>C++>>正文


C++ JsonOut::start_array方法代码示例

本文整理汇总了C++中JsonOut::start_array方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonOut::start_array方法的具体用法?C++ JsonOut::start_array怎么用?C++ JsonOut::start_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsonOut的用法示例。


在下文中一共展示了JsonOut::start_array方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: json_save_invcache

/*
 * Save invlet cache
 */
void inventory::json_save_invcache(JsonOut &json) const
{
    json.start_array();
    for( std::map<std::string, std::vector<char> >::const_iterator invlet_id =  invlet_cache.begin(); invlet_id != invlet_cache.end(); ++invlet_id ) {
        json.start_object();
        json.member( invlet_id->first );
        json.start_array();
        for( std::vector<char>::const_iterator sym = invlet_id->second.begin();
                sym != invlet_id->second.end(); ++sym ) {
            json.write( int(*sym) );
        }
        json.end_array();
        json.end_object();
    }
    json.end_array();
}
开发者ID:Agnososyk,项目名称:Cataclysm-DDA,代码行数:19,代码来源:savegame_json.cpp

示例2: serialize

void mission::serialize(JsonOut &json) const
{
    json.start_object();

    json.member("type_id", type == NULL ? -1 : (int)type->id);
    json.member("description", description);
    json.member("failed", failed);
    json.member("value", value);
    json.member("reward", reward);
    json.member("uid", uid);

    json.member("target");
    json.start_array();
    json.write(target.x);
    json.write(target.y);
    json.end_array();

    json.member("count", count);
    json.member("deadline", deadline);
    json.member("npc_id", npc_id);
    json.member("good_fac_id", good_fac_id);
    json.member("bad_fac_id", bad_fac_id);
    json.member("step", step);
    json.member("follow_up", (int)follow_up);

    json.end_object();
}
开发者ID:Agnososyk,项目名称:Cataclysm-DDA,代码行数:27,代码来源:savegame_json.cpp

示例3: serialize

void zone_manager::serialize( JsonOut &json ) const
{
    json.start_array();
    for( auto &elem : zones ) {
        json.start_object();

        json.member( "name", elem.get_name() );
        json.member( "type", elem.get_type() );
        json.member( "invert", elem.get_invert() );
        json.member( "enabled", elem.get_enabled() );

        tripoint start = elem.get_start_point();
        tripoint end = elem.get_end_point();

        json.member( "start_x", start.x );
        json.member( "start_y", start.y );
        json.member( "start_z", start.z );
        json.member( "end_x", end.x );
        json.member( "end_y", end.y );
        json.member( "end_z", end.z );

        json.end_object();
    }

    json.end_array();
}
开发者ID:Mshock777,项目名称:Cataclysm-DDA,代码行数:26,代码来源:clzones.cpp

示例4: write_array

static void write_array( JsonIn &jsin, JsonOut &jsout, int depth, bool force_wrap )
{
    jsout.start_array( force_wrap );
    jsin.start_array();
    while( !jsin.end_array() ) {
        format( jsin, jsout, depth );
    }
    jsout.end_array();
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例5: json_save_items

/*
 * save all items. Just this->items, invlet cache saved seperately
 */
void inventory::json_save_items(JsonOut &json) const
{
    json.start_array();
    for (invstack::const_iterator iter = items.begin(); iter != items.end(); ++iter) {
        for (std::list<item>::const_iterator stack_iter = iter->begin();
             stack_iter != iter->end();
             ++stack_iter)
        {
            stack_iter->serialize(json, true);
        }
    }
    json.end_array();
}
开发者ID:Agnososyk,项目名称:Cataclysm-DDA,代码行数:16,代码来源:savegame_json.cpp

示例6: serialize

void auto_pickup::serialize(JsonOut &json) const
{
    json.start_array();

    for( auto &elem : vRules[( bChar ) ? CHARACTER_TAB : GLOBAL_TAB] ) {
        json.start_object();

        json.member( "rule", elem.sRule );
        json.member( "active", elem.bActive );
        json.member( "exclude", elem.bExclude );

        json.end_object();
    }

    json.end_array();
}
开发者ID:NickGrease,项目名称:Cataclysm-DDA,代码行数:16,代码来源:auto_pickup.cpp

示例7: serialize

void color_manager::serialize( JsonOut &json ) const
{
    json.start_array();
    for( auto &entry : color_array ) {
        if( !entry.name_custom.empty() || !entry.name_invert_custom.empty() ) {
            json.start_object();

            json.member( "name", id_to_name( entry.col_id ) );
            json.member( "custom", entry.name_custom );
            json.member( "invertcustom", entry.name_invert_custom );

            json.end_object();
        }
    }

    json.end_array();
}
开发者ID:AreasAside,项目名称:Cataclysm-DDA,代码行数:17,代码来源:color.cpp

示例8: 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("materials");
    json.start_array();
    for (auto mat : materials) {
        json.write(mat);
    }
    json.end_array();
    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();
}
开发者ID:Suseika,项目名称:Cataclysm-DDA,代码行数:45,代码来源:artifact.cpp

示例9: 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();
}
开发者ID:Nukesor,项目名称:Cataclysm-DDA,代码行数:19,代码来源:safemode_ui.cpp

示例10: 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();
}
开发者ID:Agnososyk,项目名称:Cataclysm-DDA,代码行数:86,代码来源:savegame_json.cpp

示例11: 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();
}
开发者ID:NeverGoWest,项目名称:Cataclysm-DDA,代码行数:75,代码来源:savegame_json.cpp


注:本文中的JsonOut::start_array方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。