Validated.h
Go to the documentation of this file.
1 #ifndef _utl_Validated_h_
2 #define _utl_Validated_h_
3 
4 #include <utl/VValidated.h>
5 
6 
7 namespace utl {
8 
55  template<typename T>
56  class Validated : public VValidated {
57  public:
58  Validated() { }
59 
60  Validated(const T& value) : fIsValid(true), fValue(value) { }
61 
62  Validated& operator=(const T& value) { Set(value); return *this; }
63 
64  bool IsValid() const { return fIsValid; }
65 
66  void SetValid(const bool valid = true) { fIsValid = valid; }
67 
68  T& Get() { return fValue; }
69 
70  const T& Get() const { return fValue; }
71 
72  void Set(const T& value) { fIsValid = true; fValue = value; }
73 
74  private:
75  bool fIsValid = false;
76  T fValue;
77  };
78 
79 }
80 
81 #endif
Validated(const T &value)
Definition: Validated.h:60
Validated & operator=(const T &value)
Definition: Validated.h:62
Wrapper class for initially unset data.
Definition: ResponseMap.h:17
void Set(const T &value)
Definition: Validated.h:72
bool IsValid() const
Definition: Validated.h:64
void SetValid(const bool valid=true)
Definition: Validated.h:66
const T & Get() const
Definition: Validated.h:70

, generated on Tue Sep 26 2023.