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


C++ config::has_attribute方法代码示例

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


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

示例1: subset_descriptor

	explicit subset_descriptor(const config & font)
		: name(font["name"].str())
		, bold_name()
		, italic_name()
		, present_codepoints()
	{
		if (font.has_attribute("bold_name")) {
			bold_name = font["bold_name"].str();
		}

		if (font.has_attribute("italic_name")) {
			italic_name = font["italic_name"].str();
		}

		std::vector<std::string> ranges = utils::split(font["codepoints"]);

		for (const std::string & i : ranges) {
			std::vector<std::string> r = utils::split(i, '-');
			if(r.size() == 1) {
				size_t r1 = lexical_cast_default<size_t>(r[0], 0);
				present_codepoints.push_back(std::pair<size_t, size_t>(r1, r1));
			} else if(r.size() == 2) {
				size_t r1 = lexical_cast_default<size_t>(r[0], 0);
				size_t r2 = lexical_cast_default<size_t>(r[1], 0);

				present_codepoints.push_back(std::pair<size_t, size_t>(r1, r2));
			}
		}
	}
开发者ID:doofus-01,项目名称:wesnoth,代码行数:29,代码来源:font_description.hpp

示例2:

// This constructor is *only* meant for loading from saves
pathfind::teleport_group::teleport_group(const config& cfg) : cfg_(cfg), reversed_(utils::string_bool(cfg["reversed"], false)), id_(cfg["id"])
{
	assert(cfg.has_attribute("id"));
	assert(cfg.has_attribute("reversed"));

	assert(cfg_.child_count("source") == 1);
	assert(cfg_.child_count("target") == 1);
	assert(cfg_.child_count("filter") == 1);
}
开发者ID:blackberry,项目名称:Wesnoth,代码行数:10,代码来源:teleport.cpp

示例3: check_addon_version_compatibility

game_info::ADDON_REQ game_info::check_addon_version_compatibility(const config& local_item, const config& game)
{
	if(!local_item.has_attribute("addon_id") || !local_item.has_attribute("addon_version")) {
		return SATISFIED;
	}

	if(const config& game_req = game.find_child("addon", "id", local_item["addon_id"])) {
		required_addon r = {local_item["addon_id"].str(), SATISFIED, ""};

		// Local version
		const version_info local_ver(local_item["addon_version"].str());
		version_info local_min_ver(local_item.has_attribute("addon_min_version") ? local_item["addon_min_version"] : local_item["addon_version"]);

		// If the UMC didn't specify last compatible version, assume no backwards compatibility.
		// Also apply some sanity checking regarding min version; if the min ver doens't make sense, ignore it.
		local_min_ver = std::min(local_min_ver, local_ver);

		// Remote version
		const version_info remote_ver(game_req["version"].str());
		version_info remote_min_ver(game_req.has_attribute("min_version") ? game_req["min_version"] : game_req["version"]);

		remote_min_ver = std::min(remote_min_ver, remote_ver);

		// Check if the host is too out of date to play.
		if(local_min_ver > remote_ver) {
			r.outcome = CANNOT_SATISFY;

			// TODO: Figure out how to ask the add-on manager for the user-friendly name of this add-on.
			r.message = vgettext("The host's version of <i>$addon</i> is incompatible. They have version <b>$host_ver</b> while you have version <b>$local_ver</b>.", {
				{"addon",     r.addon_id},
				{"host_ver",  remote_ver.str()},
				{"local_ver", local_ver.str()}
			});

			required_addons.push_back(r);
			return r.outcome;
		}

		// Check if our version is too out of date to play.
		if(remote_min_ver > local_ver) {
			r.outcome = NEED_DOWNLOAD;

			// TODO: Figure out how to ask the add-on manager for the user-friendly name of this add-on.
			r.message = vgettext("Your version of <i>$addon</i> is incompatible. You have version <b>$local_ver</b> while the host has version <b>$host_ver</b>.", {
				{"addon", r.addon_id},
				{"host_ver", remote_ver.str()},
				{"local_ver", local_ver.str()}
			});

			required_addons.push_back(r);
			return r.outcome;
		}
	}

	return SATISFIED;
}
开发者ID:doofus-01,项目名称:wesnoth,代码行数:56,代码来源:lobby_data.cpp

示例4: if

void team::team_info::handle_legacy_share_vision(const config& cfg)
{
	if(cfg.has_attribute("share_view") || cfg.has_attribute("share_maps")) {
		if(cfg["share_view"].to_bool()) {
			share_vision = team::SHARE_VISION::ALL;
		} else if(cfg["share_maps"].to_bool(true)) {
			share_vision = team::SHARE_VISION::SHROUD;
		} else {
			share_vision = team::SHARE_VISION::NONE;
		}
	}
}
开发者ID:fluffbeast,项目名称:wesnoth-old,代码行数:12,代码来源:team.cpp

