libUTL++
InetHostname.h
1 #pragma once
2 
4 
5 #include <libutl/InetHostAddress.h>
6 #include <libutl/String.h>
7 
9 
10 UTL_NS_BEGIN;
11 
13 
14 class Collection;
15 
17 
25 
27 class InetHostname : public String
28 {
31 
32 public:
37  InetHostname(const String& hostName)
38  : String(hostName)
39  {
40  }
41 
46  InetHostname(const char* hostName)
47  : String(hostName)
48  {
49  }
50 
55  InetHostname(const InetHostAddress& hostAddr);
56 
58  InetHostAddress address() const;
59 
62  getAddress() const
63  {
64  return address();
65  }
66 
71  void addresses(Collection* collection) const;
72 
77  void
78  getAddresses(Collection* collection) const
79  {
80  addresses(collection);
81  }
82 
87  void aliases(Collection* collection) const;
88 
93  void
94  getAliases(Collection* collection) const
95  {
96  aliases(collection);
97  }
98 
100  static InetHostname localInetHostname();
101 
103  static InetHostname localFQDN();
104 
106  static String localDomainName();
107 
109  void set(const InetHostAddress& hostAddr);
110 };
111 
113 
114 UTL_NS_END;
#define UTL_CLASS_DEFID
Default init() and deInit() (which are merely place-holders).
Definition: macros.h:532
Internet host name.
Definition: InetHostname.h:27
#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
void getAliases(Collection *collection) const
Get all aliases for this hostname.
Definition: InetHostname.h:94
InetHostname(const char *hostName)
Constructor.
Definition: InetHostname.h:46
void getAddresses(Collection *collection) const
Get all addresses this hostname resolves to.
Definition: InetHostname.h:78
InetHostname(const String &hostName)
Constructor.
Definition: InetHostname.h:37
Internet host address.
A collection of objects.
Definition: Collection.h:62
InetHostAddress getAddress() const
Return the first/primary address this hostname resolves to.
Definition: InetHostname.h:62