libcamgm
ValueCheck.hpp
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | |
3 | _ _ _ _ __ _ |
4 | | | | | | \_/ | / \ | | |
5 | | | | | | |_| | / /\ \ | | |
6 | | |__ | | | | | | / ____ \ | |__ |
7 | |____||_| |_| |_|/ / \ \|____| |
8 | |
9 | core library |
10 | |
11 | (C) SUSE Linux Products GmbH |
12 \----------------------------------------------------------------------/
13 
14  File: ValueCheck.hpp
15 
16  Author: Marius Tomaschewski
17  Maintainer: Marius Tomaschewski
18 
19  Purpose:
20 
21 /-*/
26 #ifndef CA_MGM_VALUE_CHECK_HPP
27 #define CA_MGM_VALUE_CHECK_HPP
28 
29 #include <ca-mgm/config.h>
30 #include <ca-mgm/String.hpp>
32 #include <list>
33 
34 namespace CA_MGM_NAMESPACE
35 {
36 
40 class ValueCheck;
41 
42 // -------------------------------------------------------------------
55 {
56 public:
60  virtual
62  {
63  }
64 
81  virtual bool
82  isValid(const std::string &value) const = 0;
83 
100  virtual std::string
101  explain(const std::string &value) const = 0;
102 
103 protected:
108  : ReferenceCounted()
109  {
110  }
111 
112 private:
119  : ReferenceCounted(r)
120  {}
121 
125  ValueCheckBase & operator = (const ValueCheckBase &r);
126 
127 
132  friend class ValueCheck;
133 
134 };
135 
136 
137 // -------------------------------------------------------------------
189 {
190 public:
197  ValueCheck();
198 
203  ValueCheck(ValueCheckBase *check);
204 
210  ValueCheck & operator=(ValueCheckBase *check);
211 
216  ValueCheck(const ValueCheck &ref);
217 
223  ValueCheck & operator=(const ValueCheck &ref);
224 
228  virtual ~ValueCheck();
229 
238  virtual bool
239  isValid(const std::string &value) const;
240 
248  virtual std::string
249  explain(const std::string &value) const;
250 
258  ValueCheck&
259  And(const ValueCheck &ref);
260 
268  ValueCheck&
269  And(ValueCheckBase *check);
270 
278  ValueCheck&
279  Or(const ValueCheck &ref);
280 
288  ValueCheck&
289  Or(ValueCheckBase *check);
290 
307  ValueCheck&
308  Not();
309 
310 private:
311  /*
312  ** Relationship operators
313  */
314  enum ECheckOp { E_AND, E_OR };
315 
324  ValueCheck(const ValueCheck &ref, ECheckOp op);
325 
330  void
331  incRCnt(ValueCheckBase *ptr);
332 
338  void
339  delRCnt(ValueCheckBase *ptr);
340 
345 
349  bool m_neg;
350 
355 
359  std::list<ValueCheck> m_list;
360 };
361 
362 
363 } // End of CA_MGM_NAMESPACE
364 #endif // CA_MGM_VALUE_CHECK_HPP
365 // vim: set ts=8 sts=8 sw=8 ai noet:
std::list< ValueCheck > m_list
Definition: ValueCheck.hpp:359
ValueCheckBase(const ValueCheckBase &r)
Definition: ValueCheck.hpp:118
virtual ~ValueCheckBase()
Definition: ValueCheck.hpp:61
ValueCheckBase * m_self
Definition: ValueCheck.hpp:354
Definition: ReferenceCounted.hpp:31
Expression chain for checking values.
Definition: ValueCheck.hpp:188
ECheckOp
Definition: ValueCheck.hpp:314
ECheckOp m_cop
Definition: ValueCheck.hpp:344
ValueCheckBase()
Definition: ValueCheck.hpp:107
bool m_neg
Definition: ValueCheck.hpp:349
Base class to check a value.
Definition: ValueCheck.hpp:54