50#include <wx/variant.h>
80 return wxT(
"any value");
84 using Holder = std::unique_ptr<Validator>;
93 return std::make_unique<DefaultValidator>(*
this);
118 wxString
desc =
wxT(
"one of: ");
121 for (i = 0; i+1 < optionCount; ++i)
130 auto v = std::make_unique<OptionValidator>();
143 if (!v.Convert(&val))
return false;
149 return wxT(
"true/false or 1/0 or yes/no");
153 return std::make_unique<BoolValidator>();
163 if (!v.Convert(&val))
166 for(
size_t i=0; i != val.length(); i++)
167 if( val[i] !=
'0' && val[i] !=
'1' && val[i] !=
'x' && val[i] !=
'X')
173 return wxT(
"0X101XX101...etc. where 0=false, 1=true, and X=don't care. Numbering starts at leftmost = track 0");
177 return std::make_unique<BoolArrayValidator>();
187 if (!v.Convert(&val))
return false;
193 return wxT(
"a floating-point number");
197 return std::make_unique<DoubleValidator>();
212 if (!v.Convert(&val))
return false;
222 return std::make_unique<RangeValidator>(
mLower,
mUpper);
232 if (!v.Convert(&val))
return false;
235 return ((
long)val == val);
239 return wxT(
"an integer");
243 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