示例5:

	lua_candidate_action_wrapper_external(rca_context& context, const config& cfg, lua_ai_context &lua_ai_ctx)
		: lua_candidate_action_wrapper_base(context,cfg), location_(cfg["location"]), use_parms_(false)
	{
		if (cfg.has_attribute("exec_parms") || cfg.has_attribute("eval_parms")) {
			use_parms_ = true;
			exec_parms_ = cfg["exec_parms"].str();
			eval_parms_ = cfg["eval_parms"].str();
		}
		std::string eval_code;
		std::string exec_code;
		generate_code(eval_code, exec_code);

		evaluation_action_handler_ = std::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(eval_code.c_str(),lua_ai_ctx));
		execution_action_handler_ = std::shared_ptr<lua_ai_action_handler>(resources::lua_kernel->create_lua_ai_action_handler(exec_code.c_str(),lua_ai_ctx));
	}
开发者ID:aquileia,项目名称:wesnoth,代码行数:15,代码来源:engine_lua.cpp

示例6:

theme::label::label(const config& cfg) :
	object(cfg),
	text_(cfg["prefix"].str() + cfg["text"].str() + cfg["postfix"].str()),
	icon_(cfg["icon"]),
	font_(cfg["font_size"]),
	font_rgb_set_(false),
	font_rgb_(DefaultFontRGB)
{
	if(font_ == 0)
		font_ = DefaultFontSize;

	if (cfg.has_attribute("font_rgb"))
	{
		std::vector<std::string> rgb_vec = utils::split(cfg["font_rgb"]);
		if (3 <= rgb_vec.size()) {
			std::vector<std::string>::iterator c=rgb_vec.begin();
			int r,g,b;
			r = (atoi(c->c_str()));
			++c;
			if (c != rgb_vec.end()) {
				g = (atoi(c->c_str()));
				++c;
			} else {
				g=0;
			}
			if (c != rgb_vec.end()) {
				b=(atoi(c->c_str()));
			} else {
				b=0;
			}
			font_rgb_ = (((r<<16) & 0x00FF0000) + ((g<<8) & 0x0000FF00) + ((b) & 0x000000FF));
			font_rgb_set_=true;
		}
	}
}
开发者ID:CliffsDover,项目名称:wesnoth,代码行数:35,代码来源:theme.cpp

示例7: child_tag

class_tag::class_tag(const config & cfg)
	: name_(cfg["name"].str())
	, min_(cfg["min"].to_int())
	, max_(cfg["max"].to_int())
	, super_("")
	, tags_()
	, keys_()
	, links_()
{
		if (max_ < 0){
			max_ = INT_MAX;
		}
		if (cfg.has_attribute("super")){
			super_ = cfg["super"].str();
		}
		foreach (const config &child, cfg.child_range("tag")) {
			class_tag child_tag (child);
			add_tag(child_tag);
		}
		foreach (const config &child, cfg.child_range("key")) {
			class_key child_key (child);
			add_key(child_key);
		}
		foreach (const config &link, cfg.child_range("link")) {
			std::string link_name = link["name"].str();
			add_link(link_name);
		}
}
开发者ID:asimonov-im,项目名称:wesnoth,代码行数:28,代码来源:tag.cpp

示例8: transfer_to

void carryover_info::transfer_to(config& level)
{
	if(!level.has_attribute("next_underlying_unit_id"))
	{
		level["next_underlying_unit_id"] = next_underlying_unit_id_;
	}

	//if the game has been loaded from a snapshot, variables_ is empty since we cleared it below.
	level.child_or_add("variables").append(std::move(variables_));

	config::attribute_value & seed_value = level["random_seed"];
	if ( seed_value.empty() ) {
		seed_value = rng_.get_random_seed_str();
		level["random_calls"] = rng_.get_random_calls();
	}

	if(!level.has_child("menu_item")){
		for(config& item : wml_menu_items_)
		{
			level.add_child("menu_item").swap(item);
		}
	}

	next_scenario_ = "";
	variables_.clear();
	wml_menu_items_.clear();

}
开发者ID:GregoryLundberg,项目名称:wesnoth,代码行数:28,代码来源:carryover.cpp

示例9: transfer_to

void carryover_info::transfer_to(config& level)
{
	if(!level.has_attribute("next_underlying_unit_id"))
	{
		level["next_underlying_unit_id"] = next_underlying_unit_id_;
	}

	//if the game has been loaded from a snapshot, the existing variables will be the current ones
	if(!level.has_child("variables")) {
		level.add_child("variables", variables_);
	}

	config::attribute_value & seed_value = level["random_seed"];
	if ( seed_value.empty() ) {
		seed_value = rng_.get_random_seed_str();
		level["random_calls"] = rng_.get_random_calls();
	}

	if(!level.has_child("menu_item")){
		for(config& item : wml_menu_items_)
		{
			level.add_child("menu_item").swap(item);
		}
	}

	next_scenario_ = "";
	variables_ = config();
	wml_menu_items_.clear();

}
开发者ID:PoignardAzur,项目名称:wesnoth,代码行数:30,代码来源:carryover.cpp

