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


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

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


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

示例1: deserialize

/*
 * vehicle_part
 */
void vehicle_part::deserialize(JsonIn &jsin)
{
    JsonObject data = jsin.get_object();
    int intpid;
    std::string pid;
    if ( data.read("id_enum", intpid) && intpid < 74 ) {
        pid = legacy_vpart_id[intpid];
    } else {
        data.read("id",pid);
    }
    // if we don't know what type of part it is, it'll cause problems later.
    if (vehicle_part_types.find(pid) == vehicle_part_types.end()) {
        if (pid == "wheel_underbody") {
            pid = "wheel_wide";
        } else {
            throw (std::string)"bad vehicle part, id: %s" + pid;
        }
    }
    setid(pid);
    data.read("mount_dx", mount_dx);
    data.read("mount_dy", mount_dy);
    data.read("hp", hp );
    data.read("amount", amount );
    data.read("blood", blood );
    data.read("bigness", bigness );
    data.read( "flags", flags );
    data.read( "passenger_id", passenger_id );
    data.read("items", items);
}
开发者ID:Agnososyk,项目名称:Cataclysm-DDA,代码行数:32,代码来源:savegame_json.cpp

示例2: deserialize

void zone_data::deserialize( JsonIn &jsin )
{
    JsonObject data = jsin.get_object();
    data.read( "name", name );
    data.read( "type", type );
    data.read( "invert", invert );
    data.read( "enabled", enabled );
    //Legacy support
    if( data.has_member( "is_vehicle" ) ) {
        data.read( "is_vehicle", is_vehicle );
    } else {
        is_vehicle = false;
    }
    //Legacy support
    if( data.has_member( "start_x" ) ) {
        tripoint s;
        tripoint e;
        data.read( "start_x", s.x );
        data.read( "start_y", s.y );
        data.read( "start_z", s.z );
        data.read( "end_x", e.x );
        data.read( "end_y", e.y );
        data.read( "end_z", e.z );
        start = s;
        end = e;
    } else {
        data.read( "start", start );
        data.read( "end", end );
    }
    auto new_options = zone_options::create( type );
    new_options->deserialize( data );
    options = new_options;
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:33,代码来源:clzones.cpp

示例3: load

void unfold_vehicle_iuse::load( JsonObject &obj )
{
    obj.read( "vehicle_name", vehicle_name );
    obj.read( "unfold_msg", unfold_msg );
    obj.read( "moves", moves );
    obj.read( "tools_needed", tools_needed );
}
开发者ID:reverieAlice,项目名称:Cataclysm-DDA,代码行数:7,代码来源:iuse_actor.cpp

示例4: load_mutation_social_mods

static social_modifiers load_mutation_social_mods( JsonObject &jo )
{
    social_modifiers ret;
    jo.read( "lie", ret.lie );
    jo.read( "persuade", ret.persuade );
    jo.read( "intimidate", ret.intimidate );
    return ret;
}
开发者ID:ymber,项目名称:Cataclysm-DDA,代码行数:8,代码来源:mutation_data.cpp

示例5: deserialize

void Messages::deserialize( JsonObject &json )
{
    if( json.has_member( "player_messages" ) ) {
        JsonObject obj = json.get_object( "player_messages" );
        obj.read( "messages", player_messages.messages );
        obj.read( "curmes", player_messages.curmes );
    }
}
开发者ID:Devanon,项目名称:Cataclysm-DDA,代码行数:8,代码来源:messages.cpp

示例6: load

void json_flag::load( JsonObject &jo )
{
    auto id = jo.get_string( "id" );
    auto &f = json_flags_all.emplace( id, json_flag( id ) ).first->second;

    jo.read( "info", f.info_ );
    jo.read( "conflicts", f.conflicts_ );
    jo.read( "inherit", f.inherit_ );
}
开发者ID:AreasAside,项目名称:Cataclysm-DDA,代码行数:9,代码来源:flag.cpp

示例7: load_mat_burn_data

mat_burn_data load_mat_burn_data( JsonObject &jsobj )
{
    mat_burn_data bd;
    assign( jsobj, "immune", bd.immune );
    assign( jsobj, "volume_penalty", bd.volume_per_turn );
    jsobj.read( "fuel", bd.fuel );
    jsobj.read( "smoke", bd.smoke );
    jsobj.read( "burn", bd.burn );
    return bd;
}
开发者ID:Barhandar,项目名称:Cataclysm-DDA,代码行数:10,代码来源:material.cpp

示例8: load_mat_burn_data

mat_burn_data load_mat_burn_data( JsonObject &jsobj )
{
    mat_burn_data bd;
    assign( jsobj, "immune", bd.immune );
    assign( jsobj, "chance", bd.chance_in_volume );
    jsobj.read( "fuel", bd.fuel );
    jsobj.read( "smoke", bd.smoke );
    jsobj.read( "burn", bd.burn );
    return bd;
}
开发者ID:CrAzYPiLoT-SS13,项目名称:Cataclysm-DDA,代码行数:10,代码来源:material.cpp

示例9: deserialize

void Messages::deserialize( JsonObject &json )
{
    if (!json.has_member("player_messages")) {
        return;
    }
    
    JsonObject obj = json.get_object( "player_messages" );
    obj.read( "messages", player_messages.impl_->messages );
    obj.read( "curmes", player_messages.impl_->curmes );
}
开发者ID:Catacstone,项目名称:Cataclysm-DDA,代码行数:10,代码来源:messages.cpp

示例10: load_emit

void emit::load_emit( JsonObject &jo )
{
    emit et;

    et.id_ = emit_id( jo.get_string( "id" ) );
    et.field_name = jo.get_string( "field" );

    jo.read( "density", et.density_ );
    jo.read( "qty", et.qty_ );
    jo.read( "chance", et.chance_ );

    emits_all[ et.id_ ] = et;
}
开发者ID:KrazyTheFox,项目名称:Cataclysm-DDA,代码行数:13,代码来源:emit.cpp

示例11: load_monster_adjustment

void load_monster_adjustment( JsonObject &jsobj )
{
    monster_adjustment adj;
    adj.species = species_id( jsobj.get_string( "species" ) );
    if( jsobj.has_member( "stat" ) ) {
        JsonObject stat = jsobj.get_object( "stat" );
        stat.read( "name", adj.stat );
        stat.read( "modifier", adj.stat_adjust );
    }
    if( jsobj.has_member( "flag" ) ) {
        JsonObject flag = jsobj.get_object( "flag" );
        flag.read( "name", adj.flag );
        flag.read( "value", adj.flag_val );
    }
    if( jsobj.has_member( "special" ) ) {
        jsobj.read( "special", adj.special );
    }
    adjustments.push_back( adj );
}
开发者ID:vidarsk,项目名称:Cataclysm-DDA,代码行数:19,代码来源:monstergenerator.cpp

示例12: deserialize

void it_artifact_armor::deserialize(JsonObject &jo)
{
    id = jo.get_string("id");
    name = jo.get_string("name");
    description = jo.get_string("description");
    sym = jo.get_int("sym");
    color = int_to_color(jo.get_int("color"));
    price = jo.get_int("price");
    // LEGACY: Since it seems artifacts get serialized out to disk, and they're
    // dynamic, we need to allow for them to be read from disk for, oh, I guess
    // quite some time. Loading and saving once will write things out as a JSON
    // array.
    if (jo.has_string("m1")) {
        materials.push_back(jo.get_string("m1"));
    }
    if (jo.has_string("m2")) {
        materials.push_back(jo.get_string("m2"));
    }
    // Assumption, perhaps dangerous, that we won't wind up with m1 and m2 and
    // a materials array in our serialized objects at the same time.
    if (jo.has_array("materials")) {
        JsonArray jarr = jo.get_array("materials");
        for (int i = 0; i < jarr.size(); ++i) {
            materials.push_back(jarr.get_string(i));
        }
    }
    if (materials.size() == 0) {
        // I don't think we need this, but a lot of code seems to want at least
        // one material and I'm not sure I found every single corner case.
        materials.push_back("null");
    }
    volume = jo.get_int("volume");
    weight = jo.get_int("weight");
    melee_dam = jo.get_int("melee_dam");
    melee_cut = jo.get_int("melee_cut");
    m_to_hit = jo.get_int("m_to_hit");
    item_tags = jo.get_tags("item_flags");

    jo.read( "covers", covers);
    encumber = jo.get_int("encumber");
    coverage = jo.get_int("coverage");
    thickness = jo.get_int("material_thickness");
    env_resist = jo.get_int("env_resist");
    warmth = jo.get_int("warmth");
    storage = jo.get_int("storage");
    power_armor = jo.get_bool("power_armor");

    JsonArray ja = jo.get_array("effects_worn");
    while (ja.has_more()) {
        effects_worn.push_back((art_effect_passive)ja.next_int());
    }
}
开发者ID:Suseika,项目名称:Cataclysm-DDA,代码行数:52,代码来源:artifact.cpp

示例13: deserialize

void stomach_contents::deserialize( JsonIn &json )
{
    JsonObject jo = json.get_object();
    jo.read( "vitamins", vitamins );
    jo.read( "vitamins_absorbed", vitamins_absorbed );
    jo.read( "calories", calories );
    std::string str;
    jo.read( "water", str );
    water = string_to_ml( str );
    jo.read( "max_volume", str );
    max_volume = string_to_ml( str );
    jo.read( "contents", str );
    contents = string_to_ml( str );
    jo.read( "last_ate", last_ate );
}
开发者ID:Robik81,项目名称:Cataclysm-DDA,代码行数:15,代码来源:stomach.cpp

示例14: load_mutation_attack

static mut_attack load_mutation_attack( JsonObject &jo )
{
    mut_attack ret;
    jo.read( "attack_text_u", ret.attack_text_u );
    jo.read( "attack_text_npc", ret.attack_text_npc );
    jo.read( "required_mutations", ret.required_mutations );
    jo.read( "blocker_mutations", ret.blocker_mutations );
    jo.read( "hardcoded_effect", ret.hardcoded_effect );

    if( jo.has_string( "body_part" ) ) {
        ret.bp = get_body_part_token( jo.get_string( "body_part" ) );
    }

    jo.read( "chance", ret.chance );

    if( jo.has_array( "base_damage" ) ) {
        JsonArray jo_dam = jo.get_array( "base_damage" );
        ret.base_damage = load_damage_instance( jo_dam );
    } else if( jo.has_object( "base_damage" ) ) {
        JsonObject jo_dam = jo.get_object( "base_damage" );
        ret.base_damage = load_damage_instance( jo_dam );
    }

    if( jo.has_array( "strength_damage" ) ) {
        JsonArray jo_dam = jo.get_array( "strength_damage" );
        ret.strength_damage = load_damage_instance( jo_dam );
    } else if( jo.has_object( "strength_damage" ) ) {
        JsonObject jo_dam = jo.get_object( "strength_damage" );
        ret.strength_damage = load_damage_instance( jo_dam );
    }

    if( ret.attack_text_u.empty() || ret.attack_text_npc.empty() ) {
        jo.throw_error( "Attack message unset" );
    }

    if( !ret.hardcoded_effect && ret.base_damage.empty() && ret.strength_damage.empty() ) {
        jo.throw_error( "Damage unset" );
    } else if( ret.hardcoded_effect && ( !ret.base_damage.empty() || !ret.strength_damage.empty() ) ) {
        jo.throw_error( "Damage and hardcoded effect are both set (must be one, not both)" );
    }

    if( ret.chance <= 0 ) {
        jo.throw_error( "Chance of procing must be set and positive" );
    }

    return ret;
}
开发者ID:ymber,项目名称:Cataclysm-DDA,代码行数:47,代码来源:mutation_data.cpp

示例15: deserialize

void player_activity::deserialize(JsonIn &jsin)
{
    JsonObject data = jsin.get_object();
    int tmptype;
    int tmpinv;
    if ( !data.read( "type", tmptype ) || type >= NUM_ACTIVITIES ) {
        debugmsg( "Bad activity data:\n%s", data.str().c_str() );
    }
    type = activity_type(tmptype);
    data.read( "moves_left", moves_left );
    data.read( "index", index );
    data.read( "invlet", tmpinv );
    invlet = (char)tmpinv;
    data.read( "name", name );
    data.read( "placement", placement );
    values = data.get_int_array("values");
    str_values = data.get_string_array("str_values");
}
开发者ID:NeverGoWest,项目名称:Cataclysm-DDA,代码行数:18,代码来源:savegame_json.cpp


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