6 #ifndef TAPKEE_VALUE_KEEPER_H_ 7 #define TAPKEE_VALUE_KEEPER_H_ 15 namespace tapkee_internal
30 policy->copyFromValue(&value, &value_ptr);
40 policy->free(&value_ptr);
45 policy->clone(&(v.
value_ptr), &value_ptr);
50 policy->free(&value_ptr);
53 policy->clone(&(v.
value_ptr), &value_ptr);
65 if (isTypeCorrect<T>())
67 void* vv = policy->getValue(const_cast<void**>(&value_ptr));
68 v =
reinterpret_cast<T*
>(vv);
78 return getPolicy<T>() == policy;
83 return getPolicy<EmptyType>() != policy;
87 inline bool inRange(T lower, T upper)
const 89 if (!isTypeCorrect<T>() && isInitialized())
90 throw std::domain_error(
"Wrong range bounds type");
91 return checker->isInRange(&value_ptr,&lower,&upper);
95 inline bool equal(T value)
const 97 if (!isTypeCorrect<T>() && isInitialized())
98 throw std::domain_error(
"Wrong equality value type");
99 return checker->isEqual(&value_ptr,&value);
102 template <
typename T>
105 if (!isTypeCorrect<T>() && isInitialized())
106 throw std::domain_error(
"Wrong non-equality value type");
107 return checker->isNotEqual(&value_ptr,&value);
112 return checker->isPositive(&value_ptr);
117 return checker->isNonNegative(&value_ptr);
122 return checker->isNegative(&value_ptr);
127 return checker->isNonPositive(&value_ptr);
130 template <
typename T>
133 if (!isTypeCorrect<T>() && isInitialized())
134 throw std::domain_error(
"Wrong greater check bound type");
135 return checker->isGreater(&value_ptr,&lower);
138 template <
typename T>
141 if (!isTypeCorrect<T>() && isInitialized())
142 throw std::domain_error(
"Wrong lesser check bound type");
143 return checker->isLesser(&value_ptr,&upper);
bool isTypeCorrect() const
CheckerPolicyBase * checker
bool isInitialized() const
An exception type that is thrown in case of missed parameter, i.e. when some required parameter is no...
TypePolicyBase * getPolicy()
An exception type that is thrown in case if wrong parameter value is passed.
bool notEqual(T value) const
ValueKeeper(const T &value)
ValueKeeper(const ValueKeeper &v)
bool lesser(T upper) const
bool inRange(T lower, T upper) const
bool equal(T value) const
ValueKeeper & operator=(const ValueKeeper &v)
CheckerPolicyBase * getCheckerPolicy()
bool greater(T lower) const