本文整理汇总了C++中vconfig::get_config方法的典型用法代码示例。如果您正苦于以下问题:C++ vconfig::get_config方法的具体用法?C++ vconfig::get_config怎么用?C++ vconfig::get_config使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vconfig
的用法示例。
在下文中一共展示了vconfig::get_config方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: construct
static std::shared_ptr<unit_filter_abstract_impl> construct(const vconfig & vcfg, const filter_context & fc, bool flat_tod)
{
if (vcfg.empty()) {
return std::make_shared<null_unit_filter_impl> (fc);
}
if (vcfg.get_config().attribute_count() == 1 && vcfg.get_config().all_children_count() == 0 && vcfg.has_attribute("limit")) {
return std::make_shared<null_unit_filter_impl> (fc);
}
return std::make_shared<basic_unit_filter_impl>(vcfg, fc, flat_tod);
//TODO: Add more efficient implementations for special cases
}
示例2:
pathfind::teleport_group::teleport_group(const vconfig& cfg, bool reversed) : cfg_(cfg.get_config()), reversed_(reversed), id_()
{
assert(cfg_.child_count("source") == 1);
assert(cfg_.child_count("target") == 1);
assert(cfg_.child_count("filter") == 1);
if (cfg["id"].empty()) {
id_ = resources::tunnels->next_unique_id();
} else {
id_ = cfg["id"].str();
if (reversed_) // Differentiate the reverse tunnel from the forward one
id_ += reversed_suffix;
}
}
示例3: handle_event_command
void handle_event_command(const std::string &cmd,
const queued_event &event_info, const vconfig &cfg)
{
log_scope2(log_engine, "handle_event_command");
LOG_NG << "handling command '" << cmd << "' from cfg 0x"
<< std::hex << std::setiosflags(std::ios::uppercase)
<< reinterpret_cast<uintptr_t>(&cfg.get_config()) << std::dec << "\n";
if (!resources::lua_kernel->run_wml_action(cmd, cfg, event_info))
{
ERR_NG << "Couldn't find function for wml tag: "<< cmd <<"\n";
}
DBG_NG << "done handling command...\n";
}
示例4: fill
void unit_filter_compound::fill(vconfig cfg)
{
const config& literal = cfg.get_config();
//optimisation
if(literal.empty()) { return; }
create_attribute(literal["name"],
[](const config::attribute_value& c) { return c.t_str(); },
[](const t_string& str, const unit_filter_args& args) { return str == args.u.name(); }
);
create_attribute(literal["id"],
[](const config::attribute_value& c) { return utils::split(c.str()); },
[](const std::vector<std::string>& id_list, const unit_filter_args& args)
{
return std::find(id_list.begin(), id_list.end(), args.u.id()) != id_list.end();
}
);
create_attribute(literal["speaker"],
[](const config::attribute_value& c) { return c.str(); },
[](const std::string& speaker, const unit_filter_args& args)
{
return speaker == args.u.id();
}
);
create_attribute(literal["type"],
[](const config::attribute_value& c) { return utils::split(c.str()); },
[](const std::vector<std::string>& types, const unit_filter_args& args)
{
return std::find(types.begin(), types.end(), args.u.type_id()) != types.end();
}
);
create_attribute(literal["type_adv_tree"],
[](const config::attribute_value& c) { return utils::split(c.str()); },
[](const std::vector<std::string>& types, const unit_filter_args& args)
{
std::set<std::string> types_expanded;
for(const std::string& type : types) {
if(types_expanded.count(type)) {
continue;
}
if(const unit_type* ut = unit_types.find(type)) {
const auto& tree = ut->advancement_tree();
types_expanded.insert(tree.begin(), tree.end());
types_expanded.insert(type);
}
}
return types_expanded.find(args.u.type_id()) != types_expanded.end();
}
);
create_attribute(literal["variation"],
[](const config::attribute_value& c) { return utils::split(c.str()); },
[](const std::vector<std::string>& types, const unit_filter_args& args)
{
return std::find(types.begin(), types.end(), args.u.variation()) != types.end();
}
);
create_attribute(literal["has_variation"],
[](const config::attribute_value& c) { return utils::split(c.str()); },
[](const std::vector<std::string>& types, const unit_filter_args& args)
{
// If this unit is a variation itself then search in the base unit's variations.
const unit_type* const type = args.u.variation().empty() ? &args.u.type() : unit_types.find(args.u.type().base_id());
assert(type);
for(const std::string& variation_id : types) {
if (type->has_variation(variation_id)) {
return true;
}
}
return false;
}
);
create_attribute(literal["ability"],
[](const config::attribute_value& c) { return utils::split(c.str()); },
[](const std::vector<std::string>& abilities, const unit_filter_args& args)
{
for(const std::string& ability_id : abilities) {
if (args.u.has_ability_by_id(ability_id)) {
return true;
}
}
return false;
}
);
create_attribute(literal["ability_type"],
[](const config::attribute_value& c) { return utils::split(c.str()); },
[](const std::vector<std::string>& abilities, const unit_filter_args& args)
{
for(const std::string& ability : abilities) {
if (args.u.has_ability_type(ability)) {
return true;
//.........这里部分代码省略.........