Add str_upper and str_lower functions to WFL

This commit is contained in:
Celtic Minstrel 2016-12-18 14:29:42 -05:00
parent d46d713fb9
commit 9c8e597005
2 changed files with 28 additions and 0 deletions

View file

@ -10,6 +10,8 @@ Version 1.13.6+dev:
* Lua API:
* New attributes in side proxy:
num_units, num_villages, total_upkeep, expenses, net_income
* Wesnoth Formula Engine:
* New str_upper and str_lower functions for case transformations
* WML Engine:
* Removed LOW_MEM option when building.
* Add color= attribute to [floating_text]

View file

@ -519,6 +519,32 @@ private:
}
};
class str_upper_function : public function_expression {
public:
explicit str_upper_function(const args_list& args)
: function_expression("str_upper", args, 1, 1)
{}
private:
variant execute(const formula_callable& variables, formula_debugger* fdb) const {
std::string str = args()[0]->evaluate(variables, fdb).as_string();
std::transform(str.begin(), str.end(), str.begin(), std::toupper);
return variant(str);
}
};
class str_lower_function : public function_expression {
public:
explicit str_lower_function(const args_list& args)
: function_expression("str_lower", args, 1, 1)
{}
private:
variant execute(const formula_callable& variables, formula_debugger* fdb) const {
std::string str = args()[0]->evaluate(variables, fdb).as_string();
std::transform(str.begin(), str.end(), str.begin(), std::tolower);
return variant(str);
}
};
class sin_function : public function_expression {
public:
explicit sin_function(const args_list& args)