ListNParser.cti
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 inline template implementation */
16 
17 #include "ListNParser.ih"
18 
19 // Custom includes
20 
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 template <class ElementParser, class AuxPolicy>
25 prefix_ senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::ListNParser_Policy()
26 {}
27 
28 template <class ElementParser, class AuxPolicy>
29 prefix_ senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::
30 ListNParser_Policy(parser_policy const & policy)
31  : AuxPolicy(policy)
32 {}
33 
34 template <class ElementParser, class AuxPolicy>
35 template <class Arg>
36 prefix_
37 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::ListNParser_Policy(Arg const & aux)
38  : AuxPolicy (aux)
39 {}
40 
41 template <class ElementParser, class AuxPolicy>
42 prefix_ typename senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::size_type
43 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::bytes(data_iterator i, state_type s)
44  const
45 {
46  container_type c (parser_type(*this, i, s));
47  return std::distance(i,c.end().raw());
48 }
49 
50 template <class ElementParser, class AuxPolicy>
51 prefix_ typename senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::size_type
52 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::size(data_iterator i, state_type s)
53  const
54 {
55  return AuxPolicy::aux(i,s);
56 }
57 
58 template <class ElementParser, class AuxPolicy>
59 prefix_ void senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::init(data_iterator i,
60  state_type s)
61  const
62 {
63  AuxPolicy::aux(0,i,s);
64 }
65 
66 template <class ElementParser, class AuxPolicy>
67 prefix_ void
68 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::construct(container_type & c)
69  const
70 {}
71 
72 template <class ElementParser, class AuxPolicy>
73 prefix_ void
74 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::destruct(container_type & c)
75  const
76 {}
77 
78 template <class ElementParser, class AuxPolicy>
79 prefix_ void
80 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::erase(container_type & c,
81  data_iterator p)
82  const
83 {
84  this->aux(this->aux(c.i(),c.state())-1,c.i(),c.state());
85 }
86 
87 template <class ElementParser, class AuxPolicy>
88 prefix_ void
89 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::insert(container_type & c,
90  data_iterator p)
91  const
92 {
93  this->aux(this->aux(c.i(),c.state())+1,c.i(),c.state());
94 }
95 
96 template <class ElementParser, class AuxPolicy>
97 prefix_ void
98 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::update(container_type const & c)
99  const
100 {}
101 
102 template <class ElementParser, class AuxPolicy>
103 prefix_ typename senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::data_iterator
104 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::setBegin(container_type const & c,
105  iterator_data & d)
106  const
107 {
108  d.n_ = this->aux(c.i(),c.state());
109  return d.n_ ? this->adjust(c.i(),c.state()) : c.data().end();
110 }
111 
112 template <class ElementParser, class AuxPolicy>
113 prefix_ typename senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::data_iterator
114 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::setEnd(container_type const & c,
115  iterator_data & d)
116  const
117 {
118  d.n_ = 0;
119  return c.data().end();
120 }
121 
122 template <class ElementParser, class AuxPolicy>
123 prefix_ typename senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::data_iterator
124 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::next(container_type const & c,
125  iterator_data & d)
126  const
127 {
128  --d.n_;
129  return d.n_ ? boost::next( container_type::iterator::get(d).i(),
130  senf::bytes(* container_type::iterator::get(d)) )
131  : c.data().end();
132 }
133 
134 //-/////////////////////////////////////////////////////////////////////////////////////////////////
135 #undef prefix_
136 
137 
138 // Local Variables:
139 // mode: c++
140 // fill-column: 100
141 // comment-column: 40
142 // c-file-style: "senf"
143 // indent-tabs-mode: nil
144 // ispell-local-dictionary: "american"
145 // compile-command: "scons -u test"
146 // End: