root / trunk / tbeta / OSX / libs / poco / include / Poco / Net / HostEntry.h @ 151

View | Annotate | Download (3.4 KB)

1
//
2
// HostEntry.h
3
//
4
// $Id: //poco/1.3/Net/include/Poco/Net/HostEntry.h#1 $
5
//
6
// Library: Net
7
// Package: NetCore
8
// Module:  HostEntry
9
//
10
// Definition of the HostEntry class.
11
//
12
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
13
// and Contributors.
14
//
15
// Permission is hereby granted, free of charge, to any person or organization
16
// obtaining a copy of the software and accompanying documentation covered by
17
// this license (the "Software") to use, reproduce, display, distribute,
18
// execute, and transmit the Software, and to prepare derivative works of the
19
// Software, and to permit third-parties to whom the Software is furnished to
20
// do so, all subject to the following:
21
// 
22
// The copyright notices in the Software and this entire statement, including
23
// the above license grant, this restriction and the following disclaimer,
24
// must be included in all copies of the Software, in whole or in part, and
25
// all derivative works of the Software, unless such copies or derivative
26
// works are solely in the form of machine-executable object code generated by
27
// a source language processor.
28
// 
29
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35
// DEALINGS IN THE SOFTWARE.
36
//
37
38
39
#ifndef Net_HostEntry_INCLUDED
40
#define Net_HostEntry_INCLUDED
41
42
43
#include "Poco/Net/Net.h"
44
#include "Poco/Net/SocketDefs.h"
45
#include "Poco/Net/IPAddress.h"
46
#include <vector>
47
48
49
namespace Poco {
50
namespace Net {
51
52
53
class Net_API HostEntry
54
        /// This class stores information about a host
55
        /// such as host name, alias names and a list
56
        /// of IP addresses.
57
{
58
public:
59
        typedef std::vector<std::string> AliasList;
60
        typedef std::vector<IPAddress>   AddressList;
61
        
62
        HostEntry();
63
                /// Creates an empty HostEntry.
64
                
65
        HostEntry(struct hostent* entry);
66
                /// Creates the HostEntry from the data in a hostent structure.
67
68
#if defined(_WIN32) && defined(POCO_HAVE_IPv6)
69
        HostEntry(struct addrinfo* info);
70
                /// Creates the HostEntry from the data in a Windows addrinfo structure.
71
#endif
72
73
        HostEntry(const HostEntry& entry);
74
                /// Creates the HostEntry by copying another one.
75
76
        HostEntry& operator = (const HostEntry& entry);
77
                /// Assigns another HostEntry.
78
79
        void swap(HostEntry& hostEntry);
80
                /// Swaps the HostEntry with another one.        
81
82
        ~HostEntry();
83
                /// Destroys the HostEntry.
84
85
        const std::string& name() const;
86
                /// Returns the canonical host name.
87
88
        const AliasList& aliases() const;
89
                /// Returns a vector containing alias names for
90
                /// the host name.
91
92
        const AddressList& addresses() const;
93
                /// Returns a vector containing the IPAddresses
94
                /// for the host.
95
96
private:
97
        std::string _name;
98
        AliasList   _aliases;
99
        AddressList _addresses;
100
};
101
102
103
//
104
// inlines
105
//
106
inline const std::string& HostEntry::name() const
107
{
108
        return _name;
109
}
110
111
112
inline const HostEntry::AliasList& HostEntry::aliases() const
113
{
114
        return _aliases;
115
}
116
117
118
inline const HostEntry::AddressList& HostEntry::addresses() const
119
{
120
        return _addresses;
121
}
122
123
124
inline void swap(HostEntry& h1, HostEntry& h2)
125
{
126
        h1.swap(h2);
127
}
128
129
130
} } // namespace Poco::Net
131
132
133
#endif // Net_HostEntry_INCLUDED