30 return filter[attribute].to_bool() == cfg[attribute].to_bool(def);
34 const config& filter,
const config& cfg,
const std::string& attribute,
const std::string& def)
40 const std::vector<std::string> filter_attribute =
utils::split(filter[attribute]);
42 std::find(filter_attribute.begin(), filter_attribute.end(), cfg[attribute].str(def)) != filter_attribute.end());
58 const std::set<std::string> filter_attribute =
utils::split_set(filter[attribute].str());
59 const std::set<std::string> cfg_attribute =
utils::split_set(cfg[attribute].str());
60 for(
const std::string& fil_at : filter_attribute) {
61 if (cfg_attribute.count(fil_at) == 0){
80 if(filter[attribute] ==
"default" && def){
81 return (cfg[attribute].to_int(*def) == *def);
83 int value_def = def ? (*def) : 0;
88 const config& filter,
const config& cfg,
const std::string& attribute,
const std::string& opposite, utils::optional<int> def)
101 if(filter[attribute] ==
"default" && def){
102 return (cfg[attribute].to_int(*def) == *def);
104 int value_def = def ? (*def) : 0;
123 if(filter[attribute] ==
"default" && def){
124 return (cfg[attribute].to_int(*def) == *def);
126 double value_def = def ? (*def) : 1;
140 std::set<std::string> filter_attribute =
utils::split_set(filter[attribute].str());
141 bool is_matches =
false;
143 if(filter_attribute.count(
"yes") != 0 || filter_attribute.count(
"true") != 0){
144 is_matches = cfg[attribute].to_bool();
146 if(!is_matches && (filter_attribute.count(
"no") != 0 || filter_attribute.count(
"false") != 0)){
147 is_matches = !cfg[attribute].to_bool();
150 if(filter_attribute.count(
"none") != 0){
A config object defines a single node in a WML file, with access to child nodes.
bool has_attribute(config_key_type key) const
General math utility functions.
bool int_matches_if_present(const config &filter, const config &cfg, const std::string &attribute, utils::optional< int > def=utils::nullopt)
bool set_includes_if_present(const config &filter, const config &cfg, const std::string &attribute)
filter[attribute] and cfg[attribute] are assumed to be comma-separated lists.
bool double_matches_if_present(const config &filter, const config &cfg, const std::string &attribute, utils::optional< double > def=utils::nullopt)
Checks whether the filter matches the value of cfg[attribute].
bool int_matches_if_present_or_negative(const config &filter, const config &cfg, const std::string &attribute, const std::string &opposite, utils::optional< int > def=utils::nullopt)
Supports filters using "add" and "sub" attributes, for example a filter add=1 matching a cfg containi...
bool string_matches_if_present(const config &filter, const config &cfg, const std::string &attribute, const std::string &def)
bool bool_or_empty(const config &filter, const config &cfg, const std::string &attribute)
bool bool_matches_if_present(const config &filter, const config &cfg, const std::string &attribute, bool def)
Checks whether the filter matches the value of cfg[attribute].
std::set< std::string > split_set(std::string_view s, char sep, const int flags)
std::vector< std::pair< int, int > > parse_ranges_int(const std::string &str)
Handles a comma-separated list of inputs to parse_range.
std::vector< std::pair< double, double > > parse_ranges_real(const std::string &str)
std::vector< std::string > split(const config_attribute_value &val)