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 internal header */
17 #ifndef IH_SENF_SafeIterator_
18 #define IH_SENF_SafeIterator_ 1
22 ///////////////////////////////ih.p////////////////////////////////////////
28 template <class DataIteratorType>
29 class safe_data_iterator_base
30 : public comparable_safe_bool< safe_data_iterator_base<DataIteratorType> >
33 typedef PacketData::size_type size_type;
35 bool boolean_test() const
40 operator DataIteratorType () const
42 SENF_ASSERT(data_, "Use/dereferencing of empty safe_data_iterator");
43 return boost::next(data_->begin(),i_);
48 safe_data_iterator_base(PacketData * data = nullptr, size_type i = 0)
49 : data_ (data), i_ (i) {}
57 template <class ValueType>
58 class safe_data_iterator_base<ValueType *>
61 typedef PacketData::size_type size_type;
63 operator ValueType * () const
65 return data_ ? boost::next(data_->begin(), i_) : static_cast<ValueType *>(nullptr);
69 safe_data_iterator_base(PacketData * data = nullptr, size_type i = 0)
70 : data_ (data), i_ (i) {}
80 ///////////////////////////////ih.e////////////////////////////////////////
88 // c-file-style: "senf"
89 // indent-tabs-mode: nil
90 // ispell-local-dictionary: "american"
91 // compile-command: "scons -u test"