1 #ifndef NUMERICFILTER_HPP 2 #define NUMERICFILTER_HPP 4 #include <SFML/System/String.hpp> 9 template<
class T=
double>
19 NumericFilter(T min = -INFINITY, T max = INFINITY,
bool clamp =
true,
bool eofCheck =
true,
bool allowEmpty =
true) :
22 allowEmpty(allowEmpty) {
32 bool operator()(sf::String& str) {
33 if((allowEmpty && str.isEmpty()) || (str ==
"-" && min < 0)) {
36 str.replace(
",",
".");
39 std::istringstream ss(str);
41 if(ss.fail() || (eofCheck && !ss.eof())) {
46 str = sf::String(std::to_string(min));
47 }
else if(num > max) {
48 str = sf::String(std::to_string(max));
51 }
else if(num < min || num > max) {
58 void setClamp(
bool value) {
61 void setMin(
const T& value) {
64 if(test > 0 && value < 0) {
70 void setMax(
const T& value) {
73 if(test > 0 && value < 0) {
81 #endif // NUMERICFILTER_HPP Definition: NumericFilter.hpp:10