Packet data STL-sequence view. More...
#include <senf/Packets/PacketData.hh>
Public Types | |
typedef senf::detail::packet::iterator | iterator |
typedef senf::detail::packet::const_iterator | const_iterator |
typedef senf::detail::packet::size_type | size_type |
typedef senf::detail::packet::difference_type | difference_type |
typedef senf::detail::packet::byte | byte |
typedef byte | value_type |
typedef byte & | reference |
typedef byte const & | const_reference |
typedef byte * | pointer |
typedef byte const * | const_pointer |
Protected Member Functions | |
PacketData (size_type b, size_type e) | |
detail::PacketImpl & | impl () const |
bool | valid () |
Protected Attributes | |
detail::PacketImpl * | impl_ |
Need to make this protected so we can change it in the derived class. More... | |
Sequence interface to raw data | |
iterator | begin () const |
Return iterator to beginning. More... | |
iterator | end () const |
Return iterator to end. More... | |
size_type | size () const |
Returns the number of bytes in the packet data. More... | |
bool | empty () const |
Test whether the packet data is empty. More... | |
byte | operator[] (size_type n) const |
Access byte in the packet data. More... | |
byte & | operator[] (size_type n) |
Access byte in the packet data. More... | |
void | insert (iterator pos, byte v) |
void | insert (iterator pos, size_type n, byte v) |
template<class InputIterator > | |
void | insert (iterator pos, InputIterator f, InputIterator l) |
void | erase (iterator pos) |
void | erase (iterator first, iterator last) |
void | clear () |
All bytes of the packet data dropped, leaving the container with a size of 0. */. More... | |
void | zero (iterator first, iterator last) |
void | resize (size_type n, byte v=0) |
bool | usingExternalMemory () const |
Check for external memory usage. More... | |
void | releaseExternalMemory () |
Release external memory. More... | |
Packet data STL-sequence view.
The PacketData class provides an STL-sequence compatible view of the raw packet data. Each packet/header/interpreter in the chain references the same storage area, presenting a different (but nested/overlapping) section of the data.
Whenever the data is manipulated through PacketData, the change is assumed to be within the data range of that packet: All insertions take place inside this
packet and outside any following packets in the packet chain.
this
sequence. Doing so will corrupt the packet data.All public members are those of an STL random-access sequence.
Definition at line 61 of file PacketData.hh.
Definition at line 72 of file PacketData.hh.
Definition at line 69 of file PacketData.hh.
typedef byte const* senf::PacketData::const_pointer |
Definition at line 77 of file PacketData.hh.
typedef byte const& senf::PacketData::const_reference |
Definition at line 75 of file PacketData.hh.
Definition at line 71 of file PacketData.hh.
Definition at line 68 of file PacketData.hh.
typedef byte* senf::PacketData::pointer |
Definition at line 76 of file PacketData.hh.
typedef byte& senf::PacketData::reference |
Definition at line 74 of file PacketData.hh.
Definition at line 70 of file PacketData.hh.
typedef byte senf::PacketData::value_type |
Definition at line 73 of file PacketData.hh.
iterator senf::PacketData::begin | ( | ) | const |
Return iterator to beginning.
Returns an random access iterator referring to the first byte of the packet data.
void senf::PacketData::clear | ( | ) |
All bytes of the packet data dropped, leaving the container with a size of 0. */.
bool senf::PacketData::empty | ( | ) | const |
Test whether the packet data is empty.
Returns whether the packet data is empty, i.e. whether its size is 0. This function does not modify the content of the packet data in any way. To clear the content use clear()
iterator senf::PacketData::end | ( | ) | const |
Return iterator to end.
Returns an random access iterator referring to the byte past the end of the packet data.
void senf::PacketData::erase | ( | iterator | pos | ) |
|
protected |
void senf::PacketData::insert | ( | iterator | pos, |
InputIterator | f, | ||
InputIterator | l | ||
) |
void senf::PacketData::releaseExternalMemory | ( | ) |
Release external memory.
If usingExternalMemory()
returns true
, this member will force a reallocation of the packet data into internally managed memory. This operation does not change the packet in any way it only changes the location, the packet data is stored at. This operation will invalidate any iterators.
If usingExternalMemory()
is false
, this function is a no-op.
Definition at line 28 of file PacketData.cc.
size_type senf::PacketData::size | ( | ) | const |
Returns the number of bytes in the packet data.
bool senf::PacketData::usingExternalMemory | ( | ) | const |
Check for external memory usage.
Returns true
, if the packet data resides in external memory not managed by the packet, false
otherwise.
Normally, this member will return false
. If however the Packet has been constructed using the special zero-copy external memory constructor, usingExternalMemory()
will return true
as long as no reallocation has occurred.
|
protected |
|
protected |
Need to make this protected so we can change it in the derived class.
Definition at line 155 of file PacketData.hh.