• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ catajson类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: set_material_from_json

void Item_factory::set_material_from_json(Item_tag new_id, catajson mat_list){
    //If the value isn't found, just return a group of null materials
    std::string material_list[2] = {"null", "null"};

    if (mat_list.is_array())
    {
        if (mat_list.has(2))
        {
            debugmsg("Too many materials provided for item %s", new_id.c_str());
        }
        material_list[0] = mat_list.get(0).as_string();
        material_list[1] = mat_list.get(1).as_string();
    }
    else
    {
        material_list[0] = mat_list.as_string();
    }

    itype* temp = find_template(new_id);
    temp->m1 = material_list[0];
    temp->m2 = material_list[1];
}
开发者ID:NecroBanana,项目名称:Cataclysm-DDA,代码行数:22,代码来源:item_factory.cpp


示例2: throw

void snippet_library::load() throw (std::string)
{
    catajson snippetRaw("data/raw/snippets.json");

    if(!json_good())
    	throw (std::string)"Could not read data/raw/snippets.json";

    catajson snippetList = snippetRaw.get("snippets");
    for( snippetList.set_begin(); snippetList.has_curr(); snippetList.next() )
    {
        const catajson curr = snippetList.curr();
        // required fields
        const std::string category = curr.get("category").as_string();
        const std::string text = curr.get("text").as_string();
        const int hash = djb2_hash( (const unsigned char*)text.c_str() );

        snippets.insert( std::pair<int, std::string>(hash, text) );
        categories.insert( std::pair<std::string, int>(category, hash) );
    }
    if(!json_good())
        throw (std::string)"There was an error reading data/raw/snippets.json";
}
开发者ID:TarikMechEng,项目名称:Cataclysm-DDA,代码行数:22,代码来源:text_snippets.cpp


示例3: tags_from_json

void Item_factory::tags_from_json(catajson tag_list, std::set<std::string> &tags)
{
    if (tag_list.is_array())
    {
        for (tag_list.set_begin(); tag_list.has_curr(); tag_list.next())
        {
            tags.insert( tag_list.curr().as_string() );
        }
    }
    else
    {
        //we should have gotten a string, if not an array, and catajson will do error checking
        tags.insert( tag_list.as_string() );
    }
}
开发者ID:NecroBanana,项目名称:Cataclysm-DDA,代码行数:15,代码来源:item_factory.cpp


示例4: set_flag_by_string

unsigned Item_factory::flags_from_json(catajson flag_list, std::string flag_type){
    //If none is found, just use the standard none action
    unsigned flag = 0;
    //Otherwise, grab the right label to look for
    if (flag_list.is_array())
    {
        for (flag_list.set_begin(); flag_list.has_curr(); flag_list.next())
        {
            set_flag_by_string(flag, flag_list.curr().as_string(), flag_type);
        }
    }
    else
    {
        //we should have gotten a string, if not an array, and catajson will do error checking
        set_flag_by_string(flag, flag_list.as_string(), flag_type);
    }
    return flag;
}
开发者ID:NecroBanana,项目名称:Cataclysm-DDA,代码行数:18,代码来源:item_factory.cpp


示例5: is_mod_target

bool Item_factory::is_mod_target(catajson targets, std::string weapon){
    //If none is found, just use the standard none action
    unsigned is_included = false;
    //Otherwise, grab the right label to look for
    if (targets.is_array())
    {
        for (targets.set_begin(); targets.has_curr() && !is_included; targets.next())
        {
            if(targets.curr().as_string() == weapon){
              is_included=true;
            }
        }
    }
    else
    {
        if(targets.as_string() == weapon){
          is_included=true;
        }
    }
    return is_included;
}
开发者ID:NecroBanana,项目名称:Cataclysm-DDA,代码行数:21,代码来源:item_factory.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ccBBox类代码示例发布时间:2022-05-31
下一篇:
C++ camera类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap