Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::asio::ip::address_v4 Class Reference

Implements IP version 4 style addresses. More...

#include <address_v4.hpp>

Public Types

typedef
boost::asio::detail::array
< unsigned char, 4 > 
bytes_type
 The type used to represent an address as an array of bytes. More...
 

Public Member Functions

 address_v4 ()
 Default constructor. More...
 
BOOST_ASIO_DECL address_v4 (const bytes_type &bytes)
 Construct an address from raw bytes. More...
 
BOOST_ASIO_DECL address_v4 (unsigned long addr)
 Construct an address from a unsigned long in host byte order. More...
 
 address_v4 (const address_v4 &other)
 Copy constructor. More...
 
address_v4operator= (const address_v4 &other)
 Assign from another address. More...
 
BOOST_ASIO_DECL bytes_type to_bytes () const
 Get the address in bytes, in network byte order. More...
 
BOOST_ASIO_DECL unsigned long to_ulong () const
 Get the address as an unsigned long in host byte order. More...
 
BOOST_ASIO_DECL std::string to_string () const
 Get the address as a string in dotted decimal format. More...
 
BOOST_ASIO_DECL std::string to_string (boost::system::error_code &ec) const
 Get the address as a string in dotted decimal format. More...
 
BOOST_ASIO_DECL bool is_loopback () const
 Determine whether the address is a loopback address. More...
 
BOOST_ASIO_DECL bool is_unspecified () const
 Determine whether the address is unspecified. More...
 
BOOST_ASIO_DECL bool is_class_a () const
 Determine whether the address is a class A address. More...
 
BOOST_ASIO_DECL bool is_class_b () const
 Determine whether the address is a class B address. More...
 
BOOST_ASIO_DECL bool is_class_c () const
 Determine whether the address is a class C address. More...
 
BOOST_ASIO_DECL bool is_multicast () const
 Determine whether the address is a multicast address. More...
 

Static Public Member Functions

static BOOST_ASIO_DECL address_v4 from_string (const char *str)
 Create an address from an IP address string in dotted decimal form. More...
 
static BOOST_ASIO_DECL address_v4 from_string (const char *str, boost::system::error_code &ec)
 Create an address from an IP address string in dotted decimal form. More...
 
static BOOST_ASIO_DECL address_v4 from_string (const std::string &str)
 Create an address from an IP address string in dotted decimal form. More...
 
static BOOST_ASIO_DECL address_v4 from_string (const std::string &str, boost::system::error_code &ec)
 Create an address from an IP address string in dotted decimal form. More...
 
static address_v4 any ()
 Obtain an address object that represents any address. More...
 
static address_v4 loopback ()
 Obtain an address object that represents the loopback address. More...
 
static address_v4 broadcast ()
 Obtain an address object that represents the broadcast address. More...
 
static BOOST_ASIO_DECL address_v4 broadcast (const address_v4 &addr, const address_v4 &mask)
 Obtain an address object that represents the broadcast address that corresponds to the specified address and netmask. More...
 
static BOOST_ASIO_DECL address_v4 netmask (const address_v4 &addr)
 Obtain the netmask that corresponds to the address, based on its address class. More...
 

Friends

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

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_v4 &addr)
 Output an address as a string. More...
 

Detailed Description

Implements IP version 4 style addresses.

The boost::asio::ip::address_v4 class provides the ability to use and manipulate IP version 4 addresses.

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

Member Typedef Documentation

typedef boost::asio::detail::array<unsigned char, 4> boost::asio::ip::address_v4::bytes_type

The type used to represent an address as an array of bytes.

Note
This type is defined in terms of the C++0x template std::array when it is available. Otherwise, it uses boost:array.

Constructor & Destructor Documentation

boost::asio::ip::address_v4::address_v4 ( )
inline

Default constructor.

Referenced by any(), broadcast(), and loopback().

BOOST_ASIO_DECL boost::asio::ip::address_v4::address_v4 ( const bytes_type bytes)
explicit

Construct an address from raw bytes.

BOOST_ASIO_DECL boost::asio::ip::address_v4::address_v4 ( unsigned long  addr)
explicit

Construct an address from a unsigned long in host byte order.

