51#include <wx/variant.h>
81 return wxT(
"any value");
85 using Holder = std::unique_ptr<Validator>;
94 return std::make_unique<DefaultValidator>(*
this);
119 wxString
desc =
wxT(
"one of: ");
122 for (i = 0; i+1 < optionCount; ++i)
131 auto v = std::make_unique<OptionValidator>();
144 if (!v.Convert(&val))
return false;
150 return wxT(
"true/false or 1/0 or yes/no");
154 return std::make_unique<BoolValidator>();
164 if (!v.Convert(&val))
167 for(
size_t i=0; i != val.length(); i++)
168 if( val[i] !=
'0' && val[i] !=
'1' && val[i] !=
'x' && val[i] !=
'X')
174 return wxT(
"0X101XX101...etc. where 0=false, 1=true, and X=don't care. Numbering starts at leftmost = track 0");
178 return std::make_unique<BoolArrayValidator>();
188 if (!v.Convert(&val))
return false;
194 return wxT(
"a floating-point number");
198 return std::make_unique<DoubleValidator>();
213 if (!v.Convert(&val))
return false;
223 return std::make_unique<RangeValidator>(
mLower,
mUpper);
233 if (!v.Convert(&val))
return false;
236 return ((
long)val == val);
240 return wxT(
"an integer");
244 return std::make_unique<IntValidator>();
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Parameter must be char array of booleans, e.g. "011010001".
wxString GetDescription() const override
virtual bool Validate(const wxVariant &v) override
Judge whether the passed value satisfies the Validator.
Holder GetClone() const override
Parameter must be a boolean.
bool Validate(const wxVariant &v) override
Judge whether the passed value satisfies the Validator.
Holder GetClone() const override
wxString GetDescription() const override
virtual Holder GetClone() const
Parameter must be a floating-point number.
bool Validate(const wxVariant &v) override
Judge whether the passed value satisfies the Validator.
Holder GetClone() const override
wxString GetDescription() const override
Parameter must be integral.
bool Validate(const wxVariant &v) override
Judge whether the passed value satisfies the Validator.
Holder GetClone() const override
wxString GetDescription() const override
Parameter must be one of the defined options.
bool Validate(const wxVariant &v) override
Judge whether the passed value satisfies the Validator.
void AddOption(const wxString &option)
Holder GetClone() const override
wxString GetDescription() const override
void AddOptions(const wxArrayString &options)
Parameter must lie between the two given numbers.
RangeValidator(double l, double u)
Holder GetClone() const override
bool Validate(const wxVariant &v) override
Judge whether the passed value satisfies the Validator.
wxString GetDescription() const override
A Validator is an object which checks whether a wxVariant satisfies a certain criterion....
virtual Holder GetClone() const =0
virtual wxString GetDescription() const
const wxVariant & GetConverted()
void SetConverted(const wxVariant &v)
std::unique_ptr< Validator > Holder
This MUST be overridden, to avoid slicing!
virtual bool Validate(const wxVariant &v)
Judge whether the passed value satisfies the Validator.
const TranslatableString desc