libUTL++
Bool.h
1 #pragma once
2 
4 
5 #include <libutl/String.h>
6 
8 
9 UTL_NS_BEGIN;
10 
12 
20 
22 class Bool : public Object
23 {
25 
26 public:
31  Bool(bool b)
32  {
33  set(b);
34  }
35 
40  Bool(const String& str)
41  {
42  set(str);
43  }
44 
45  virtual int compare(const Object& rhs) const;
46 
47  virtual void copy(const Object& rhs);
48 
49  virtual void serialize(Stream& stream, uint_t io, uint_t mode = ser_default);
50 
52  virtual String toString() const;
53 
55  bool
56  get() const
57  {
58  return _b;
59  }
60 
65  void set(const String& str);
66 
68  void
69  set(bool b)
70  {
71  _b = b;
72  }
73 
75  operator bool() const
76  {
77  return _b;
78  }
79 
81  operator bool()
82  {
83  return _b;
84  }
85 
86 private:
87  void
88  init()
89  {
90  _b = false;
91  }
92  void
93  deInit()
94  {
95  }
96 
97 private:
98  bool _b;
99 };
100 
102 
103 UTL_NS_END;
String toString(const FwdIt &begin, const FwdIt &end, const String &sep, bool key=false)
Obtain a string representation of a sequence (via Object::toString()).
void serialize(bool &b, Stream &stream, uint_t io, uint_t mode=ser_default)
Serialize a boolean.
void deInit()
De-initialize UTL++.
default representation (via getSerializeMode())
Definition: util.h:75
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition: macros.h:688
Character string.
Definition: String.h:31
Boolean value.
Definition: Bool.h:22
Bool(bool b)
Constructor.
Definition: Bool.h:31
void copy(T *dest, const T *src, size_t len)
Copy one array of objects to another.
Definition: util_inl.h:690
Bool(const String &str)
Constructor.
Definition: Bool.h:40
unsigned int uint_t
Unsigned integer.
Definition: types.h:59
Stream I/O abstraction.
Definition: Stream.h:68
Root of UTL++ class hierarchy.
Definition: Object.h:52
int compare(bool lhs, bool rhs)
Compare two boolean values.
void init()
Initialize UTL++.