示例10: transfer_all_to

void carryover_info::transfer_all_to(config& side_cfg){
	if(side_cfg["save_id"].empty()){
		side_cfg["save_id"] = side_cfg["id"];
	}
	std::vector<carryover>::iterator iside = std::find_if(
		carryover_sides_.begin(),
		carryover_sides_.end(),
		save_id_equals(side_cfg["save_id"])
	);
	if(iside != carryover_sides_.end())
	{
		iside->transfer_all_gold_to(side_cfg);
		iside->transfer_all_recalls_to(side_cfg);
		iside->transfer_all_recruits_to(side_cfg);
		carryover_sides_.erase(iside);
		return;
	}
	else
	{
		//if no carryover was found for this side, check if starting gold is defined
		if(!side_cfg.has_attribute("gold") || side_cfg["gold"].empty()){
			side_cfg["gold"] = default_gold_qty;
		}
	}
}
开发者ID:GregoryLundberg,项目名称:wesnoth,代码行数:25,代码来源:carryover.cpp

示例11: do_parse_candidate_action_from_config

void engine_lua::do_parse_candidate_action_from_config( rca_context &context, const config &cfg, std::back_insert_iterator<std::vector< candidate_action_ptr > > b ){
	if (!cfg) {
		return;
	}

	if (!lua_ai_context_) {
		return;
	}

	candidate_action_ptr ca_ptr;
	if (!cfg["sticky"].to_bool())
	{
		if (cfg.has_attribute("location")) {
			ca_ptr = candidate_action_ptr(new lua_candidate_action_wrapper_external(context,cfg,*lua_ai_context_));
		} else {
			ca_ptr = candidate_action_ptr(new lua_candidate_action_wrapper(context,cfg,*lua_ai_context_));
		}
	}
	else
	{
		ca_ptr = candidate_action_ptr(new lua_sticky_candidate_action_wrapper(context,cfg,*lua_ai_context_));
	}

	if (ca_ptr) {
		*b = ca_ptr;
	}
}
开发者ID:aquileia,项目名称:wesnoth,代码行数:27,代码来源:engine_lua.cpp

示例12: get_engine_code

std::string engine_lua::get_engine_code(const config &cfg) const
{
	if (cfg.has_attribute("code")) {
		return cfg["code"].str();
	}
	// If there is no engine defined we create a dummy engine
	std::string code = "wesnoth.require(\"ai/lua/dummy_engine_lua.lua\")";
	return code;
}
开发者ID:aquileia,项目名称:wesnoth,代码行数:9,代码来源:engine_lua.cpp

示例13: handle_change

	bool handle_change(const path_element &child, config cfg)
	{
		if (!handle_delete(child)) {
			return false;
		}
		if (!cfg.has_attribute("id")) {
			cfg["id"] = child.id;
		}

		return handle_add(child,cfg);
	}
开发者ID:PoignardAzur,项目名称:wesnoth,代码行数:11,代码来源:property_handler.hpp

示例14: add_name_generator_from_config

void name_generator_factory::add_name_generator_from_config(const config& config, const std::string id, const std::string prefix) {
 	std::string cfg_name 	= prefix + "name_generator";
	std::string markov_name = prefix + "names";

	if(config.has_attribute(cfg_name)) {
		try {
			name_generators_[id] = std::shared_ptr<name_generator>(new context_free_grammar_generator(config[cfg_name]));
		}
		catch (const name_generator_invalid_exception& ex) {
			lg::wml_error() << ex.what() << '\n';
		}
	}

	if(config.has_attribute(markov_name)) {
		config::attribute_value markov_name_list = config[markov_name];

		if(!markov_name_list.blank()) {
			name_generators_[id] = std::shared_ptr<name_generator>(new markov_generator(utils::split(markov_name_list), config["markov_chain_size"].to_int(2), 12));
		}
	}
};
开发者ID:PoignardAzur,项目名称:wesnoth,代码行数:21,代码来源:name_generator_factory.cpp

示例15: goal

lua_goal::lua_goal(readonly_context &context, const config &cfg)
	: goal(context, cfg)
	, code_()
	, handler_()
{
	if (cfg.has_attribute("code")) {
		code_ = cfg["code"].str();
	}
	else
	{
		ERR_AI_GOAL << "side " << get_side() << " : Error creating Lua goal (missing code= key)" << std::endl;
	}
}
开发者ID:GregoryLundberg,项目名称:wesnoth,代码行数:13,代码来源:goal.cpp


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