33 return str.empty() ?
empty :
false;
55 utils::optional<config::const_child_itors> composite_range;
56 std::shared_ptr<wml_type>
type;
58 type = std::make_shared<wml_type_union>(cfg[
"name"]);
60 }
else if(cfg.
has_child(
"intersection")) {
61 type = std::make_shared<wml_type_intersection>(cfg[
"name"]);
65 int list_min = list_cfg[
"min"].to_int();
66 int list_max = list_cfg[
"max"].str() ==
"infinite" ? -1 : list_cfg[
"max"].to_int(-1);
67 if(list_max < 0) list_max = std::numeric_limits<int>::max();
68 type = std::make_shared<wml_type_list>(cfg[
"name"], list_cfg[
"split"].str(
"\\s*,\\s*"), list_min, list_max);
69 composite_range.emplace(list_cfg.
child_range(
"element"));
71 auto t = std::make_shared<wml_type_simple>(cfg[
"name"], cfg[
"value"]);
72 if(cfg[
"allow_translatable"].to_bool())
t->allow_translatable();
75 type = std::make_shared<wml_type_alias>(cfg[
"name"], cfg[
"link"]);
78 auto composite_type = std::dynamic_pointer_cast<wml_type_composite>(
type);
79 for(
const config& elem : *composite_range) {
90 return boost::regex_match(value.
str(), sub,
pattern_);
96 auto it = type_map.find(
link_);
97 if(it == type_map.end()) {
103 return cached_->matches(value, type_map);
109 if(
type->matches(value, type_map)) {
119 if(!
type->matches(value, type_map)) {
128 auto value = value_attr.
str();
129 boost::sregex_token_iterator it(value.begin(), value.end(),
split_, -1), end;
131 bool result = std::all_of(it, end, [
this, &type_map, &
n](
const boost::ssub_match& match){
133 if(!match.matched)
return true;
136 elem = std::string(match.first, match.second);
137 return this->wml_type_union::matches(elem, type_map);
Variant for storing WML attributes.
std::string str(const std::string &fallback="") const
auto apply_visitor(const V &visitor) const
Visitor support: Applies a visitor to the underlying variant.
A config object defines a single node in a WML file, with access to child nodes.
config & mandatory_child(config_key_type key, int n=0)
Returns the nth child with the given key, or throws an error if there is none.
bool has_child(config_key_type key) const
Determine whether a config has a child or not.
bool has_attribute(config_key_type key) const
child_itors child_range(config_key_type key)
std::shared_ptr< wml_type > cached_
bool matches(const config_attribute_value &value, const map &type_map) const override
std::vector< std::shared_ptr< wml_type > > subtypes_
bool matches(const config_attribute_value &value, const map &type_map) const override
bool matches(const config_attribute_value &value, const map &type_map) const override
bool matches(const config_attribute_value &value, const map &type_map) const override
bool matches(const config_attribute_value &value, const map &type_map) const override
bool matches(const config_attribute_value &value, const map &type_map) const override
static std::shared_ptr< wml_type > from_config(const config &cfg)
std::map< std::string, ptr > map
Definitions for the interface to Wesnoth Markup Language (WML).
bool operator()(const utils::monostate &) const
bool operator()(const t_string &) const
bool operator()(const T &) const
bool operator()(const std::string &str) const
static map_location::direction n
This file contains object "type", which is used to store information about types while annotation par...
MacOS doesn't support std::visit when targing MacOS < 10.14 (currently we target 10....