ArrayParser.ih
Go to the documentation of this file.
1 //
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
6 //
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
11 //
12 
13 
14 /** \file
15  \brief ArrayParser internal header */
16 
17 #ifndef IH_SENF_Packets_ArrayParser_
18 #define IH_SENF_Packets_ArrayParser_ 1
19 
20 // Custom includes
21 #include <boost/iterator/iterator_facade.hpp>
22 
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 /** \brief Internal: Array and Vector iterator
26 
27  \internal
28 
29  This is the iterator type used for both ArrayParser and VectorParser. It is a model of random
30  access iterator.
31  */
32 template <class ElementParser>
33 class senf::detail::ArrayParser_iterator
34  : public boost::iterator_facade< ArrayParser_iterator<ElementParser>,
35  ElementParser,
36  boost::random_access_traversal_tag,
37  ElementParser >
38 {
39 public:
40  ArrayParser_iterator();
41  ArrayParser_iterator(PacketParserBase::data_iterator const & i,
42  PacketParserBase::state_type s);
43 
44  // Needed to elide the []-proxy of iterator_facade
45  ElementParser operator[](int i) const;
46 
47  PacketParserBase::data_iterator raw() const; ///< Return data_iterator
48  /**< Returns the raw data_iterator pointing to the beginning
49  of the current element */
50 
51 protected:
52 
53 private:
54  friend class boost::iterator_core_access;
55 
56  // iterator_facade interface
57 
58  ElementParser dereference() const;
59  bool equal(ArrayParser_iterator const & other) const;
60  int distance_to(ArrayParser_iterator const & other) const;
61  void increment();
62  void decrement();
63  void advance(int n);
64 
65  PacketParserBase::data_iterator i_;
66  PacketParserBase::state_type s_;
67 };
68 
69 //-/////////////////////////////////////////////////////////////////////////////////////////////////
70 #endif
71 
72 
73 // Local Variables:
74 // mode: c++
75 // fill-column: 100
76 // c-file-style: "senf"
77 // indent-tabs-mode: nil
78 // ispell-local-dictionary: "american"
79 // compile-command: "scons -u test"
80 // comment-column: 40
81 // End: