Packet data STL-sequence view. More...

#include <senf/Packets/PacketData.hh>

Inheritance diagram for senf::PacketData:

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 bytereference
 
typedef byte const & const_reference
 
typedef bytepointer
 
typedef byte const * const_pointer
 

Protected Member Functions

 PacketData (size_type b, size_type e)
 
detail::PacketImplimpl () const
 
bool valid ()
 

Protected Attributes

detail::PacketImplimpl_
 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...
 
byteoperator[] (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...
 

Detailed Description

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.

Warning
It is not permissible to change data belonging to a following packet/header/interpreter even though this data is part of this sequence. Doing so will corrupt the packet data.
Warning
When accessing packet data via the PacketData interface you are on your own: The packet is not validated in any way, you bypass all parsers.

All public members are those of an STL random-access sequence.

Implementation note:
This class is very tightly integrated with PacketInterpreterBase / PacketInterpreter. It is separated out of those classes primarily to provide a clean sequence interface to the library user and not for implementation reasons (it would have been simpler to implement all these members in PacketInterpreterBase).

Definition at line 61 of file PacketData.hh.

Member Typedef Documentation

◆ byte

◆ const_iterator

◆ const_pointer

Definition at line 77 of file PacketData.hh.

◆ const_reference

Definition at line 75 of file PacketData.hh.

◆ difference_type

◆ iterator

◆ pointer

Definition at line 76 of file PacketData.hh.

◆ reference

Definition at line 74 of file PacketData.hh.

◆ size_type

◆ value_type

Definition at line 73 of file PacketData.hh.

Constructor & Destructor Documentation

◆ PacketData()

senf::PacketData::PacketData ( size_type  b,
size_type  e 
)
protected

Member Function Documentation

◆ begin()

iterator senf::PacketData::begin ( ) const

Return iterator to beginning.

Returns an random access iterator referring to the first byte of the packet data.

◆ clear()

void senf::PacketData::clear ( )

All bytes of the packet data dropped, leaving the container with a size of 0. */.

◆ empty()

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()

◆ end()

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.

◆ erase() [1/2]

void senf::PacketData::erase ( iterator  pos)

◆ erase() [2/2]

void senf::PacketData::erase ( iterator  first,
iterator  last 
)

◆ impl()

detail::PacketImpl& senf::PacketData::impl ( ) const
protected

◆ insert() [1/3]

void senf::PacketData::insert ( iterator  pos,
byte  v 
)

◆ insert() [2/3]

void senf::PacketData::insert ( iterator  pos,
size_type  n,
byte  v 
)

◆ insert() [3/3]

template<class InputIterator >
void senf::PacketData::insert ( iterator  pos,
InputIterator  f,
InputIterator  l 
)

◆ operator[]() [1/2]

byte senf::PacketData::operator[] ( size_type  n) const

Access byte in the packet data.

◆ operator[]() [2/2]

byte& senf::PacketData::operator[] ( size_type  n)

Access byte in the packet data.

◆ releaseExternalMemory()

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.

◆ resize()

void senf::PacketData::resize ( size_type  n,
byte  v = 0 
)

Definition at line 28 of file PacketData.cc.

◆ size()

size_type senf::PacketData::size ( ) const

Returns the number of bytes in the packet data.

◆ usingExternalMemory()

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.

◆ valid()

bool senf::PacketData::valid ( )
protected

◆ zero()

void senf::PacketData::zero ( iterator  first,
iterator  last 
)

Member Data Documentation

◆ impl_

detail::PacketImpl* senf::PacketData::impl_
protected

Need to make this protected so we can change it in the derived class.

Definition at line 155 of file PacketData.hh.


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