1#ifndef CHITECH_ALLOWABLE_RANGE_H
2#define CHITECH_ALLOWABLE_RANGE_H
35 std::stringstream outstr;
37 if (not scope.empty()) outstr <<
"Parameter \"" << scope <<
"\": ";
39 outstr <<
"Value " << vvalue <<
" out of range. ";
62 for (
const auto& val : raw_list)
63 list_.emplace_back(val);
69 for (
const auto& val : raw_list)
70 list_.emplace_back(val);
74 static std::unique_ptr<AllowableRangeList>
75 New(
const std::initializer_list<T>& raw_list)
77 return std::unique_ptr<AllowableRangeList>{
82 static std::unique_ptr<AllowableRangeList>
83 New(
const std::vector<T>& raw_list)
85 return std::unique_ptr<AllowableRangeList>{
96 std::stringstream outstr;
97 for (
const auto& value :
list_)
100 if (value !=
list_.back()) outstr <<
", ";
106class AllowableRangeLowHighLimit;
117 template <
typename T>
123 template <
typename T>
124 static std::unique_ptr<AllowableRangeLowLimit>
New(
const T& low_value,
125 bool low_closed =
true)
127 return std::unique_ptr<AllowableRangeLowLimit>{
158 template <
typename T>
164 template <
typename T>
165 static std::unique_ptr<AllowableRangeHighLimit>
New(
const T& hi_value,
166 bool hi_closed =
true)
168 return std::unique_ptr<AllowableRangeHighLimit>{
199 template <
typename T>
202 bool low_closed =
true,
203 bool hi_closed =
true)
209 template <
typename T>
210 static std::unique_ptr<AllowableRangeLowHighLimit>
New(
const T& low_value,
212 bool low_closed =
true,
213 bool hi_closed =
true)
215 return std::unique_ptr<AllowableRangeLowHighLimit>{
217 low_value, hi_value, low_closed, hi_closed)};
AllowableRangeHighLimit(const T &hi_value, bool hi_closed=true)
std::string AllowableRangeStr() const override
static std::unique_ptr< AllowableRangeHighLimit > New(const T &hi_value, bool hi_closed=true)
bool ChildIsAllowable(Varying value) const override
virtual ~AllowableRange()=default
std::string OutOfRangeString(const std::string &scope, const T &value) const
virtual bool ChildIsAllowable(Varying value) const =0
virtual std::string AllowableRangeStr() const =0
bool IsAllowable(const T &value)
std::string AllowableRangeStr() const override
AllowableRangeList(const std::initializer_list< T > &raw_list)
AllowableRangeList(const std::vector< T > &raw_list)
static std::unique_ptr< AllowableRangeList > New(const std::vector< T > &raw_list)
bool ChildIsAllowable(Varying value) const override
std::vector< Varying > list_
static std::unique_ptr< AllowableRangeList > New(const std::initializer_list< T > &raw_list)
AllowableRangeHighLimit hi_range
AllowableRangeLowHighLimit(const T &low_value, const T &hi_value, bool low_closed=true, bool hi_closed=true)
static std::unique_ptr< AllowableRangeLowHighLimit > New(const T &low_value, const T &hi_value, bool low_closed=true, bool hi_closed=true)
std::string AllowableRangeStr() const override
AllowableRangeLowLimit low_range_
bool ChildIsAllowable(Varying value) const override
std::string AllowableRangeStr() const override
AllowableRangeLowLimit(const T &low_value, bool low_closed=true)
static std::unique_ptr< AllowableRangeLowLimit > New(const T &low_value, bool low_closed=true)
bool ChildIsAllowable(Varying value) const override
std::string PrintStr(bool with_type=true) const
VaryingDataType Type() const