libUTL++
NamedObjectMI.h
1 #pragma once
2 
4 
5 #include <libutl/String.h>
6 
8 
9 UTL_NS_BEGIN;
10 
12 
22 
25 {
26 public:
31  {
32  }
33 
38  NamedObjectMI(const String& name)
39  {
40  setName(name);
41  }
42 
44  void
46  {
47  _name.clear();
48  }
49 
50  int
51  compare(const NamedObjectMI& rhs) const
52  {
53  return _name.compare(rhs._name);
54  }
55 
56  void
57  copy(const NamedObjectMI& rhs)
58  {
59  _name = rhs._name;
60  }
61 
62  void
63  serialize(Stream& stream, uint_t io, uint_t mode = ser_default)
64  {
65  _name.serialize(stream, io, mode);
66  }
67 
69  const String&
70  getName() const
71  {
72  return _name;
73  }
74 
76  const String*
77  getNamePtr() const
78  {
79  if (_name.empty()) return nullptr;
80  return &_name;
81  }
82 
84  void
85  setName(const String& name)
86  {
87  _name = name;
88  }
89 
90 private:
91  String _name;
92 };
93 
95 
96 UTL_NS_END;
void setName(const String &name)
Set the name.
Definition: NamedObjectMI.h:85
Named object mix-in.
Definition: NamedObjectMI.h:24
void serialize(bool &b, Stream &stream, uint_t io, uint_t mode=ser_default)
Serialize a boolean.
default representation (via getSerializeMode())
Definition: util.h:75
Character string.
Definition: String.h:31
void copy(T *dest, const T *src, size_t len)
Copy one array of objects to another.
Definition: util_inl.h:690
const String & getName() const
Get the name.
Definition: NamedObjectMI.h:70
void clear()
Clear the name.
Definition: NamedObjectMI.h:45
const String * getNamePtr() const
Get the address of the name.
Definition: NamedObjectMI.h:77
unsigned int uint_t
Unsigned integer.
Definition: types.h:59
Stream I/O abstraction.
Definition: Stream.h:68
int compare(bool lhs, bool rhs)
Compare two boolean values.
NamedObjectMI(const String &name)
Constructor.
Definition: NamedObjectMI.h:38
NamedObjectMI()
Constructor.
Definition: NamedObjectMI.h:30