Documentation de SFML 2.5.0

Attention: cette page se réfère à une ancienne version de SFML. Cliquez ici pour passer à la dernière version.
IpAddress.hpp
1 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 #ifndef SFML_IPADDRESS_HPP
26 #define SFML_IPADDRESS_HPP
27 
29 // Headers
31 #include <SFML/Network/Export.hpp>
32 #include <SFML/System/Time.hpp>
33 #include <istream>
34 #include <ostream>
35 #include <string>
36 
37 
38 namespace sf
39 {
44 class SFML_NETWORK_API IpAddress
45 {
46 public:
47 
54  IpAddress();
55 
65  IpAddress(const std::string& address);
66 
79  IpAddress(const char* address);
80 
94  IpAddress(Uint8 byte0, Uint8 byte1, Uint8 byte2, Uint8 byte3);
95 
109  explicit IpAddress(Uint32 address);
110 
123  std::string toString() const;
124 
139  Uint32 toInteger() const;
140 
155  static IpAddress getLocalAddress();
156 
179  static IpAddress getPublicAddress(Time timeout = Time::Zero);
180 
182  // Static member data
184  static const IpAddress None;
185  static const IpAddress Any;
186  static const IpAddress LocalHost;
187  static const IpAddress Broadcast;
188 
189 private:
190 
191  friend SFML_NETWORK_API bool operator <(const IpAddress& left, const IpAddress& right);
192 
199  void resolve(const std::string& address);
200 
202  // Member data
204  Uint32 m_address;
205  bool m_valid;
206 };
207 
217 SFML_NETWORK_API bool operator ==(const IpAddress& left, const IpAddress& right);
218 
228 SFML_NETWORK_API bool operator !=(const IpAddress& left, const IpAddress& right);
229 
239 SFML_NETWORK_API bool operator <(const IpAddress& left, const IpAddress& right);
240 
250 SFML_NETWORK_API bool operator >(const IpAddress& left, const IpAddress& right);
251 
261 SFML_NETWORK_API bool operator <=(const IpAddress& left, const IpAddress& right);
262 
272 SFML_NETWORK_API bool operator >=(const IpAddress& left, const IpAddress& right);
273 
283 SFML_NETWORK_API std::istream& operator >>(std::istream& stream, IpAddress& address);
284 
294 SFML_NETWORK_API std::ostream& operator <<(std::ostream& stream, const IpAddress& address);
295 
296 } // namespace sf
297 
298 
299 #endif // SFML_IPADDRESS_HPP
300 
301 
Encapsulate an IPv4 network address.
Definition: IpAddress.hpp:44
static const IpAddress None
Value representing an empty/invalid address.
Definition: IpAddress.hpp:184
static const IpAddress LocalHost
The "localhost" address (for connecting a computer to itself locally)
Definition: IpAddress.hpp:186
Represents a time value.
Definition: Time.hpp:40
static const Time Zero
Predefined "zero" time value.
Definition: Time.hpp:85
static const IpAddress Broadcast
The "broadcast" address (for sending UDP messages to everyone on a local network) ...
Definition: IpAddress.hpp:187
static const IpAddress Any
Value representing any address (0.0.0.0)
Definition: IpAddress.hpp:185