senf::safe_data_iterator Class Reference

Re-validating data iterator. More...

#include <senf/Packets/SafeIterator.hh>

Inheritance diagram for senf::safe_data_iterator:

Public Types

typedef PacketData::size_type size_type
 

Public Member Functions

 safe_data_iterator ()
 Make uninitialized iterator. More...
 
 safe_data_iterator (PacketData &data)
 Construct iterator only setting the data container. More...
 
 safe_data_iterator (PacketData &data, PacketData::iterator i)
 Initialize iterator to given position. More...
 
 safe_data_iterator (PacketParserBase const &parser)
 Initialize iterator from parser. More...
 
safe_data_iteratoroperator= (PacketData::iterator i)
 Assign iterator. More...
 
safe_data_iteratoroperator= (PacketParserBase const &parser)
 Assign iterator from parser. More...
 
PacketDatadata () const
 Access data container. More...
 

Detailed Description

Re-validating data iterator.

This class is a wrapper around a PacketData::iterator instance. It will revalidate the iterator on every access. This keeps the iterator valid even when the data container is resized and thereby possibly relocated. The iterator will always point to the byte at the same offset from the packets beginning. If data is inserted before this iterators position, the data pointed to will of course change.

For this to work, the safe_data_iterator must be initialized with the container to which the iterator belongs. After this initialization it can be used like any other iterator.

Definition at line 47 of file SafeIterator.hh.

Member Typedef Documentation

◆ size_type

Constructor & Destructor Documentation

◆ safe_data_iterator() [1/4]

senf::safe_data_iterator::safe_data_iterator ( )

Make uninitialized iterator.

◆ safe_data_iterator() [2/4]

senf::safe_data_iterator::safe_data_iterator ( PacketData data)
explicit

Construct iterator only setting the data container.

◆ safe_data_iterator() [3/4]

senf::safe_data_iterator::safe_data_iterator ( PacketData data,
PacketData::iterator  i 
)

Initialize iterator to given position.

◆ safe_data_iterator() [4/4]

senf::safe_data_iterator::safe_data_iterator ( PacketParserBase const &  parser)
explicit

Initialize iterator from parser.

The iterator will point to the parsers start position.

Member Function Documentation

◆ data()

PacketData& senf::safe_data_iterator::data ( ) const

Access data container.

◆ operator=() [1/2]

safe_data_iterator& senf::safe_data_iterator::operator= ( PacketData::iterator  i)

Assign iterator.

The iterator i must be from the container which this iterator has been initialized.

◆ operator=() [2/2]

safe_data_iterator& senf::safe_data_iterator::operator= ( PacketParserBase const &  parser)

Assign iterator from parser.

The iterator will point to the parser start position.


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