7 #ifndef H_PROPERTY_ACCESSOR 8 #define H_PROPERTY_ACCESSOR 11 #include "../../lib/safeint/SafeInt.hpp" 37 return ( x < min ) ? min : x;
47 return ( x > max ) ? max : x;
51 template <
int min,
int max>
88 template <
class T,
class constra
int = NoConstra
int>
98 SafeInt<T> operator()()
const {
return SafeInt<T>( _value ); }
99 SafeInt<T> operator()(
const T newValue )
101 _value = constraint::apply<T>( newValue );
102 return SafeInt<T>( _value );
108 _value = constraint::apply<T>( newValue );
125 #define PROPERTY_MAP( propName, type, key ) \ 126 type propName() const { return this->getmember<type, key>(); } \ 127 type propName( type tmp ) \ 129 this->setmember<type, key>( tmp ); \ 140 struct PropertyHelper
142 static const char* stringFromError( SafeIntError x )
144 const int numberOfErrors = 3;
145 const char* SafeIntErrorString[numberOfErrors] = {
"No error",
"Arithmetic overflow",
148 if ( x < numberOfErrors )
150 return SafeIntErrorString[x];
T operator()(const T newValue)
static T apply(const T x)
static T apply(const T x)
static T apply(const T x)
static T apply(const T x)