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


C++ JsonIn::end_array方法代码示例

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


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

示例1: load_all_from_json

void DynamicDataLoader::load_all_from_json(JsonIn &jsin)
{
    char ch;
    jsin.eat_whitespace();
    // examine first non-whitespace char
    ch = jsin.peek();
    if (ch == '{') {
        // find type and dispatch single object
        JsonObject jo = jsin.get_object();
        load_object(jo);
        jo.finish();
        // if there's anything else in the file, it's an error.
        jsin.eat_whitespace();
        if (jsin.good()) {
            jsin.error( string_format( "expected single-object file but found '%c'", jsin.peek() ) );
        }
    } else if (ch == '[') {
        jsin.start_array();
        // find type and dispatch each object until array close
        while (!jsin.end_array()) {
            jsin.eat_whitespace();
            ch = jsin.peek();
            if (ch != '{') {
                jsin.error( string_format( "expected array of objects but found '%c', not '{'", ch ) );
            }
            JsonObject jo = jsin.get_object();
            load_object(jo);
            jo.finish();
        }
    } else {
        // not an object or an array?
        jsin.error( string_format( "expected object or array, but found '%c'", ch ) );
    }
}
开发者ID:2birdie,项目名称:Cataclysm-DDA,代码行数:34,代码来源:init.cpp

示例2: load_all_from_json

void DynamicDataLoader::load_all_from_json( JsonIn &jsin, const std::string &src, loading_ui &,
        const std::string &base_path, const std::string &full_path )
{
    if( jsin.test_object() ) {
        // find type and dispatch single object
        JsonObject jo = jsin.get_object();
        load_object( jo, src, base_path, full_path );
        jo.finish();
        // if there's anything else in the file, it's an error.
        jsin.eat_whitespace();
        if( jsin.good() ) {
            jsin.error( string_format( "expected single-object file but found '%c'", jsin.peek() ) );
        }
    } else if( jsin.test_array() ) {
        jsin.start_array();
        // find type and dispatch each object until array close
        while( !jsin.end_array() ) {
            JsonObject jo = jsin.get_object();
            load_object( jo, src, base_path, full_path );
            jo.finish();
        }
    } else {
        // not an object or an array?
        jsin.error( "expected object or array" );
    }
}
开发者ID:Barhandar,项目名称:Cataclysm-DDA,代码行数:26,代码来源:init.cpp

示例3: deserialize

void zone_manager::deserialize( JsonIn &jsin )
{
    zones.clear();

    jsin.start_array();
    while( !jsin.end_array() ) {
        JsonObject jo_zone = jsin.get_object();

        const std::string name = jo_zone.get_string( "name" );
        const std::string type = jo_zone.get_string( "type" );

        const bool invert = jo_zone.get_bool( "invert" );
        const bool enabled = jo_zone.get_bool( "enabled" );

        // Z coords need to have a default value - old saves won't have those
        const int start_x = jo_zone.get_int( "start_x" );
        const int start_y = jo_zone.get_int( "start_y" );
        const int start_z = jo_zone.get_int( "start_z", 0 );
        const int end_x = jo_zone.get_int( "end_x" );
        const int end_y = jo_zone.get_int( "end_y" );
        const int end_z = jo_zone.get_int( "end_z", 0 );

        if( has_type( type ) ) {
            add( name, type, invert, enabled,
                 tripoint( start_x, start_y, start_z ),
                 tripoint( end_x, end_y, end_z ) );
        } else {
            debugmsg( "Invalid zone type: %s", type.c_str() );
        }
    }
}
开发者ID:Mshock777,项目名称:Cataclysm-DDA,代码行数:31,代码来源:clzones.cpp

示例4: load

void NameGenerator::load( JsonIn &jsin )
{
    jsin.start_array();
    while( !jsin.end_array() ) {
        JsonObject json_name = jsin.get_object();
        load_name( json_name );
    }
}
开发者ID:AlecWhite,项目名称:Cataclysm-DDA,代码行数:8,代码来源:name.cpp

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

示例6: load_season_array

void load_season_array( JsonIn &js, C &container, F load_func )
{
    if( js.test_array() ) {
        js.start_array();
        for( auto &season_entry : container ) {
            season_entry = load_func( js );
            js.end_array(); // consume separator
        }
    } else {
        container.fill( load_func( js ) );
    }
}
开发者ID:1942rob,项目名称:Cataclysm-DDA,代码行数:12,代码来源:mapdata.cpp

示例7: deserialize

void auto_pickup::deserialize(JsonIn &jsin)
{
    vRules[(bChar) ? CHARACTER : GLOBAL].clear();

    jsin.start_array();
    while (!jsin.end_array()) {
        JsonObject jo = jsin.get_object();

        const std::string sRule = jo.get_string("rule");
        const bool bActive = jo.get_bool("active");
        const bool bExclude = jo.get_bool("exclude");

        vRules[(bChar) ? CHARACTER : GLOBAL].push_back(cRules(sRule, bActive, bExclude));
    }
}
开发者ID:DearVarun,项目名称:Cataclysm-DDA,代码行数:15,代码来源:auto_pickup.cpp

示例8: load

// The loaded name is one of usage with optional gender.
// The combinations used in names files are as follows.
//
// Backer | (Female|Male|Unisex)
// Given  | (Female|Male)        // unisex names are duplicated in each group
// Family | Unisex
// City
// World
static void load( JsonIn &jsin )
{
    jsin.start_array();

    while( !jsin.end_array() ) {
        JsonObject jo = jsin.get_object();

        // get flags of name.
        const nameFlags type =
            usage_flag( jo.get_string( "usage" ) )
            | gender_flag( jo.get_string( "gender", "" ) );

        // find group type and add name to group
        names[type].push_back( jo.get_string( "name" ) );
    }
}
开发者ID:Barhandar,项目名称:Cataclysm-DDA,代码行数:24,代码来源:name.cpp

示例9: load_all_from_json

void DynamicDataLoader::load_all_from_json(JsonIn &jsin)
{
    char ch;
    std::string type = "";
    jsin.eat_whitespace();
    // examine first non-whitespace char
    ch = jsin.peek();
    if (ch == '{') {
        // find type and dispatch single object
        JsonObject jo = jsin.get_object();
        load_object(jo);
        jo.finish();
        // if there's anything else in the file, it's an error.
        jsin.eat_whitespace();
        if (jsin.good()) {
            std::stringstream err;
            err << jsin.line_number() << ": ";
            err << "expected single-object file but found '";
            err << jsin.peek() << "'";
            throw err.str();
        }
    } else if (ch == '[') {
        jsin.start_array();
        // find type and dispatch each object until array close
        while (!jsin.end_array()) {
            jsin.eat_whitespace();
            ch = jsin.peek();
            if (ch != '{') {
                std::stringstream err;
                err << jsin.line_number() << ": ";
                err << "expected array of objects but found '";
                err << ch << "', not '{'";
                throw err.str();
            }
            JsonObject jo = jsin.get_object();
            load_object(jo);
            jo.finish();
        }
    } else {
        // not an object or an array?
        std::stringstream err;
        err << jsin.line_number() << ": ";
        err << "expected object or array, but found '" << ch << "'";
        throw err.str();
    }
}
开发者ID:Kingz62,项目名称:Cataclysm-DDA,代码行数:46,代码来源:init.cpp

示例10: deserialize

void safemode::deserialize( JsonIn &jsin )
{
    auto &temp_rules = ( is_character ) ? character_rules : global_rules;
    temp_rules.clear();

    jsin.start_array();
    while( !jsin.end_array() ) {
        JsonObject jo = jsin.get_object();

        const std::string rule = jo.get_string( "rule" );
        const bool active = jo.get_bool( "active" );
        const bool whitelist = jo.get_bool( "whitelist" );
        const Creature::Attitude attitude = ( Creature::Attitude ) jo.get_int( "attitude" );
        const int proximity = jo.get_int( "proximity" );

        temp_rules.push_back(
            rules_class( rule, active, whitelist, attitude, proximity )
        );
    }
}
开发者ID:Nukesor,项目名称:Cataclysm-DDA,代码行数:20,代码来源:safemode_ui.cpp

示例11: deserialize

void color_manager::deserialize( JsonIn &jsin )
{
    jsin.start_array();
    while( !jsin.end_array() ) {
        JsonObject joColors = jsin.get_object();

        const std::string name = joColors.get_string( "name" );
        const std::string name_custom = joColors.get_string( "custom" );
        const std::string name_invert_custom = joColors.get_string( "invertcustom" );

        color_id id = name_to_id( name );
        auto &entry = color_array[id];

        if( !name_custom.empty() ) {
            entry.name_custom = name_custom;
        }

        if( !name_invert_custom.empty() ) {
            entry.name_invert_custom = name_invert_custom;
        }
    }
}
开发者ID:AreasAside,项目名称:Cataclysm-DDA,代码行数:22,代码来源:color.cpp


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