libcamgm
Public Member Functions | Private Attributes | List of all members
ca_mgm::ValueIntCheck Class Reference

Integer range value check. More...

#include <ValueIntCheck.hpp>

Inheritance diagram for ca_mgm::ValueIntCheck:
ca_mgm::ValueCheckBase ca_mgm::ReferenceCounted

Public Member Functions

 ValueIntCheck (uint64_t minValue, uint64_t maxValue, bool inclusiveRange=true)
 
 ValueIntCheck (int64_t minValue, int64_t maxValue, bool inclusiveRange=true)
 
 ValueIntCheck (int minValue, int maxValue, bool inclusiveRange=true)
 
virtual bool isValid (const std::string &value) const
 
virtual std::string explain (const std::string &value) const
 
- Public Member Functions inherited from ca_mgm::ValueCheckBase
virtual ~ValueCheckBase ()
 
- Public Member Functions inherited from ca_mgm::ReferenceCounted
 ReferenceCounted ()
 
 ReferenceCounted (const ReferenceCounted &rhs)
 
virtual ~ReferenceCounted ()
 
ReferenceCountedoperator= (const ReferenceCounted &)
 
unsigned refCount () const
 
void ref () const
 
void unref () const
 

Private Attributes

bool m_sign
 
bool m_incl
 
union {
   int64_t   s
 
   uint64_t   u
 
m_min
 
union {
   int64_t   s
 
   uint64_t   u
 
m_max
 

Additional Inherited Members

- Static Public Member Functions inherited from ca_mgm::ReferenceCounted
static void add_ref (const ReferenceCounted *ptr_r)
 
static void release (const ReferenceCounted *ptr_r)
 
- Protected Member Functions inherited from ca_mgm::ValueCheckBase
 ValueCheckBase ()
 
- Protected Member Functions inherited from ca_mgm::ReferenceCounted
virtual std::ostream & dumpOn (std::ostream &str) const
 
virtual void ref_to (unsigned) const
 
virtual void unref_to (unsigned) const
 

Detailed Description

Integer range value check.

The ValueIntCheck implements a simple integer range check that can be used in ValueCheck.

Constructor & Destructor Documentation

ca_mgm::ValueIntCheck::ValueIntCheck ( uint64_t  minValue,
uint64_t  maxValue,
bool  inclusiveRange = true 
)

Constructor using a UInt64 range.

Parameters
minValueMinimal value for the range.
maxValueMaximal value for the range.
inclusiveRangeWhether to check if the value is less (inclusiveRange=false) if less or equal the maxValue.
ca_mgm::ValueIntCheck::ValueIntCheck ( int64_t  minValue,
int64_t  maxValue,
bool  inclusiveRange = true 
)

Constructor using a Int64 range.

Parameters
minValueMinimal value for the range.
maxValueMaximal value for the range.
inclusiveRangeWhether to check if the value is less (inclusiveRange=false) if less or equal the maxValue.
ca_mgm::ValueIntCheck::ValueIntCheck ( int  minValue,
int  maxValue,
bool  inclusiveRange = true 
)

Constructor using int range.

Note: This constructor will be used by default, if you simply call:

 ValueIntCheck(0, 42)

To avoid conversion problems on 64 bit integers, you should choose the right constructors:

 ValueIntCheck( Int64(0),  Int64(42))
 ValueIntCheck(UInt64(0), UInt64(42))

instead...

Parameters
minValueMinimal value for the range.
maxValueMaximal value for the range.
inclusiveRangeWhether to check if the value is less (inclusiveRange=false) if less or equal the maxValue.

Member Function Documentation

virtual std::string ca_mgm::ValueIntCheck::explain ( const std::string &  value) const
virtual

Return a string showing the integer range check.

Parameters
valueA string value.
Returns
A string showing the check.

Implements ca_mgm::ValueCheckBase.

virtual bool ca_mgm::ValueIntCheck::isValid ( const std::string &  value) const
virtual

Return whether the specified value is fits into the integer range.

Parameters
valueA string value.
Returns
true, if the value fits into the range.
Exceptions
std::stringConversionExceptionif the value can't be converted to a integer value.

Implements ca_mgm::ValueCheckBase.

Member Data Documentation

bool ca_mgm::ValueIntCheck::m_incl
private
union { ... } ca_mgm::ValueIntCheck::m_max
union { ... } ca_mgm::ValueIntCheck::m_min
bool ca_mgm::ValueIntCheck::m_sign
private
int64_t ca_mgm::ValueIntCheck::s
uint64_t ca_mgm::ValueIntCheck::u

The documentation for this class was generated from the following file: