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


C++ JsonObject::line_number方法代码示例

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


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

示例1: load_object

// copypasta: init.cpp
void load_object(JsonObject &jo)
{
    std::string type = jo.get_string("type");
    if ( ! jo.has_string("type") )
    {
        std::stringstream err;
        err << jo.line_number() << ": ";
        err << "JSON object has no type";
        throw err.str();
    }
}
开发者ID:Agnososyk,项目名称:Cataclysm-DDA,代码行数:12,代码来源:chkjson.cpp

示例2: load_object

void DynamicDataLoader::load_object(JsonObject &jo)
{
    std::string type = jo.get_string("type");
    t_type_function_map::iterator it = type_function_map.find(type);
    if (it == type_function_map.end()) {
        std::stringstream err;
        err << jo.line_number() << ": ";
        err << "unrecognized JSON object, type: \"" << type << "\"";
        throw err.str();
    }
    (*it->second)(jo);
}
开发者ID:KA101,项目名称:Cataclysm-DDA,代码行数:12,代码来源:init.cpp

示例3: load_object

void load_object(JsonObject &jo)
{
    std::string type = jo.get_string("type");
    if (type_function_map.find(type) != type_function_map.end())
    {
        (*type_function_map[type])(jo);
    } else {
        std::stringstream err;
        err << jo.line_number() << ": ";
        err << "unrecognized JSON object, type: \"" << type << "\"";
        throw err.str();
    }
}
开发者ID:duskgao,项目名称:Cataclysm-DDA,代码行数:13,代码来源:init.cpp

示例4: load_object

void load_object(JsonObject &jo)
{
    std::string type = jo.get_string("type");
    if (type == "material") { material_type::load_material(jo);}
    else if (type == "bionic") { load_bionic(jo); }
    else if (type == "profession") { profession::load_profession(jo); }
    else if (type == "skill") { Skill::load_skill(jo); }
    else if (type == "dream") { load_dream(jo); }
    else if (type == "mutation") { load_mutation(jo); }
    else if (type == "snippet") { SNIPPET.load_snippet(jo); }
    else if (type == "item_group") { item_controller->load_item_group(jo); }
    else if (type == "recipe_category") { load_recipe_category(jo); }
    else if (type == "recipe") { load_recipe(jo); }
    else {
        std::stringstream err;
        err << jo.line_number() << ": ";
        err << "unrecognized JSON object, type: \"" << type << "\"";
        throw err.str();
    }
}
开发者ID:AnderHammer,项目名称:Cataclysm-DDA,代码行数:20,代码来源:init.cpp

示例5: load_artifacts_from_ifstream

void load_artifacts_from_ifstream(std::ifstream &f)
{
    // read and create artifacts from json array in artifacts.gsav
    JsonIn artifact_json(f);
    artifact_json.start_array();
    while (!artifact_json.end_array()) {
        JsonObject jo = artifact_json.get_object();
        std::string type = jo.get_string("type");
        std::string id = jo.get_string("id");
        if (type == "artifact_tool") {
            it_artifact_tool *art = new it_artifact_tool(jo);
            item_controller->add_item_type( art );
        } else if (type == "artifact_armor") {
            it_artifact_armor *art = new it_artifact_armor(jo);
            item_controller->add_item_type( art );
        } else {
            throw jo.line_number() + ": unrecognized artifact type.";
        }
    }
}
开发者ID:Suseika,项目名称:Cataclysm-DDA,代码行数:20,代码来源:artifact.cpp

示例6: load_item_group

// Load an item group from JSON
void Item_factory::load_item_group(JsonObject &jsobj)
{
    Item_tag group_id = jsobj.get_string("id");
    Item_group *current_group = new Item_group(group_id);
    m_template_groups[group_id] = current_group;

    JsonArray items = jsobj.get_array("items");
    while (items.has_more()) {
        JsonArray pair = items.next_array();
        current_group->add_entry(pair.get_string(0), pair.get_int(1));
    }

    JsonArray groups = jsobj.get_array("groups");
    while (groups.has_more()) {
        JsonArray pair = groups.next_array();
        std::string name = pair.get_string(0);
        int frequency = pair.get_int(1);
        // we had better have loaded it already!
        if (m_template_groups.find(name) == m_template_groups.end()) {
            throw jsobj.line_number() + ": unrecognized group name: " + name;
        }
        current_group->add_group(m_template_groups[name], frequency);
    }
}
开发者ID:nickasummers,项目名称:Cataclysm-DDA,代码行数:25,代码来源:item_factory.cpp

示例7: load_artifacts_from_ifstream

void load_artifacts_from_ifstream(std::ifstream &f, itypemap &itypes)
{
    // delete current artefact ids
    artifact_itype_ids.clear();
    // read and create artifacts from json array in artifacts.gsav
    JsonIn artifact_json(f);
    artifact_json.start_array();
    while (!artifact_json.end_array()) {
        JsonObject jo = artifact_json.get_object();
        std::string type = jo.get_string("type");
        std::string id = jo.get_string("id");
        if (type == "artifact_tool") {
            it_artifact_tool *art = new it_artifact_tool(jo);
            itypes[id] = art;
            artifact_itype_ids.push_back(id);
        } else if (type == "artifact_armor") {
            it_artifact_armor *art = new it_artifact_armor(jo);
            itypes[id] = art;
            artifact_itype_ids.push_back(id);
        } else {
            throw jo.line_number() + ": unrecognized artifact type.";
        }
    }
}
开发者ID:Hadesfire27,项目名称:Cataclysm-DDA,代码行数:24,代码来源:artifact.cpp


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