ArrayParser.hh
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 
17 #ifndef HH_SENF_Packets_ArrayParser_
18 #define HH_SENF_Packets_ArrayParser_ 1
19 
44 // Custom includes
45 #include "PacketParser.hh"
46 
47 //#include "ArrayParser.mpp"
48 //-/////////////////////////////////////////////////////////////////////////////////////////////////
49 
50 namespace senf {
51 
52  namespace detail { template <class> class ArrayParser_iterator; }
53 
65  template <unsigned elements, class ElementParser>
66  struct ArrayParser : public PacketParserBase
67  {
69 
70  static size_type const fixed_bytes = elements*ElementParser::fixed_bytes;
71 
72  void init() const;
73 
74  //-////////////////////////////////////////////////////////////////////////
75  // Container interface
76 
77  typedef ElementParser value_type;
79  typedef iterator const_iterator;
80 
81  static size_type size();
82 
83  iterator begin() const;
84  iterator end() const;
85 
86  value_type operator[](difference_type i) const;
87  };
88 
100 # define SENF_PARSER_ARRAY(name, elt_type, size) \
101  typedef senf::ArrayParser<size,elt_type> BOOST_PP_CAT(name, _array_t); \
102  SENF_PARSER_FIELD( name, BOOST_PP_CAT(name, _array_t) )
103 
104 }
105 
106 //-/////////////////////////////////////////////////////////////////////////////////////////////////
107 #endif
108 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_ArrayParser_i_)
109 #define HH_SENF_Packets_ArrayParser_i_
110 //#include "ArrayParser.cci"
111 #include "ArrayParser.ct"
112 #include "ArrayParser.cti"
113 #endif
114 
115 
116 // Local Variables:
117 // mode: c++
118 // fill-column: 100
119 // c-file-style: "senf"
120 // indent-tabs-mode: nil
121 // ispell-local-dictionary: "american"
122 // compile-command: "scons -u test"
123 // comment-column: 40
124 // End:
PacketParser public header.
void init()
Fixed size collection of fixed size elements.
Definition: ArrayParser.hh:66
ElementParser value_type
Definition: ArrayParser.hh:77
Packet data STL-sequence view.
Definition: PacketData.hh:61
detail::packet::difference_type difference_type
Signed integral type.
detail::packet::size_type size_type
Unsigned integral type.
Parser Base class.
iterator const_iterator
Definition: ArrayParser.hh:79
detail::packet::iterator data_iterator
Raw data iterator type.
detail::ArrayParser_iterator< value_type > iterator
Definition: ArrayParser.hh:78