本文整理汇总了C++中JsonArray::next_string方法的典型用法代码示例。如果您正苦于以下问题:C++ JsonArray::next_string方法的具体用法?C++ JsonArray::next_string怎么用?C++ JsonArray::next_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonArray
的用法示例。
在下文中一共展示了JsonArray::next_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_material
// load a material object from incoming JSON
void material_type::load_material( JsonObject &jsobj )
{
material_type mat;
mat._ident = jsobj.get_string( "ident" );
mat._name = _( jsobj.get_string( "name" ).c_str() );
mat._salvage_id = jsobj.get_string( "salvage_id", "null" );
mat._salvage_multiplier = jsobj.get_float( "salvage_multiplier", 1.0 );
mat._bash_resist = jsobj.get_int( "bash_resist" );
mat._cut_resist = jsobj.get_int( "cut_resist" );
mat._bash_dmg_verb = _( jsobj.get_string( "bash_dmg_verb" ).c_str() );
mat._cut_dmg_verb = _( jsobj.get_string( "cut_dmg_verb" ).c_str() );
mat._acid_resist = jsobj.get_int( "acid_resist" );
mat._elec_resist = jsobj.get_int( "elec_resist" );
mat._fire_resist = jsobj.get_int( "fire_resist" );
mat._chip_resist = jsobj.get_int( "chip_resist" );
mat._density = jsobj.get_int( "density" );
JsonArray jsarr = jsobj.get_array( "dmg_adj" );
mat._dmg_adj[0] = _( jsarr.next_string().c_str() );
mat._dmg_adj[1] = _( jsarr.next_string().c_str() );
mat._dmg_adj[2] = _( jsarr.next_string().c_str() );
mat._dmg_adj[3] = _( jsarr.next_string().c_str() );
_all_materials[mat._ident] = mat;
DebugLog( D_INFO, DC_ALL ) << "Loaded material: " << mat._name;
}
示例2: load_profession
void profession::load_profession(JsonObject &jsobj)
{
profession prof;
JsonArray jsarr;
prof._ident = jsobj.get_string("ident");
prof._name = _(jsobj.get_string("name").c_str());
prof._description = _(jsobj.get_string("description").c_str());
prof._point_cost = jsobj.get_int("points");
jsarr = jsobj.get_array("items");
while (jsarr.has_more()) {
prof.add_item(jsarr.next_string());
}
jsarr = jsobj.get_array("skills");
while (jsarr.has_more()) {
JsonObject jo = jsarr.next_object();
prof.add_skill(jo.get_string("name"),
jo.get_int("level"));
}
jsarr = jsobj.get_array("addictions");
while (jsarr.has_more()) {
JsonObject jo = jsarr.next_object();
prof.add_addiction(addiction_type(jo.get_string("type")),
jo.get_int("intensity"));
}
jsarr = jsobj.get_array("flags");
while (jsarr.has_more()) {
prof.flags.insert(jsarr.next_string());
}
_all_profs[prof._ident] = prof;
//dout(D_INFO) << "Loaded profession: " << prof._name;
}
示例3: load_trait_group
void mutation_branch::load_trait_group( JsonObject &jsobj, const trait_group::Trait_group_tag &gid,
const std::string &subtype )
{
if( subtype != "distribution" && subtype != "collection" && subtype != "old" ) {
jsobj.throw_error( "unknown trait group type", "subtype" );
}
Trait_group &tg = make_group_or_throw( gid, ( subtype == "collection" || subtype == "old" ) );
// TODO: (sm) Looks like this makes the new code backwards-compatible with the old format. Great if so!
if( subtype == "old" ) {
JsonArray traits = jsobj.get_array( "traits" );
while( traits.has_more() ) {
JsonArray pair = traits.next_array();
tg.add_trait_entry( trait_id( pair.get_string( 0 ) ), pair.get_int( 1 ) );
}
return;
}
// TODO: (sm) Taken from item_factory.cpp almost verbatim. Ensure that these work!
if( jsobj.has_member( "entries" ) ) {
JsonArray traits = jsobj.get_array( "entries" );
while( traits.has_more() ) {
JsonObject subobj = traits.next_object();
add_entry( tg, subobj );
}
}
if( jsobj.has_member( "traits" ) ) {
JsonArray traits = jsobj.get_array( "traits" );
while( traits.has_more() ) {
if( traits.test_string() ) {
tg.add_trait_entry( trait_id( traits.next_string() ), 100 );
} else if( traits.test_array() ) {
JsonArray subtrait = traits.next_array();
tg.add_trait_entry( trait_id( subtrait.get_string( 0 ) ), subtrait.get_int( 1 ) );
} else {
JsonObject subobj = traits.next_object();
add_entry( tg, subobj );
}
}
}
if( jsobj.has_member( "groups" ) ) {
JsonArray traits = jsobj.get_array( "groups" );
while( traits.has_more() ) {
if( traits.test_string() ) {
tg.add_group_entry( trait_group::Trait_group_tag( traits.next_string() ), 100 );
} else if( traits.test_array() ) {
JsonArray subtrait = traits.next_array();
tg.add_group_entry( trait_group::Trait_group_tag( traits.get_string( 0 ) ), subtrait.get_int( 1 ) );
} else {
JsonObject subobj = traits.next_object();
add_entry( tg, subobj );
}
}
}
}
示例4: load_profession
void profession::load_profession(JsonObject &jsobj)
{
profession prof;
JsonArray jsarr;
prof._ident = jsobj.get_string("ident");
//If the "name" is an object then we have to deal with gender-specific titles,
if(jsobj.has_object("name")) {
JsonObject name_obj = jsobj.get_object("name");
prof._name_male = pgettext("profession_male", name_obj.get_string("male").c_str());
prof._name_female = pgettext("profession_female", name_obj.get_string("female").c_str());
} else {
// Same profession names for male and female in English.
// Still need to different names in other languages.
const std::string name = jsobj.get_string("name");
prof._name_female = pgettext("profession_female", name.c_str());
prof._name_male = pgettext("profession_male", name.c_str());
}
const std::string desc = jsobj.get_string("description").c_str();
prof._description_male = pgettext("prof_desc_male", desc.c_str());
prof._description_female = pgettext("prof_desc_female", desc.c_str());
prof._point_cost = jsobj.get_int("points");
JsonObject items_obj = jsobj.get_object("items");
prof.add_items_from_jsonarray(items_obj.get_array("both"), "both");
prof.add_items_from_jsonarray(items_obj.get_array("male"), "male");
prof.add_items_from_jsonarray(items_obj.get_array("female"), "female");
jsarr = jsobj.get_array("skills");
while (jsarr.has_more()) {
JsonObject jo = jsarr.next_object();
prof.add_skill(jo.get_string("name"),
jo.get_int("level"));
}
jsarr = jsobj.get_array("addictions");
while (jsarr.has_more()) {
JsonObject jo = jsarr.next_object();
prof.add_addiction(addiction_type(jo.get_string("type")),
jo.get_int("intensity"));
}
jsarr = jsobj.get_array("CBMs");
while (jsarr.has_more()) {
prof.add_CBM(jsarr.next_string());
}
jsarr = jsobj.get_array("flags");
while (jsarr.has_more()) {
prof.flags.insert(jsarr.next_string());
}
_all_profs[prof._ident] = prof;
DebugLog( D_INFO, DC_ALL ) << "Loaded profession: " << prof._ident;
}
示例5: load_technique
void load_technique(JsonObject &jo)
{
ma_technique tec;
tec.id = jo.get_string("id");
tec.name = jo.get_string("name", "");
if (!tec.name.empty()) {
tec.name = _(tec.name.c_str());
}
JsonArray jsarr = jo.get_array("messages");
while (jsarr.has_more()) {
tec.messages.push_back(_(jsarr.next_string().c_str()));
}
tec.reqs.unarmed_allowed = jo.get_bool("unarmed_allowed", false);
tec.reqs.melee_allowed = jo.get_bool("melee_allowed", false);
tec.reqs.min_melee = jo.get_int("min_melee", 0);
tec.reqs.min_unarmed = jo.get_int("min_unarmed", 0);
tec.reqs.min_bashing = jo.get_int("min_bashing", 0);
tec.reqs.min_cutting = jo.get_int("min_cutting", 0);
tec.reqs.min_stabbing = jo.get_int("min_stabbing", 0);
tec.reqs.min_bashing_damage = jo.get_int("min_bashing_damage", 0);
tec.reqs.min_cutting_damage = jo.get_int("min_cutting_damage", 0);
tec.reqs.req_buffs = jo.get_tags("req_buffs");
tec.reqs.req_flags = jo.get_tags("req_flags");
tec.crit_tec = jo.get_bool("crit_tec", false);
tec.defensive = jo.get_bool("defensive", false);
tec.disarms = jo.get_bool("disarms", false);
tec.dodge_counter = jo.get_bool("dodge_counter", false);
tec.block_counter = jo.get_bool("block_counter", false);
tec.miss_recovery = jo.get_bool("miss_recovery", false);
tec.grab_break = jo.get_bool("grab_break", false);
tec.flaming = jo.get_bool("flaming", false);
tec.hit = jo.get_int("pain", 0);
tec.bash = jo.get_int("bash", 0);
tec.cut = jo.get_int("cut", 0);
tec.pain = jo.get_int("pain", 0);
tec.weighting = jo.get_int("weighting", 1);
tec.bash_mult = jo.get_float("bash_mult", 1.0);
tec.cut_mult = jo.get_float("cut_mult", 1.0);
tec.speed_mult = jo.get_float("speed_mult", 1.0);
tec.down_dur = jo.get_int("down_dur", 0);
tec.stun_dur = jo.get_int("stun_dur", 0);
tec.knockback_dist = jo.get_int("knockback_dist", 0);
tec.knockback_spread = jo.get_int("knockback_spread", 0);
tec.aoe = jo.get_string("aoe", "");
tec.flags = jo.get_tags("flags");
ma_techniques[tec.id] = tec;
}
示例6: load_recipe_category
void load_recipe_category( JsonObject &jsobj )
{
JsonArray subcats;
std::string category = jsobj.get_string( "id" );
if( category.find( "CC_" ) != 0 ) {
jsobj.throw_error( "Crafting category id has to be prefixed with 'CC_'" );
}
// Don't store noncraft as a category.
// We're storing the subcategory so we can look it up in load_recipes
// for the fallback subcategory.
if( category != "CC_NONCRAFT" ) {
craft_cat_list.push_back( category );
}
std::string cat_name = get_cat_name( category );
craft_subcat_list[category] = std::vector<std::string>();
subcats = jsobj.get_array( "recipe_subcategories" );
while( subcats.has_more() ) {
std::string subcat_id = subcats.next_string();
if( subcat_id.find( "CSC_" + cat_name + "_" ) != 0 && subcat_id != "CSC_ALL" &&
subcat_id != "CSC_NONCRAFT" ) {
jsobj.throw_error( "Crafting sub-category id has to be prefixed with CSC_<category_name>_" );
}
craft_subcat_list[category].push_back( subcat_id );
}
}
示例7: load_mods_list
void mod_manager::load_mods_list(WORLDPTR world) const
{
if (world == NULL) {
return;
}
std::vector<std::string> &amo = world->active_mod_order;
amo.clear();
bool obsolete_mod_found = false;
read_from_file_optional_json( get_mods_list_file( world ), [&]( JsonIn &jsin ) {
JsonArray ja = jsin.get_array();
while (ja.has_more()) {
const std::string mod = ja.next_string();
if( mod.empty() || std::find(amo.begin(), amo.end(), mod) != amo.end() ) {
continue;
}
if( mod_replacements.count( mod ) ) {
amo.push_back( mod_replacements[ mod ] );
obsolete_mod_found = true;
} else {
amo.push_back(mod);
}
}
} );
if( obsolete_mod_found ) {
// If we found an obsolete mod, overwrite the mod list without the obsolete one.
save_mods_list(world);
}
}
示例8: load_mods_list
void mod_manager::load_mods_list(WORLDPTR world) const
{
if (world == NULL) {
return;
}
std::vector<std::string> &amo = world->active_mod_order;
amo.clear();
std::ifstream mods_list_file(get_mods_list_file(world).c_str(), std::ios::in | std::ios::binary);
if (!mods_list_file) {
return;
}
try {
JsonIn jsin(mods_list_file);
JsonArray ja = jsin.get_array();
while (ja.has_more()) {
const std::string mod = ja.next_string();
if (mod.empty() || std::find(amo.begin(), amo.end(), mod) != amo.end()) {
continue;
}
amo.push_back(mod);
}
} catch (std::string e) {
DebugLog( D_ERROR, DC_ALL ) << "worldfactory: loading mods list failed: " << e;
}
}
示例9: load_trait_blacklist
void mutation_branch::load_trait_blacklist( JsonObject &jsobj )
{
JsonArray jarr = jsobj.get_array( "traits" );
while( jarr.has_more() ) {
trait_blacklist.insert( trait_id( jarr.next_string() ) );
}
}
示例10: load
void mutation_branch::load( JsonObject &jsobj )
{
const std::string id = jsobj.get_string( "id" );
mutation_branch &new_mut = mutation_data[id];
JsonArray jsarr;
new_mut.name = _(jsobj.get_string("name").c_str());
new_mut.description = _(jsobj.get_string("description").c_str());
new_mut.points = jsobj.get_int("points");
new_mut.visibility = jsobj.get_int("visibility", 0);
new_mut.ugliness = jsobj.get_int("ugliness", 0);
new_mut.startingtrait = jsobj.get_bool("starting_trait", false);
new_mut.mixed_effect = jsobj.get_bool("mixed_effect", false);
new_mut.activated = jsobj.get_bool("active", false);
new_mut.cost = jsobj.get_int("cost", 0);
new_mut.cooldown = jsobj.get_int("time",0);
new_mut.hunger = jsobj.get_bool("hunger",false);
new_mut.thirst = jsobj.get_bool("thirst",false);
new_mut.fatigue = jsobj.get_bool("fatigue",false);
new_mut.valid = jsobj.get_bool("valid", true);
new_mut.purifiable = jsobj.get_bool("purifiable", true);
new_mut.initial_ma_styles = jsobj.get_string_array( "initial_ma_styles" );
new_mut.threshold = jsobj.get_bool("threshold", false);
new_mut.profession = jsobj.get_bool("profession", false);
load_mutation_mods(jsobj, "passive_mods", new_mut.mods);
/* Not currently supported due to inability to save active mutation state
load_mutation_mods(jsobj, "active_mods", new_mut.mods); */
new_mut.prereqs = jsobj.get_string_array( "prereqs" );
// Helps to be able to have a trait require more than one other trait
// (Individual prereq-lists are "OR", not "AND".)
// Traits shoud NOT appear in both lists for a given mutation, unless
// you want that trait to satisfy both requirements.
// These are additional to the first list.
new_mut.prereqs2 = jsobj.get_string_array( "prereqs2" );
// Dedicated-purpose prereq slot for Threshold mutations
// Stuff like Huge might fit in more than one mutcat post-threshold, so yeah
new_mut.threshreq = jsobj.get_string_array( "threshreq" );
new_mut.cancels = jsobj.get_string_array( "cancels" );
new_mut.replacements = jsobj.get_string_array( "changes_to" );
new_mut.additions = jsobj.get_string_array( "leads_to" );
jsarr = jsobj.get_array("category");
while (jsarr.has_more()) {
std::string s = jsarr.next_string();
new_mut.category.push_back(s);
mutations_category[s].push_back(id);
}
jsarr = jsobj.get_array("wet_protection");
while (jsarr.has_more()) {
JsonObject jo = jsarr.next_object();
std::string part_id = jo.get_string("part");
int ignored = jo.get_int("ignored", 0);
int neutral = jo.get_int("neutral", 0);
int good = jo.get_int("good", 0);
tripoint protect = tripoint(ignored, neutral, good);
new_mut.protection[part_id] = mutation_wet(body_parts[part_id], protect);
}
}
示例11: while
std::vector<std::string> JsonObject::get_string_array(const std::string &name)
{
JsonArray ja = get_array(name);
std::vector<std::string> ret;
while (ja.has_more()) {
ret.push_back(ja.next_string());
}
return ret;
}
示例12: load_tutorial_messages
void load_tutorial_messages( JsonObject &jo )
{
// loading them all at once, as they have to be in exact order
tut_text.clear();
JsonArray messages = jo.get_array( "messages" );
while( messages.has_more() ) {
tut_text.push_back( _( messages.next_string().c_str() ) );
}
}
示例13:
json_item_substitution::substitution::info json_item_substitution::substitution::info::load(
JsonArray &arr )
{
json_item_substitution::substitution::info ret;
ret.new_item = arr.next_string();
if( arr.test_float() && ( ret.ratio = arr.next_float() ) <= 0.0 ) {
arr.throw_error( "Ratio must be positive" );
}
return ret;
}
示例14: load
void tool_comp::load( JsonArray &ja )
{
if( ja.test_string() ) {
// constructions uses this format: [ "tool", ... ]
type = ja.next_string();
count = -1;
} else {
JsonArray comp = ja.next_array();
type = comp.get_string( 0 );
count = comp.get_int( 1 );
}
}
示例15: add_snippets_from_json
void snippet_library::add_snippets_from_json( const std::string &category, JsonArray &jarr )
{
while( jarr.has_more() ) {
if( jarr.test_string() ) {
const std::string text = _( jarr.next_string().c_str() );
add_snippet( category, text );
} else {
JsonObject jo = jarr.next_object();
add_snippet_from_json( category, jo );
}
}
}