21template <
typename TRanges,
typename TBase>
22class NumValueMultiRangeValidator :
public TBase
24 using BaseImpl = TBase;
26 static_assert(comms::util::isTuple<TRanges>(),
"TRanges must be a tuple");
30 using ValueType =
typename BaseImpl::ValueType;
33 std::is_integral<ValueType>::value || std::is_enum<ValueType>::value || std::is_floating_point<ValueType>::value,
34 "Only numeric fields are supported for multi range validation.");
36 NumValueMultiRangeValidator() =
default;
38 explicit NumValueMultiRangeValidator(
const ValueType& val)
43 explicit NumValueMultiRangeValidator(ValueType&& val)
44 : BaseImpl(
std::move(val))
48 NumValueMultiRangeValidator(
const NumValueMultiRangeValidator&) =
default;
49 NumValueMultiRangeValidator(NumValueMultiRangeValidator&&) =
default;
50 NumValueMultiRangeValidator& operator=(
const NumValueMultiRangeValidator&) =
default;
51 NumValueMultiRangeValidator& operator=(NumValueMultiRangeValidator&&) =
default;
55 return BaseImpl::valid() &&
56 comms::util::tupleTypeAccumulate<TRanges>(
false, Validator(BaseImpl::getValue()));
63 Validator(ValueType val) : m_val(val) {}
65 template <
typename TRange>
66 bool operator()(
bool val)
const
68 static_cast<void>(val);
69 static_assert(comms::util::isTuple<TRange>(),
"TRange must be a tuple");
70 static_assert(std::tuple_size<TRange>::value == 2,
"Tuple with 2 elements is expected");
71 using MinVal =
typename std::tuple_element<0, TRange>::type;
72 using MaxVal =
typename std::tuple_element<1, TRange>::type;
73 static_assert(MinVal::value <= MaxVal::value,
"Invalid range");
76 ((
static_cast<ValueType
>(MinVal::value) <= m_val) &&
77 (m_val <= static_cast<ValueType>(MaxVal::value)));
Contains various tuple type manipulation classes and functions.
Main namespace for all classes / functions of COMMS library.