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


C++ JsonOut类代码示例

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


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

示例1: serialize

void Messages::serialize( JsonOut &json )
{
    json.member( "player_messages" );
    json.start_object();
    json.member( "messages", player_messages.impl_->messages );
    json.member( "curmes", player_messages.impl_->curmes );
    json.end_object();
}
开发者ID:Catacstone,项目名称:Cataclysm-DDA,代码行数:8,代码来源:messages.cpp

示例2: serialize

////////////////////////////////////////////////////////////////////////////////////////////////////
///// skill.h
void SkillLevel::serialize(JsonOut &json) const
{
    json.start_object();
    json.member("level", level() );
    json.member("exercise", exercise(true) );
    json.member("istraining", isTraining() );
    json.member("lastpracticed", int ( lastPracticed() ) );
    json.end_object();
}
开发者ID:Agnososyk,项目名称:Cataclysm-DDA,代码行数:11,代码来源:savegame_json.cpp

示例3: 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,代码来源:

示例4: serialize

 void serialize( JsonOut &js ) const override {
     js.start_object();
     js.member( "type", "vehicle" );
     js.member( "pos", position() );
     js.member( "part", cur.part );
     if( target() != &cur.veh.parts[ cur.part ].base ) {
         js.member( "idx", find_index( cur, target() ) );
     }
     js.end_object();
 }
开发者ID:Nullsrc,项目名称:Cataclysm-DDA,代码行数:10,代码来源:item_location.cpp

示例5: write_object

static void write_object( JsonIn &jsin, JsonOut &jsout, int depth, bool force_wrap )
{
    jsout.start_object( force_wrap );
    jsin.start_object();
    while( !jsin.end_object() ) {
        std::string name = jsin.get_member_name();
        jsout.member( name );
        format( jsin, jsout, depth );
    }
    jsout.end_object();
}
开发者ID:,项目名称:,代码行数:11,代码来源:

示例6: 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

示例7: serialize

void stomach_contents::serialize( JsonOut &json ) const
{
    json.start_object();
    json.member( "vitamins", vitamins );
    json.member( "vitamins_absorbed", vitamins_absorbed );
    json.member( "calories", calories );
    json.member( "water", ml_to_string( water ) );
    json.member( "max_volume", ml_to_string( max_volume ) );
    json.member( "contents", ml_to_string( contents ) );
    json.member( "last_ate", last_ate );
    json.end_object();
}
开发者ID:Robik81,项目名称:Cataclysm-DDA,代码行数:12,代码来源:stomach.cpp

示例8: serialize

void zone_data::serialize( JsonOut &json ) const
{
    json.start_object();
    json.member( "name", name );
    json.member( "type", type );
    json.member( "invert", invert );
    json.member( "enabled", enabled );
    json.member( "is_vehicle", is_vehicle );
    json.member( "start", start );
    json.member( "end", end );
    get_options().serialize( json );
    json.end_object();
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:13,代码来源:clzones.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: 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

示例11:

void Messages::game_message::serialize( JsonOut &jsout ) const
{
    jsout.start_object();
    jsout.member( "turn", static_cast<int>( turn ) );
    jsout.member( "message", message );
    jsout.member( "count", count );
    jsout.member( "type", static_cast<int>( type ) );
    jsout.end_object();
}
开发者ID:Devanon,项目名称:Cataclysm-DDA,代码行数:9,代码来源:messages.cpp

示例12: format

static void format( JsonIn &jsin, JsonOut &jsout, int depth )
{
    depth++;
    if( jsin.test_array() ) {
        format_collection( jsin, jsout, depth, write_array );
    } else if( jsin.test_object() ) {
        format_collection( jsin, jsout, depth, write_object );
    } else if( jsin.test_string() ) {
        std::string str = jsin.get_string();
        jsout.write( str );
    } else if( jsin.test_number() ) {
        // Have to introspect into the string to distinguish integers from floats.
        // Otherwise they won't serialize correctly.
        const int start_pos = jsin.tell();
        double num = jsin.get_float();
        const int end_pos = jsin.tell();
        std::string str_form = jsin.substr( start_pos, end_pos - start_pos );
        if( str_form.find( '.' ) == std::string::npos ) {
            jsout.write( static_cast<long>( num ) );
        } else {
            // This is QUITE insane, but as far as I can tell there is NO way to configure
            // an ostream to output a float/double meeting two constraints:
            // Always emit a decimal point (and single trailing 0 after a bare decimal point).
            // Don't emit trailing zeroes otherwise.
            std::string double_str = std::to_string( num );
            double_str.erase( double_str.find_last_not_of( '0' ) + 1, std::string::npos );
            if( double_str.back() == '.' ) {
                double_str += "0";
            }
            jsout.write_separator();
            *jsout.get_stream() << double_str;
            jsout.set_need_separator();
        }
        jsin.seek( end_pos );
    } else if( jsin.test_bool() ) {
        bool tf = jsin.get_bool();
        jsout.write( tf );
    } else if( jsin.test_null() ) {
        jsout.write_null();
    } else {
        std::cerr << "Encountered unrecognized json element \"";
        const int start_pos = jsin.tell();
        jsin.skip_value();
        const int end_pos = jsin.tell();
        for( int i = start_pos; i < end_pos; ++i ) {
            jsin.seek( i );
            std::cerr << jsin.peek();
        }
        std::cerr << "\"" << std::endl;
    }
}
开发者ID:,项目名称:,代码行数:51,代码来源:

示例13: 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

示例14: 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

示例15: serialize

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

    json.member("type", "artifact_armor");

    // 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("id", id);
    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);

    // armor data
    json.member("covers", covers);
    json.member("encumber", encumber);
    json.member("coverage", coverage);
    json.member("material_thickness", thickness);
    json.member("env_resist", env_resist);
    json.member("warmth", warmth);
    json.member("storage", storage);
    json.member("power_armor", power_armor);

    // artifact data
    json.member("effects_worn", effects_worn);

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


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