39 #ifndef OME_XML_MODEL_PRIMITIVES_CONSTRAINEDNUMERIC_H
40 #define OME_XML_MODEL_PRIMITIVES_CONSTRAINEDNUMERIC_H
46 #include <boost/format.hpp>
47 #include <boost/operators.hpp>
79 const std::string& typestr)
81 boost::format fmt(
"‘%1%’ not a supported value of %2%");
82 fmt % value % typestr;
83 throw std::invalid_argument(fmt.str());
118 typename E = ConstrainedNumericError>
120 boost::partially_ordered<ConstrainedNumeric<N, C, E>,
121 boost::equality_comparable2<ConstrainedNumeric<N, C, E>, N,
122 boost::equality_comparable<ConstrainedNumeric<N, C, E>,
123 boost::addable2<ConstrainedNumeric<N, C, E>, N,
124 boost::addable<ConstrainedNumeric<N, C, E>,
125 boost::subtractable2<ConstrainedNumeric<N, C, E>, N,
126 boost::subtractable<ConstrainedNumeric<N, C, E>,
127 boost::dividable2<ConstrainedNumeric<N, C, E>, N,
128 boost::dividable<ConstrainedNumeric<N, C, E>,
129 boost::multipliable2<ConstrainedNumeric<N, C, E>, N,
130 boost::multipliable<ConstrainedNumeric<N, C, E>,
131 boost::incrementable<ConstrainedNumeric<N, C, E>,
132 boost::decrementable<ConstrainedNumeric<N, C, E> > > > > > > > > > > > > > >
182 std::istringstream is(value);
183 is.imbue(std::locale::classic());
188 error_policy_type error;
229 this->value = value.
value;
261 this->value += value.
value;
277 this->value -= value.
value;
293 this->value *= value.
value;
309 this->value /= value.
value;
325 this->value %= value.
value;
341 this->value +=
value;
357 this->value -=
value;
373 this->value *=
value;
389 this->value /=
value;
405 this->value %=
value;
448 return this->value < value.
value;
461 return this->value <
value;
477 return this->value >
value;
490 return this->value == value.
value;
503 return this->value ==
value;
516 constraint_type constraint;
517 if (!constraint(this->
value))
519 error_policy_type error;
536 template<
class _charT,
542 std::basic_istream<_charT,_traits>&
543 operator>> (std::basic_istream<_charT,_traits>& is,
554 template<
class charT,
559 inline std::basic_istream<charT,traits>&
567 boost::format fmt(
"Failed to parse invalid input for %1%");
569 throw std::invalid_argument(fmt.str());
584 template<
class charT,
589 inline std::basic_ostream<charT,traits>&
590 operator<< (std::basic_ostream<charT,traits>& os,
593 return os << static_cast<typename ConstrainedNumeric<N, C, E>::value_type>(value);
601 #endif // OME_XML_MODEL_PRIMITIVES_CONSTRAINEDNUMERIC_H
C constraint_type
The constraint to impose.
Definition: ConstrainedNumeric.h:138
value_type value
The value being constrained.
Definition: ConstrainedNumeric.h:525
ConstrainedNumeric & operator%=(const ConstrainedNumeric &value)
Modulo of the constrained value by a constrained value.
Definition: ConstrainedNumeric.h:323
ConstrainedNumeric(const ConstrainedNumeric &value)
Copy constructor.
Definition: ConstrainedNumeric.h:200
static const value_type default_value
Default value for default construction.
Definition: ConstrainedNumeric.h:143
ConstrainedNumeric & operator-=(const ConstrainedNumeric &value)
Subtract a constrained value from the constrained value.
Definition: ConstrainedNumeric.h:275
friend std::basic_istream< _charT, _traits > & operator>>(std::basic_istream< _charT, _traits > &is, ConstrainedNumeric< _N, _C, _E > &value)
Set constrained value from input stream.
bool operator>(const value_type &value) const
Check if the constrained value is greater than an unconstrained value.
Definition: ConstrainedNumeric.h:475
Open Microscopy Environment C++ implementation.
Definition: CoreMetadata.cpp:40
E error_policy_type
The error policy to apply on constraint violation.
Definition: ConstrainedNumeric.h:140
ConstrainedNumeric & operator*=(const ConstrainedNumeric &value)
Multiply the constrained value by a constrained value.
Definition: ConstrainedNumeric.h:291
bool operator==(const ConstrainedNumeric &value) const
Check if the constrained value is equal to a constrained value.
Definition: ConstrainedNumeric.h:488
ConstrainedNumeric(value_type value)
Construct a ConstrainedNumeric from an unconstrained value.
Definition: ConstrainedNumeric.h:167
void check()
Check that the set value meets the required constraints, and if it does not, handle this according to...
Definition: ConstrainedNumeric.h:514
static const std::string typestr
The name of the type. Used for diagnostics only.
Definition: ConstrainedNumeric.h:527
ConstrainedNumeric & operator/=(const ConstrainedNumeric &value)
Divide the constrained value by a constrained value.
Definition: ConstrainedNumeric.h:307
ConstrainedNumeric & operator--()
Decrement the constrained value by one.
Definition: ConstrainedNumeric.h:431
Default error handler for ConstrainedNumeric.
Definition: ConstrainedNumeric.h:67
void operator()(const T &value, const std::string &typestr)
Throw an exception.
Definition: ConstrainedNumeric.h:78
ConstrainedNumeric & operator+=(const ConstrainedNumeric &value)
Add a constrained value to the constrained value.
Definition: ConstrainedNumeric.h:259
ConstrainedNumeric & operator++()
Increment the constrained value by one.
Definition: ConstrainedNumeric.h:417
std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &is, Color &color)
Set Color from input stream.
Definition: Color.h:472
bool operator<(const ConstrainedNumeric &value) const
Check if the constrained value is less than a constrained value.
Definition: ConstrainedNumeric.h:446
N value_type
The type to constrain.
Definition: ConstrainedNumeric.h:136
ConstrainedNumeric & operator=(const ConstrainedNumeric &value)
Assign the constrained value from a constrained value.
Definition: ConstrainedNumeric.h:227
ConstrainedNumeric()
Construct a ConstrainedNumeric.
Definition: ConstrainedNumeric.h:154
ConstrainedNumeric(const std::string &value)
Construct a ConstrainedNumeric a string value.
Definition: ConstrainedNumeric.h:180
A numeric type constrained to a subrange (or subranges) of its range limits.
Definition: ConstrainedNumeric.h:119
Xerces-C modern C++ wrapper.
Definition: Base.h:53