asio::ip::address Class Reference

Implements version-independent IP addresses. More...

#include <address.hpp>

List of all members.

Public Member Functions

 address ()
 Default constructor.
 address (const asio::ip::address_v4 &ipv4_address)
 Construct an address from an IPv4 address.
 address (const asio::ip::address_v6 &ipv6_address)
 Construct an address from an IPv6 address.
 address (const address &other)
 Copy constructor.
addressoperator= (const address &other)
 Assign from another address.
addressoperator= (const asio::ip::address_v4 &ipv4_address)
 Assign from an IPv4 address.
addressoperator= (const asio::ip::address_v6 &ipv6_address)
 Assign from an IPv6 address.
bool is_v4 () const
 Get whether the address is an IP version 4 address.
bool is_v6 () const
 Get whether the address is an IP version 6 address.
asio::ip::address_v4 to_v4 () const
 Get the address as an IP version 4 address.
asio::ip::address_v6 to_v6 () const
 Get the address as an IP version 6 address.
std::string to_string () const
 Get the address as a string in dotted decimal format.
std::string to_string (asio::error_code &ec) const
 Get the address as a string in dotted decimal format.

Static Public Member Functions

static address from_string (const char *str)
static address from_string (const char *str, asio::error_code &ec)
static address from_string (const std::string &str)
static address from_string (const std::string &str, asio::error_code &ec)

Private Types

enum  { ipv4, ipv6 }

Private Attributes

enum asio::ip::address:: { ... }  type_
asio::ip::address_v4 ipv4_address_
asio::ip::address_v6 ipv6_address_

Friends

bool operator== (const address &a1, const address &a2)
 Compare two addresses for equality.
bool operator!= (const address &a1, const address &a2)
 Compare two addresses for inequality.
bool operator< (const address &a1, const address &a2)
 Compare addresses for ordering.

Related Functions

(Note that these are not member functions.)

template<typename Elem, typename Traits>
std::basic_ostream< Elem,
Traits > & 
operator<< (std::basic_ostream< Elem, Traits > &os, const address &addr)
 Output an address as a string.


Detailed Description

Implements version-independent IP addresses.

The asio::ip::address class provides the ability to use either IP version 4 or version 6 addresses.

Thread Safety
Distinct objects: Safe.
Shared objects: Unsafe.

Definition at line 43 of file address.hpp.


Member Enumeration Documentation

anonymous enum [private]

Enumerator:
ipv4 
ipv6 

Definition at line 243 of file address.hpp.


Constructor & Destructor Documentation

asio::ip::address::address (  )  [inline]

Default constructor.

Definition at line 47 of file address.hpp.

Referenced by from_string().

asio::ip::address::address ( const asio::ip::address_v4 ipv4_address  )  [inline]

Construct an address from an IPv4 address.

Definition at line 55 of file address.hpp.

asio::ip::address::address ( const asio::ip::address_v6 ipv6_address  )  [inline]

Construct an address from an IPv6 address.

Definition at line 63 of file address.hpp.

asio::ip::address::address ( const address other  )  [inline]

Copy constructor.

Definition at line 71 of file address.hpp.


Member Function Documentation

address& asio::ip::address::operator= ( const address other  )  [inline]

Assign from another address.

Definition at line 79 of file address.hpp.

References ipv4_address_, ipv6_address_, and type_.

address& asio::ip::address::operator= ( const asio::ip::address_v4 ipv4_address  )  [inline]

Assign from an IPv4 address.

Definition at line 88 of file address.hpp.

References ipv4, ipv4_address_, ipv6_address_, and type_.

address& asio::ip::address::operator= ( const asio::ip::address_v6 ipv6_address  )  [inline]

Assign from an IPv6 address.

Definition at line 97 of file address.hpp.

References ipv4_address_, ipv6, ipv6_address_, and type_.

bool asio::ip::address::is_v4 (  )  const [inline]

bool asio::ip::address::is_v6 (  )  const [inline]

asio::ip::address_v4 asio::ip::address::to_v4 (  )  const [inline]

asio::ip::address_v6 asio::ip::address::to_v6 (  )  const [inline]

std::string asio::ip::address::to_string (  )  const [inline]

std::string asio::ip::address::to_string ( asio::error_code ec  )  const [inline]

Get the address as a string in dotted decimal format.

Definition at line 150 of file address.hpp.

References ipv4_address_, ipv6, ipv6_address_, asio::ip::address_v4::to_string(), asio::ip::address_v6::to_string(), and type_.

static address asio::ip::address::from_string ( const char *  str  )  [inline, static]

Create an address from an IPv4 address string in dotted decimal form, or from an IPv6 address in hexadecimal notation.

Definition at line 159 of file address.hpp.

References asio::detail::throw_error().

Referenced by from_string(), libtorrent::aux::session_impl::listen_on(), libtorrent::aux::piece_checker_data::parse_resume_data(), libtorrent::torrent::tracker_response(), and libtorrent::torrent::use_interface().

static address asio::ip::address::from_string ( const char *  str,
asio::error_code ec 
) [inline, static]

Create an address from an IPv4 address string in dotted decimal form, or from an IPv6 address in hexadecimal notation.

Definition at line 169 of file address.hpp.

References address(), asio::ip::address_v4::from_string(), asio::ip::address_v6::from_string(), ipv4, ipv4_address_, ipv6, ipv6_address_, and type_.

static address asio::ip::address::from_string ( const std::string &  str  )  [inline, static]

Create an address from an IPv4 address string in dotted decimal form, or from an IPv6 address in hexadecimal notation.

Definition at line 196 of file address.hpp.

References from_string().

static address asio::ip::address::from_string ( const std::string &  str,
asio::error_code ec 
) [inline, static]

Create an address from an IPv4 address string in dotted decimal form, or from an IPv6 address in hexadecimal notation.

Definition at line 203 of file address.hpp.

References from_string().


Friends And Related Function Documentation

bool operator== ( const address a1,
const address a2 
) [friend]

Compare two addresses for equality.

Definition at line 210 of file address.hpp.

bool operator!= ( const address a1,
const address a2 
) [friend]

Compare two addresses for inequality.

Definition at line 220 of file address.hpp.

bool operator< ( const address a1,
const address a2 
) [friend]

Compare addresses for ordering.

Definition at line 230 of file address.hpp.

template<typename Elem, typename Traits>
std::basic_ostream< Elem, Traits > & operator<< ( std::basic_ostream< Elem, Traits > &  os,
const address addr 
) [related]

Output an address as a string.

Used to output a human-readable string for a specified address.

Parameters:
os The output stream to which the string will be written.
addr The address to be written.
Returns:
The output stream.

Definition at line 265 of file address.hpp.

References to_string().


Member Data Documentation

enum { ... } asio::ip::address::type_ [private]

Definition at line 246 of file address.hpp.

Referenced by from_string(), operator=(), to_string(), and to_v4().

Definition at line 249 of file address.hpp.

Referenced by from_string(), operator=(), to_string(), and to_v6().


The documentation for this class was generated from the following file:

Generated on Sun May 25 00:21:35 2008 by  doxygen 1.5.6