29 return filter[attribute].to_bool() == cfg[attribute].to_bool(def);
33 const config& filter,
const config& cfg,
const std::string& attribute,
const std::string& def)
39 const std::vector<std::string> filter_attribute =
utils::split(filter[attribute]);
41 std::find(filter_attribute.begin(), filter_attribute.end(), cfg[attribute].str(def)) != filter_attribute.end());
65 int value_def = def ? (*def) : 0;
70 const config& filter,
const config& cfg,
const std::string& attribute,
const std::string& opposite, std::optional<int> def)
82 int value_def = def ? (*def) : 0;
98 double value_def = def ? (*def) : 1;
108 std::set<std::string> filter_attribute =
utils::split_set(filter[attribute].str());
109 bool is_matches =
false;
111 if(filter_attribute.count(
"yes") != 0 || filter_attribute.count(
"true") != 0){
112 is_matches = cfg[attribute].to_bool();
114 if(!is_matches && (filter_attribute.count(
"no") != 0 || filter_attribute.count(
"false") != 0)){
115 is_matches = !cfg[attribute].to_bool();
118 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 unsigned_matches_if_present(const config &filter, const config &cfg, const std::string &attribute)
Restricts filters to only looking for values that are zero or more.
bool int_matches_if_present(const config &filter, const config &cfg, const std::string &attribute, std::optional< int > def=std::nullopt)
bool string_matches_if_present(const config &filter, const config &cfg, const std::string &attribute, const std::string &def)
bool double_matches_if_present(const config &filter, const config &cfg, const std::string &attribute, std::optional< double > def=std::nullopt)
Checks whether the filter matches the value of cfg[attribute].
bool bool_or_empty(const config &filter, const config &cfg, const std::string &attribute)
bool int_matches_if_present_or_negative(const config &filter, const config &cfg, const std::string &attribute, const std::string &opposite, std::optional< int > def=std::nullopt)
Supports filters using "add" and "sub" attributes, for example a filter add=1 matching a cfg containi...
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< int, int > > parse_ranges_unsigned(const std::string &str)
Handles a comma-separated list of inputs to parse_range, in a context that does not expect negative v...
std::vector< std::pair< double, double > > parse_ranges_real(const std::string &str)
std::vector< std::string > split(const config_attribute_value &val)