本文整理汇总了C++中dynamicdataloader::deferred_json::emplace_back方法的典型用法代码示例。如果您正苦于以下问题:C++ deferred_json::emplace_back方法的具体用法?C++ deferred_json::emplace_back怎么用?C++ deferred_json::emplace_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dynamicdataloader::deferred_json
的用法示例。
在下文中一共展示了deferred_json::emplace_back方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
recipe &recipe_dictionary::load( JsonObject &jo, const std::string &src,
std::map<std::string, recipe> &dest )
{
recipe r;
// defer entries dependent upon as-yet unparsed definitions
if( jo.has_string( "copy-from" ) ) {
auto base = jo.get_string( "copy-from" );
if( !dest.count( base ) ) {
deferred.emplace_back( jo.str(), src );
return null_recipe;
}
r = dest[ base ];
}
r.load( jo, src );
dest[ r.ident() ] = std::move( r );
return dest[ r.ident() ];
}
示例2: load
/**
* Reads in a vehicle part from a JsonObject.
*/
void vpart_info::load( JsonObject &jo, const std::string &src )
{
vpart_info def;
if( jo.has_string( "copy-from" ) ) {
auto const base = vpart_info_all.find( vpart_id( jo.get_string( "copy-from" ) ) );
auto const ab = abstract_parts.find( vpart_id( jo.get_string( "copy-from" ) ) );
if( base != vpart_info_all.end() ) {
def = base->second;
} else if( ab != abstract_parts.end() ) {
def = ab->second;
} else {
deferred.emplace_back( jo.str(), src );
return;
}
}
if( jo.has_string( "abstract" ) ) {
def.id = vpart_id( jo.get_string( "abstract" ) );
} else {
def.id = vpart_id( jo.get_string( "id" ) );
}
assign( jo, "name", def.name_ );
assign( jo, "item", def.item );
assign( jo, "location", def.location );
assign( jo, "durability", def.durability );
assign( jo, "damage_modifier", def.dmg_mod );
assign( jo, "power", def.power );
assign( jo, "epower", def.epower );
assign( jo, "fuel_type", def.fuel_type );
assign( jo, "default_ammo", def.default_ammo );
assign( jo, "folded_volume", def.folded_volume );
assign( jo, "size", def.size );
assign( jo, "difficulty", def.difficulty );
assign( jo, "bonus", def.bonus );
assign( jo, "flags", def.flags );
if( jo.has_member( "requirements" ) ) {
auto reqs = jo.get_object( "requirements" );
parse_vp_reqs( reqs, def.id.str(), "install", def.install_reqs, def.install_skills, def.install_moves );
parse_vp_reqs( reqs, def.id.str(), "removal", def.removal_reqs, def.removal_skills, def.removal_moves );
parse_vp_reqs( reqs, def.id.str(), "repair", def.repair_reqs, def.repair_skills, def.repair_moves );
def.legacy = false;
}
if( jo.has_member( "symbol" ) ) {
def.sym = jo.get_string( "symbol" )[ 0 ];
}
if( jo.has_member( "broken_symbol" ) ) {
def.sym_broken = jo.get_string( "broken_symbol" )[ 0 ];
}
if( jo.has_member( "color" ) ) {
def.color = color_from_string( jo.get_string( "color" ) );
}
if( jo.has_member( "broken_color" ) ) {
def.color_broken = color_from_string( jo.get_string( "broken_color" ) );
}
if( jo.has_member( "breaks_into" ) ) {
JsonIn& stream = *jo.get_raw( "breaks_into" );
def.breaks_into_group = item_group::load_item_group( stream, "collection" );
}
auto qual = jo.get_array( "qualities" );
if( !qual.empty() ) {
def.qualities.clear();
while( qual.has_more() ) {
auto pair = qual.next_array();
def.qualities[ quality_id( pair.get_string( 0 ) ) ] = pair.get_int( 1 );
}
}
if( jo.has_member( "damage_reduction" ) ) {
JsonObject dred = jo.get_object( "damage_reduction" );
def.damage_reduction = load_damage_array( dred );
} else {
def.damage_reduction.fill( 0.0f );
}
if( jo.has_string( "abstract" ) ) {
abstract_parts[def.id] = def;
} else {
vpart_info_all[def.id] = def;
}
}
示例3: load
void recipe_dictionary::load( JsonObject &jo, const std::string &src, bool uncraft )
{
bool strict = src == "core";
recipe r;
// defer entries dependent upon as-yet unparsed definitions
if( jo.has_string( "copy-from" ) ) {
auto base = jo.get_string( "copy-from" );
if( uncraft ) {
if( !recipe_dict.uncraft.count( base ) ) {
deferred.emplace_back( jo.str(), src );
return;
}
r = recipe_dict.uncraft[ base ];
} else {
if( !recipe_dict.recipes.count( base ) ) {
deferred.emplace_back( jo.str(), src );
return;
}
r = recipe_dict.recipes[ base ];
}
}
if( jo.has_string( "abstract" ) ) {
r.ident_ = jo.get_string( "abstract" );
r.abstract = true;
} else {
r.ident_ = r.result = jo.get_string( "result" );
r.abstract = false;
}
if( !uncraft ) {
if( jo.has_string( "id_suffix" ) ) {
if( r.abstract ) {
jo.throw_error( "abstract recipe cannot specify id_suffix", "id_suffix" );
}
r.ident_ += "_" + jo.get_string( "id_suffix" );
}
assign( jo, "category", r.category, strict );
assign( jo, "subcategory", r.subcategory, strict );
assign( jo, "reversible", r.reversible, strict );
} else {
r.reversible = true;
}
assign( jo, "time", r.time, strict, 0 );
assign( jo, "difficulty", r.difficulty, strict, 0, MAX_SKILL );
assign( jo, "flags", r.flags );
// automatically set contained if we specify as container
assign( jo, "contained", r.contained, strict );
r.contained |= assign( jo, "container", r.container, strict );
if( jo.has_array( "batch_time_factors" ) ) {
auto batch = jo.get_array( "batch_time_factors" );
r.batch_rscale = batch.get_int( 0 ) / 100.0;
r.batch_rsize = batch.get_int( 1 );
}
assign( jo, "charges", r.charges );
assign( jo, "result_mult", r.result_mult );
assign( jo, "skill_used", r.skill_used, strict );
if( jo.has_member( "skills_required" ) ) {
auto sk = jo.get_array( "skills_required" );
r.required_skills.clear();
if( sk.empty() ) {
// clear all requirements
} else if( sk.has_array( 0 ) ) {
// multiple requirements
while( sk.has_more() ) {
auto arr = sk.next_array();
r.required_skills[skill_id( arr.get_string( 0 ) )] = arr.get_int( 1 );
}
} else {
// single requirement
r.required_skills[skill_id( sk.get_string( 0 ) )] = sk.get_int( 1 );
}
}
// simplified autolearn sets requirements equal to required skills at finalization
if( jo.has_bool( "autolearn" ) ) {
assign( jo, "autolearn", r.autolearn );
} else if( jo.has_array( "autolearn" ) ) {
r.autolearn = true;
auto sk = jo.get_array( "autolearn" );
while( sk.has_more() ) {
auto arr = sk.next_array();
r.autolearn_requirements[skill_id( arr.get_string( 0 ) )] = arr.get_int( 1 );
}
}
if( jo.has_member( "decomp_learn" ) ) {
r.learn_by_disassembly.clear();
//.........这里部分代码省略.........