ListNParser.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 ListNParser internal header */
16 
17 #ifndef IH_SENF_Packets_ListNParser_
18 #define IH_SENF_Packets_ListNParser_ 1
19 
20 // Custom includes
21 #include "ListParser.ih"
22 
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
25 namespace senf {
26 namespace detail {
27 
28  /** \brief Internal: ListPolicy defining the ListNParser parser
29  \internal
30  \see \ref ListParser
31  */
32  template <class ElementParser, class AuxPolicy>
33  struct ListNParser_Policy
34  : public AuxPolicy
35  {
36  typedef ListNParser_Policy<
37  ElementParser, typename AuxPolicy::ParserPolicy> parser_policy;
38  typedef ListNParser_Policy<
39  ElementParser, typename AuxPolicy::WrapperPolicy> container_policy;
40  typedef PacketParserBase::data_iterator data_iterator;
41  typedef PacketParserBase::state_type state_type;
42  typedef PacketParserBase::size_type size_type;
43  typedef ElementParser element_type;
44  typedef ListParser<parser_policy> parser_type;
45  typedef ListParser_Container<container_policy> container_type;
46 
47  static const size_type init_bytes = AuxPolicy::aux_bytes;
48 
49  ListNParser_Policy();
50  template <class Arg> ListNParser_Policy(Arg const & aux);
51  ListNParser_Policy(parser_policy const & policy);
52 
53  size_type bytes (data_iterator i, state_type s) const;
54  size_type size (data_iterator i, state_type s) const;
55  void init (data_iterator i, state_type s) const;
56 
57  void construct (container_type & c) const;
58  void destruct (container_type & c) const;
59  void erase (container_type & c, data_iterator p) const;
60  void insert (container_type & c, data_iterator p) const;
61  void update (container_type const & c) const;
62 
63  /** Internal: ListNParser iterator specific data */
64  struct iterator_data {
65  size_type n_;
66  };
67 
68  data_iterator setBegin (container_type const & c, iterator_data & d) const;
69  data_iterator setEnd (container_type const & c, iterator_data & d) const;
70  void setFromPosition (container_type const & c, iterator_data & d, data_iterator p) const;
71  data_iterator next (container_type const & c, iterator_data & d) const;
72  data_iterator raw (container_type const & c, iterator_data const & d) const;
73  };
74 
75 #ifndef DOXYGEN
76 
77  template <class ElementParser, class AuxPolicy>
78  struct ListParserPolicy<ElementParser, AuxPolicy, senf::detail::auxtag::none>
79  {
80  typedef ListNParser_Policy<ElementParser, AuxPolicy> type;
81  };
82 
83  template <class ElementParser, class AuxPolicy, class Transform>
84  struct ListParserPolicy<ElementParser, AuxPolicy,
85  senf::detail::auxtag::transform<Transform,
86  senf::detail::auxtag::none> >
87  {
88  typedef ListNParser_Policy< ElementParser,
89  TransformAuxParserPolicy<AuxPolicy, Transform> > type;
90  };
91 
92 #endif
93 
94 }}
95 
96 //-/////////////////////////////////////////////////////////////////////////////////////////////////
97 #endif
98 
99 
100 // Local Variables:
101 // mode: c++
102 // fill-column: 100
103 // comment-column: 40
104 // c-file-style: "senf"
105 // indent-tabs-mode: nil
106 // ispell-local-dictionary: "american"
107 // compile-command: "scons -u test"
108 // End: