libcamgm
|
Expression chain for checking values. More...
#include <ValueCheck.hpp>
Public Member Functions | |
ValueCheck () | |
ValueCheck (ValueCheckBase *check) | |
ValueCheck & | operator= (ValueCheckBase *check) |
ValueCheck (const ValueCheck &ref) | |
ValueCheck & | operator= (const ValueCheck &ref) |
virtual | ~ValueCheck () |
virtual bool | isValid (const std::string &value) const |
virtual std::string | explain (const std::string &value) const |
ValueCheck & | And (const ValueCheck &ref) |
ValueCheck & | And (ValueCheckBase *check) |
ValueCheck & | Or (const ValueCheck &ref) |
ValueCheck & | Or (ValueCheckBase *check) |
ValueCheck & | Not () |
![]() | |
virtual | ~ValueCheckBase () |
![]() | |
ReferenceCounted () | |
ReferenceCounted (const ReferenceCounted &rhs) | |
virtual | ~ReferenceCounted () |
ReferenceCounted & | operator= (const ReferenceCounted &) |
unsigned | refCount () const |
void | ref () const |
void | unref () const |
Private Types | |
enum | ECheckOp { E_AND, E_OR } |
Private Member Functions | |
ValueCheck (const ValueCheck &ref, ECheckOp op) | |
void | incRCnt (ValueCheckBase *ptr) |
void | delRCnt (ValueCheckBase *ptr) |
Private Attributes | |
ECheckOp | m_cop |
bool | m_neg |
ValueCheckBase * | m_self |
std::list< ValueCheck > | m_list |
Additional Inherited Members | |
![]() | |
static void | add_ref (const ReferenceCounted *ptr_r) |
static void | release (const ReferenceCounted *ptr_r) |
![]() | |
ValueCheckBase () | |
![]() | |
virtual std::ostream & | dumpOn (std::ostream &str) const |
virtual void | ref_to (unsigned) const |
virtual void | unref_to (unsigned) const |
![]() | |
void | intrusive_ptr_add_ref (const ReferenceCounted *ptr_r) |
void | intrusive_ptr_release (const ReferenceCounted *ptr_r) |
std::ostream & | operator<< (std::ostream &str, const ReferenceCounted &obj) |
Expression chain for checking values.
The ValueCheck class allows to construct a simple expression. It contains one or more single checks derived from ValueCheckBase or also sub-expressions, that are combined with And, Or and Not operators.
The check can be evaluated for a value using the isValid() method, showed as string with the explain() method and of course stored in a variable and used to check values multiple times.
|
private |
ca_mgm::ValueCheck::ValueCheck | ( | ) |
Default constructor. Since it does not contain any check, the isValid() and and explain() will throw an error until a check is assigned using the operator=().
ca_mgm::ValueCheck::ValueCheck | ( | ValueCheckBase * | check | ) |
Single check assignment constructor.
check | Pointer to a single check. |
ca_mgm::ValueCheck::ValueCheck | ( | const ValueCheck & | ref | ) |
Check expression copy constructor.
ref | Reference to a check expression. |
|
virtual |
Destructor.
|
private |
Private constructor used to add the value check reference to the current expression list.
ref | Reference to a value check. |
op | Relation to the current or last expression in the list. |
ValueCheck& ca_mgm::ValueCheck::And | ( | const ValueCheck & | ref | ) |
Append a sub-expression to the list of checks using the E_OR relationship operator.
ref | Reference to the sub-expression. |
ValueCheck& ca_mgm::ValueCheck::And | ( | ValueCheckBase * | check | ) |
Append a single check to the list of checks using the E_AND relationship operator.
check | Pointer to a single value check. |
|
private |
Decrement the reference counter of the check and delete the object if needed.
ptr | Pointer to a value check. |
|
virtual |
Returns a string explaining / showing the checks that will be done for the specified string value parameter.
value | A string value. |
Implements ca_mgm::ValueCheckBase.
|
private |
Increment the reference counter of the check.
ptr | Pointer to a value check. |
|
virtual |
Evaluates a the specified string value parameter to a boolean using the single checks and sub-expressions it contains.
value | The string value to evaluate. |
Implements ca_mgm::ValueCheckBase.
ValueCheck& ca_mgm::ValueCheck::Not | ( | ) |
Negate the result of the current expression.
ValueCheck& ca_mgm::ValueCheck::operator= | ( | ValueCheckBase * | check | ) |
Single check assignment operator.
check | Pointer to a single check. |
ValueCheck& ca_mgm::ValueCheck::operator= | ( | const ValueCheck & | ref | ) |
Check expression assignment operator.
ref | Reference to a check expression. |
ValueCheck& ca_mgm::ValueCheck::Or | ( | const ValueCheck & | ref | ) |
Append a sub-expression to the list of checks using the E_OR relationship operator.
ref | Reference to the sub-expression. |
ValueCheck& ca_mgm::ValueCheck::Or | ( | ValueCheckBase * | check | ) |
Append a single check to the list of checks using the E_OR relationship operator.
check | Pointer to a single value check. |
|
private |
Check relationship operator to the parent check.
|
private |
List of further checks in the chain.
|
private |
Whether to negate the result of the current chain.
|
private |
Pointer to the current (reference counted) check.