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


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

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


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

示例1: load_item_group

Group_tag item_group::load_item_group( JsonIn& stream, const std::string& default_subtype )
{
    if( stream.test_string() ) {
        return stream.get_string();
    } else if( stream.test_object() ) {
        const Group_tag group = get_unique_group_id();

        JsonObject jo = stream.get_object();
        const std::string subtype = jo.get_string( "subtype", default_subtype );
        item_controller->load_item_group( jo, group, subtype );

        return group;
    } else if( stream.test_array() ) {
        const Group_tag group = get_unique_group_id();

        JsonArray jarr = stream.get_array();
        // load_item_group needs a bool, invalid subtypes are unexpected and most likely errors
        // from the caller of this function.
        if( default_subtype != "collection" && default_subtype != "distribution" ) {
            debugmsg( "invalid subtype for item group: %s", default_subtype.c_str() );
        }
        item_controller->load_item_group( jarr, group, default_subtype == "collection" );

        return group;
    } else {
        stream.error( "invalid item group, must be string (group id) or object/array (the group data)" );
        // stream.error always throws, this is here to prevent a warning
        return Group_tag{};
    }
}
开发者ID:Bubbadoo,项目名称:Cataclysm-DDA,代码行数:30,代码来源:item_group.cpp

示例2: 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 );
        bool override_wrap = false;
        if( name == "rows" || name == "blueprint" ) {
            // Introspect into the row, if it has more than one element, force it to wrap.
            int in_start_pos = jsin.tell();
            bool ate_seperator = jsin.get_ate_separator();
            {
                JsonArray arr = jsin.get_array();
                if( arr.size() > 1 ) {
                    override_wrap = true;
                }
            }
            jsin.seek( in_start_pos );
            jsin.set_ate_separator( ate_seperator );
        }
        format( jsin, jsout, depth, override_wrap );
    }
    jsout.end_object();
}
开发者ID:CleverRaven,项目名称:Cataclysm-DDA,代码行数:25,代码来源:format.cpp

示例3: load_trait_group

Trait_group_tag trait_group::load_trait_group( JsonIn &stream, const std::string &default_subtype )
{
    if( stream.test_string() ) {
        return Trait_group_tag( stream.get_string() );
    } else if( stream.test_object() ) {
        const Trait_group_tag group = get_unique_trait_group_id();

        JsonObject jo = stream.get_object();
        const std::string subtype = jo.get_string( "subtype", default_subtype );

        mutation_branch::load_trait_group( jo, group, subtype );

        return group;
    } else if( stream.test_array() ) {
        const Trait_group_tag group = get_unique_trait_group_id();

        JsonArray jarr = stream.get_array();
        if( default_subtype != "collection" && default_subtype != "distribution" ) {
            jarr.throw_error( "invalid subtype for trait group" );
        }

        mutation_branch::load_trait_group( jarr, group, default_subtype == "collection" );
        return group;
    } else {
        stream.error( "invalid trait group, must be string (group id) or object/array (the group data)" );
        return Trait_group_tag{};
    }
}
开发者ID:Reclusive-reptile,项目名称:Cataclysm-DDA,代码行数:28,代码来源:trait_group.cpp

示例4: get_next

 profession::itypedec get_next( JsonIn &jin ) const {
     // either a plain item type id string, or an array with item type id
     // and as second entry the item description.
     if( jin.test_string() ) {
         return profession::itypedec( jin.get_string(), "" );
     }
     JsonArray jarr = jin.get_array();
     const auto id = jarr.get_string( 0 );
     const auto s = jarr.get_string( 1 );
     const auto snippet = _( s.c_str() );
     return profession::itypedec( id, snippet );
 }
开发者ID:AreasAside,项目名称:Cataclysm-DDA,代码行数:12,代码来源:profession.cpp

示例5: json_load_items

void inventory::json_load_items(JsonIn &jsin)
{
    try {
        JsonArray ja = jsin.get_array();
        while ( ja.has_more() ) {
            JsonObject jo = ja.next_object();
            add_item(item( jo ), false, false);
        }
    } catch (std::string& jsonerr) {
         debugmsg("bad inventory json:\n%s", jsonerr.c_str() );
    }
}
开发者ID:Agnososyk,项目名称:Cataclysm-DDA,代码行数:12,代码来源:savegame_json.cpp

示例6: json_load_invcache

/*
 * Invlet cache: player specific, thus not wrapped in inventory::json_load/save
 */
void inventory::json_load_invcache(JsonIn &jsin)
{
    try {
        JsonArray ja = jsin.get_array();
        while ( ja.has_more() ) {
            JsonObject jo = ja.next_object();
            std::set<std::string> members = jo.get_member_names();
            for (std::set<std::string>::iterator it = members.begin();
                    it != members.end(); ++it) {
                std::vector<char> vect;
                JsonArray pvect = jo.get_array(*it);
                while ( pvect.has_more() ) {
                    vect.push_back( pvect.next_int() );
                }
                invlet_cache[*it] = vect;
            }
        }
    } catch (std::string jsonerr) {
        debugmsg("bad invcache json:\n%s", jsonerr.c_str() );
    }
}
开发者ID:Agnososyk,项目名称:Cataclysm-DDA,代码行数:24,代码来源:savegame_json.cpp


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