boost::asio::ip::address_v4::address_v4 ( const address_v4 other)
inline

Copy constructor.

Member Function Documentation

static address_v4 boost::asio::ip::address_v4::any ( )
inlinestatic

Obtain an address object that represents any address.

References address_v4().

static address_v4 boost::asio::ip::address_v4::broadcast ( )
inlinestatic

Obtain an address object that represents the broadcast address.

References address_v4().

static BOOST_ASIO_DECL address_v4 boost::asio::ip::address_v4::broadcast ( const address_v4 addr,
const address_v4 mask 
)
static

Obtain an address object that represents the broadcast address that corresponds to the specified address and netmask.

static BOOST_ASIO_DECL address_v4 boost::asio::ip::address_v4::from_string ( const char *  str)
static

Create an address from an IP address string in dotted decimal form.

static BOOST_ASIO_DECL address_v4 boost::asio::ip::address_v4::from_string ( const char *  str,
boost::system::error_code ec 
)
static

Create an address from an IP address string in dotted decimal form.

static BOOST_ASIO_DECL address_v4 boost::asio::ip::address_v4::from_string ( const std::string &  str)
static

Create an address from an IP address string in dotted decimal form.

static BOOST_ASIO_DECL address_v4 boost::asio::ip::address_v4::from_string ( const std::string &  str,
boost::system::error_code ec 
)
static

Create an address from an IP address string in dotted decimal form.

BOOST_ASIO_DECL bool boost::asio::ip::address_v4::is_class_a ( ) const

Determine whether the address is a class A address.

BOOST_ASIO_DECL bool boost::asio::ip::address_v4::is_class_b ( ) const

Determine whether the address is a class B address.

BOOST_ASIO_DECL bool boost::asio::ip::address_v4::is_class_c ( ) const

Determine whether the address is a class C address.

BOOST_ASIO_DECL bool boost::asio::ip::address_v4::is_loopback ( ) const

Determine whether the address is a loopback address.

BOOST_ASIO_DECL bool boost::asio::ip::address_v4::is_multicast ( ) const

Determine whether the address is a multicast address.

BOOST_ASIO_DECL bool boost::asio::ip::address_v4::is_unspecified ( ) const

Determine whether the address is unspecified.

static address_v4 boost::asio::ip::address_v4::loopback ( )
inlinestatic

Obtain an address object that represents the loopback address.

References address_v4().

static BOOST_ASIO_DECL address_v4 boost::asio::ip::address_v4::netmask ( const address_v4 addr)
static

Obtain the netmask that corresponds to the address, based on its address class.

address_v4& boost::asio::ip::address_v4::operator= ( const address_v4 other)
inline

Assign from another address.

BOOST_ASIO_DECL bytes_type boost::asio::ip::address_v4::to_bytes ( ) const

Get the address in bytes, in network byte order.

BOOST_ASIO_DECL std::string boost::asio::ip::address_v4::to_string ( ) const

Get the address as a string in dotted decimal format.

BOOST_ASIO_DECL std::string boost::asio::ip::address_v4::to_string ( boost::system::error_code ec) const

Get the address as a string in dotted decimal format.

BOOST_ASIO_DECL unsigned long boost::asio::ip::address_v4::to_ulong ( ) const

Get the address as an unsigned long in host byte order.

Friends And Related Function Documentation

bool operator!= ( const address_v4 a1,
const address_v4 a2 
)
friend

Compare two addresses for inequality.

bool operator< ( const address_v4 a1,
const address_v4 a2 
)
friend

Compare addresses for ordering.

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

Output an address as a string.

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

Parameters
osThe output stream to which the string will be written.
addrThe address to be written.
Returns
The output stream.
bool operator<= ( const address_v4 a1,
const address_v4 a2 
)
friend

Compare addresses for ordering.

bool operator== ( const address_v4 a1,
const address_v4 a2 
)
friend

Compare two addresses for equality.

bool operator> ( const address_v4 a1,
const address_v4 a2 
)
friend

Compare addresses for ordering.

bool operator>= ( const address_v4 a1,
const address_v4 a2 
)
friend

Compare addresses for ordering.


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