AgentXcpp  Revision:0.2
Internals Documentation
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Pages
agentxcpp::IpAddressValue Class Reference

Represents an IP address as described in RFC 2741, section 5.4. More...

#include <IpAddressValue.hpp>

Inheritance diagram for agentxcpp::IpAddressValue:
Collaboration diagram for agentxcpp::IpAddressValue:

Public Member Functions

 IpAddressValue (binary::const_iterator &pos, const binary::const_iterator &end, bool big_endian=true)
 Parse Constructor.
binary serialize () const
 Encode the object as described in RFC 2741, section 5.4 / 5.3.
 IpAddressValue (uint8_t a, uint8_t b, uint8_t c, uint8_t d)
 Construct an IpAddressValue object.
void set_value (uint8_t a, uint8_t b, uint8_t c, uint8_t d)
 Set the IpAddress.
uint8_t & operator[] (unsigned index)
 Access a component of the stored IpAddress.
- Public Member Functions inherited from agentxcpp::AbstractValue
virtual ~AbstractValue ()
 Destructor.

Private Member Functions

 IpAddressValue ()
 Hide default constructor.

Private Attributes

uint8_t address [4]
 The IP address.

Detailed Description

Represents an IP address as described in RFC 2741, section 5.4.

Definition at line 35 of file IpAddressValue.hpp.

Constructor & Destructor Documentation

agentxcpp::IpAddressValue::IpAddressValue ( )
private

Hide default constructor.

IpAddressValue::IpAddressValue ( binary::const_iterator &  pos,
const binary::const_iterator &  end,
bool  big_endian = true 
)

Parse Constructor.

This constructor parses the serialized form of the object. It takes an iterator, starts parsing at the position of the iterator and advances the iterator to the position right behind the object.

The constructor expects valid data from the stream; if parsing fails, parse_error is thrown. In this case, the iterator position is undefined.

Parameters
posIterator pointing to the current stream position. The iterator is advanced while reading the header.
endIterator pointing one element past the end of the current stream. This is needed to mark the end of the buffer.
big_endianWhether the input stream is in big endian format

Definition at line 45 of file IpAddressValue.cpp.

References address, and agentxcpp::read32().

agentxcpp::IpAddressValue::IpAddressValue ( uint8_t  a,
uint8_t  b,
uint8_t  c,
uint8_t  d 
)
inline

Construct an IpAddressValue object.

The stored IpAddress is initialized to "a.b.c.d".

Exceptions
None.

Definition at line 97 of file IpAddressValue.hpp.

References address.

Member Function Documentation

uint8_t& agentxcpp::IpAddressValue::operator[] ( unsigned  index)
inline

Access a component of the stored IpAddress.

This function returns the component with the given index. Note that exactly 4 components are stored. The return value is a reference to the component, so that it can be read/written, in other words, the IpAddressValue object can be accessed like an ordinary array.

Parameters
indexThe index (value in the range 0...3).
Returns
A reference to the component.
Exceptions
inval_paramIf the index is out of bound.

Definition at line 141 of file IpAddressValue.hpp.

References address.

binary IpAddressValue::serialize ( ) const
virtual

Encode the object as described in RFC 2741, section 5.4 / 5.3.

Note: We always use big endian.

Implements agentxcpp::AbstractValue.

Definition at line 25 of file IpAddressValue.cpp.

References address.

void agentxcpp::IpAddressValue::set_value ( uint8_t  a,
uint8_t  b,
uint8_t  c,
uint8_t  d 
)
inline

Set the IpAddress.

The stored IpAddress is updated to "a.b.c.d".

Exceptions
None.

Definition at line 115 of file IpAddressValue.hpp.

References address.

Member Data Documentation

uint8_t agentxcpp::IpAddressValue::address[4]
private

The IP address.

According to RFC 2578, IpAddress is a 32-bit number.

Definition at line 48 of file IpAddressValue.hpp.

Referenced by IpAddressValue(), operator[](), serialize(), and set_value().


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