libUTL++
InetHostAddress.h
1 #pragma once
2 
4 
5 #include <libutl/Exception.h>
6 
8 
9 UTL_NS_BEGIN;
10 
12 
13 class InetHostname;
14 
16 
24 
26 class InetHostAddress : public Object
27 {
29 
30 public:
35  InetHostAddress(const InetHostname& hostName);
36 
41  InetHostAddress(const void* hostAddr);
42 
47  InetHostAddress(uint32_t hostAddr);
48 
56  InetHostAddress(uint_t b3, uint_t b2, uint_t b1, uint_t b0);
57 
58  virtual int compare(const Object& rhs) const;
59 
60  virtual void copy(const Object& rhs);
61 
62  virtual size_t hash(size_t size) const;
63 
64  virtual void serialize(Stream& stream, uint_t io, uint_t mode = ser_default);
65 
67  virtual String toString() const;
68 
70  void clear();
71 
73  uint32_t get() const;
74 
76  InetHostname getName() const;
77 
79  bool isNil() const;
80 
82  InetHostname name() const;
83 
85  void set(const InetHostname& hostName);
86 
91  void set(const void* hostAddr);
92 
97  void set(uint32_t hostAddr);
98 
106  void set(uint_t b3, uint_t b2, uint_t b1, uint_t b0);
107 
109  void
111  {
112  clear();
113  }
114 
115 private:
116  void init();
117 
118  void
119  deInit()
120  {
121  }
122 
123 private:
124  byte_t _hostAddr[4];
125 };
126 
128 
129 UTL_NS_END;
130 
132 
133 #include <libutl/InetHostname.h>
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++.
Internet host name.
Definition: InetHostname.h:27
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
unsigned char byte_t
Unsigned character.
Definition: types.h:31
Character string.
Definition: String.h:31
unsigned int uint32_t
Unsigned 32-bit integer.
Definition: types.h:115
void copy(T *dest, const T *src, size_t len)
Copy one array of objects to another.
Definition: util_inl.h:690
unsigned int uint_t
Unsigned integer.
Definition: types.h:59
void setNil()
Clear the address (zero it out).
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++.
Internet host address.