2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief SafeIterator inline non-template implementation */
17 #include "SafeIterator.ih"
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::safe_data_iterator
27 prefix_ senf::safe_data_iterator::safe_data_iterator()
30 prefix_ senf::safe_data_iterator::safe_data_iterator(PacketData & data)
34 prefix_ senf::safe_data_iterator::safe_data_iterator(PacketData & data, PacketData::iterator i)
35 : Base(&data, std::distance(data.begin(),i))
38 prefix_ senf::safe_data_iterator::safe_data_iterator(PacketParserBase const & parser)
39 : Base(&parser.data(), std::distance(parser.data().begin(),parser.i()))
42 prefix_ senf::safe_data_iterator & senf::safe_data_iterator::operator=(PacketData::iterator i)
44 SENF_ASSERT(data_, "Use/dereferencing of empty safe_data_iterator");
45 i_ = std::distance(data_->begin(),i);
49 prefix_ senf::safe_data_iterator &
50 senf::safe_data_iterator::operator=(PacketParserBase const & parser)
52 data_ = &parser.data();
53 i_ = std::distance(data_->begin(),parser.i());
57 prefix_ senf::PacketData & senf::safe_data_iterator::data()
60 SENF_ASSERT(data_, "Use/dereferencing of empty safe_data_iterator");
64 prefix_ senf::safe_data_iterator::value_type & senf::safe_data_iterator::dereference()
67 return * static_cast<PacketData::iterator>(*this);
70 prefix_ bool senf::safe_data_iterator::equal(safe_data_iterator const & other)
73 SENF_ASSERT(data_ == other.data_, "Comparing iterators of two different containers is invalid");
74 return i_ == other.i_;
77 prefix_ senf::safe_data_iterator::difference_type
78 senf::safe_data_iterator::distance_to(safe_data_iterator const & other)
81 SENF_ASSERT(data_ == other.data_, "Comparing iterators of two different containers is invalid");
85 prefix_ void senf::safe_data_iterator::increment()
90 prefix_ void senf::safe_data_iterator::decrement()
92 SENF_ASSERT(i_>0, "Decrementing iterator before beginning of container" );
96 prefix_ void senf::safe_data_iterator::advance(difference_type n)
98 SENF_ASSERT( -n < difference_type(i_), "Moving iterator to before beginning of container" );
102 //-/////////////////////////////////////////////////////////////////////////////////////////////////
109 // comment-column: 40
110 // c-file-style: "senf"
111 // indent-tabs-mode: nil
112 // ispell-local-dictionary: "american"
113 // compile-command: "scons -u test"