MySensors Library & Examples  2.3.2-36-g2e00bf6
Public Member Functions | Friends | List of all members
IPAddress Class Reference

Detailed Description

A class to make it easier to handle and pass around IP addresses.

Definition at line 32 of file IPAddress.h.

#include <IPAddress.h>

+ Collaboration diagram for IPAddress:

Public Member Functions

 IPAddress ()
 IPAddress constructor.
 
 IPAddress (uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
 IPAddress constructor. More...
 
 IPAddress (uint32_t address)
 IPAddress constructor. More...
 
 IPAddress (const uint8_t *address)
 IPAddress constructor. More...
 
bool fromString (const char *address)
 Set the IP from a array of characters. More...
 
bool fromString (const std::string &address)
 Set the IP from a string class type. More...
 
 operator uint32_t () const
 Overloaded cast operator. More...
 
bool operator== (const IPAddress &addr) const
 Overloaded cast operator. More...
 
bool operator== (uint32_t addr) const
 Overloaded cast operator. More...
 
bool operator== (const uint8_t *addr) const
 Overloaded cast operator. More...
 
uint8_t operator[] (int index) const
 Overloaded index operator. More...
 
uint8_t & operator[] (int index)
 Overloaded index operator. More...
 
IPAddressoperator= (const uint8_t *address)
 Overloaded copy operators. More...
 
IPAddressoperator= (uint32_t address)
 Overloaded copy operator. More...
 
std::string toString ()
 Convert the IP address to a string. More...
 

Friends

class Client
 

Constructor & Destructor Documentation

◆ IPAddress() [1/3]

IPAddress::IPAddress ( uint8_t  first_octet,
uint8_t  second_octet,
uint8_t  third_octet,
uint8_t  fourth_octet 
)

IPAddress constructor.

Parameters
first_octetfirst octet of the IPv4 address.
second_octetsecond octet of the IPv4 address.
third_octetthird octet of the IPv4 address.
fourth_octetfourth octet of the IPv4 address.

◆ IPAddress() [2/3]

IPAddress::IPAddress ( uint32_t  address)
explicit

IPAddress constructor.

Parameters
addressto be set from a 32 bits integer.

◆ IPAddress() [3/3]

IPAddress::IPAddress ( const uint8_t *  address)
explicit

IPAddress constructor.

Parameters
addressto be set from a byte array.

Member Function Documentation

◆ fromString() [1/2]

bool IPAddress::fromString ( const char *  address)

Set the IP from a array of characters.

Parameters
addressto be set.

◆ fromString() [2/2]

bool IPAddress::fromString ( const std::string &  address)
inline

Set the IP from a string class type.

Parameters
addressto be set.

Definition at line 91 of file IPAddress.h.

◆ operator uint32_t()

IPAddress::operator uint32_t ( ) const
inline

Overloaded cast operator.

Allow IPAddress objects to be used where a pointer to a four-byte uint8_t array is expected

Definition at line 100 of file IPAddress.h.

◆ operator=() [1/2]

IPAddress& IPAddress::operator= ( const uint8_t *  address)

Overloaded copy operators.

Allow initialisation of IPAddress objects from byte array.

◆ operator=() [2/2]

IPAddress& IPAddress::operator= ( uint32_t  address)

Overloaded copy operator.

Allow initialisation of IPAddress objects from a 32 bits integer.

◆ operator==() [1/3]

bool IPAddress::operator== ( const IPAddress addr) const
inline

Overloaded cast operator.

Definition at line 108 of file IPAddress.h.

◆ operator==() [2/3]

bool IPAddress::operator== ( const uint8_t *  addr) const

Overloaded cast operator.

◆ operator==() [3/3]

bool IPAddress::operator== ( uint32_t  addr) const
inline

Overloaded cast operator.

Definition at line 116 of file IPAddress.h.

◆ operator[]() [1/2]

uint8_t& IPAddress::operator[] ( int  index)
inline

Overloaded index operator.

Definition at line 139 of file IPAddress.h.

◆ operator[]() [2/2]

uint8_t IPAddress::operator[] ( int  index) const
inline

Overloaded index operator.

Allow getting and setting individual octets of the address.

Definition at line 131 of file IPAddress.h.

◆ toString()

std::string IPAddress::toString ( )

Convert the IP address to a string.

Returns
A stringified IP address

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