Re-validating data iterator. More...
#include <senf/Packets/SafeIterator.hh>
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_iterator & | operator= (PacketData::iterator i) |
Assign iterator. More... | |
safe_data_iterator & | operator= (PacketParserBase const &parser) |
Assign iterator from parser. More... | |
PacketData & | data () const |
Access data container. More... | |
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.
Definition at line 55 of file SafeIterator.hh.
senf::safe_data_iterator::safe_data_iterator | ( | ) |
Make uninitialized iterator.
|
explicit |
Construct iterator only setting the data container.
senf::safe_data_iterator::safe_data_iterator | ( | PacketData & | data, |
PacketData::iterator | i | ||
) |
Initialize iterator to given position.
|
explicit |
Initialize iterator from parser.
The iterator will point to the parsers start position.
PacketData& senf::safe_data_iterator::data | ( | ) | const |
Access data container.
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.
safe_data_iterator& senf::safe_data_iterator::operator= | ( | PacketParserBase const & | parser | ) |
Assign iterator from parser.
The iterator will point to the parser start position.