AuxParser.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 AuxParser inline template implementation */
16 
17 //#include "AuxParser.ih"
18 
19 // Custom includes
20 
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::detail::PrefixAuxParserPolicy<P>
26 
27 template <class P>
28 prefix_ typename P::value_type
29 senf::detail::PrefixAuxParserPolicy<P>::aux(PacketParserBase::data_iterator i,
30  PacketParserBase::state_type s)
31  const
32 {
33  return P(i, s).value();
34 }
35 
36 template <class P>
37 prefix_ void senf::detail::PrefixAuxParserPolicy<P>::aux(typename P::value_type const & v,
38  PacketParserBase::data_iterator i,
39  PacketParserBase::state_type s)
40  const
41 {
42  P(i, s).value(v);
43 }
44 
45 template <class P>
46 prefix_ senf::PacketParserBase::data_iterator
47 senf::detail::PrefixAuxParserPolicy<P>::adjust(PacketParserBase::data_iterator i,
48  PacketParserBase::state_type s)
49  const
50 {
51  return i+P::fixed_bytes;
52 }
53 
54 //-/////////////////////////////////////////////////////////////////////////////////////////////////
55 // senf::detail::FixedAuxParserPolicy<P>
56 
57 template <class P, unsigned Dist>
58 prefix_ typename P::value_type
59 senf::detail::FixedAuxParserPolicy<P,Dist>::aux(PacketParserBase::data_iterator i,
60  PacketParserBase::state_type s)
61  const
62 {
63  return P(i-Dist, s).value();
64 }
65 
66 template <class P, unsigned Dist>
67 prefix_ void senf::detail::FixedAuxParserPolicy<P,Dist>::aux(typename P::value_type const & v,
68  PacketParserBase::data_iterator i,
69  PacketParserBase::state_type s)
70  const
71 {
72  P(i-Dist, s).value(v);
73 }
74 
75 template <class P, unsigned Dist>
76 prefix_ senf::PacketParserBase::data_iterator
77 senf::detail::FixedAuxParserPolicy<P,Dist>::adjust(PacketParserBase::data_iterator i,
78  PacketParserBase::state_type s)
79  const
80 {
81  return i;
82 }
83 
84 //-/////////////////////////////////////////////////////////////////////////////////////////////////
85 // senf::detail::DynamicAuxParserPolicy<P>
86 
87 template <class P>
88 prefix_ senf::detail::DynamicAuxParserPolicy<P>::DynamicAuxParserPolicy(P p)
89  : p_ (p)
90 {}
91 
92 template <class P>
93 prefix_
94 senf::detail::DynamicAuxParserPolicy<P>::DynamicAuxParserPolicy(WrapperPolicy const & other)
95  : p_ (* other.p_)
96 {}
97 
98 template <class P>
99 prefix_ typename P::value_type
100 senf::detail::DynamicAuxParserPolicy<P>::aux(PacketParserBase::data_iterator i,
101  PacketParserBase::state_type s)
102  const
103 {
104  return p_.value();
105 }
106 
107 template <class P>
108 prefix_ void senf::detail::DynamicAuxParserPolicy<P>::aux(typename P::value_type const & v,
109  PacketParserBase::data_iterator i,
110  PacketParserBase::state_type s)
111  const
112 {
113  p_.value(v);
114 }
115 
116 template <class P>
117 prefix_ senf::PacketParserBase::data_iterator
118 senf::detail::DynamicAuxParserPolicy<P>::adjust(PacketParserBase::data_iterator i,
119  PacketParserBase::state_type s)
120  const
121 {
122  return i;
123 }
124 
125 //-/////////////////////////////////////////////////////////////////////////////////////////////////
126 // senf::detail::DynamicWrapperAuxParserPolicy<P>
127 
128 template <class P>
129 prefix_ senf::detail::DynamicWrapperAuxParserPolicy<P>::
130 DynamicWrapperAuxParserPolicy(ParserPolicy const & other)
131  : p_ (other.p_)
132 {}
133 
134 template <class P>
135 prefix_ typename P::value_type
136 senf::detail::DynamicWrapperAuxParserPolicy<P>::aux(PacketParserBase::data_iterator i,
137  PacketParserBase::state_type s)
138  const
139 {
140  return p_->value();
141 }
142 
143 template <class P>
144 prefix_ void
145 senf::detail::DynamicWrapperAuxParserPolicy<P>::aux(typename P::value_type const & v,
146  PacketParserBase::data_iterator i,
147  PacketParserBase::state_type s)
148  const
149 {
150  p_->value(v);
151 }
152 
153 template <class P>
154 prefix_ senf::PacketParserBase::data_iterator
155 senf::detail::DynamicWrapperAuxParserPolicy<P>::adjust(PacketParserBase::data_iterator i,
156  PacketParserBase::state_type s)
157  const
158 {
159  return i;
160 }
161 
162 //-/////////////////////////////////////////////////////////////////////////////////////////////////
163 // senf::detail::TransformAuxParserPolicy<Policy,Transform>
164 
165 template <class Policy, class Transform>
166 prefix_ senf::detail::TransformAuxParserPolicy<Policy,Transform>::TransformAuxParserPolicy()
167 {}
168 
169 template <class Policy, class Transform>
170 template <class Arg>
171 prefix_ senf::detail::TransformAuxParserPolicy<Policy,Transform>::
172 TransformAuxParserPolicy(Arg const & arg)
173  : Policy(arg)
174 {}
175 
176 template <class Policy, class Transform>
177 prefix_ typename Transform::value_type
178 senf::detail::TransformAuxParserPolicy<Policy,Transform>::aux(PacketParserBase::data_iterator i,
179  PacketParserBase::state_type s)
180  const
181 {
182  return Transform::get(Policy::aux(i,s));
183 }
184 
185 template <class Policy, class Transform>
186 prefix_ void senf::detail::TransformAuxParserPolicy<Policy,Transform>::
187 aux(typename Transform::value_type const & v, PacketParserBase::data_iterator i,
188  PacketParserBase::state_type s)
189  const
190 {
191  Policy::aux(Transform::set(v), i, s);
192 }
193 
194 //-/////////////////////////////////////////////////////////////////////////////////////////////////
195 #undef prefix_
196 
197 
198 // Local Variables:
199 // mode: c++
200 // fill-column: 100
201 // comment-column: 40
202 // c-file-style: "senf"
203 // indent-tabs-mode: nil
204 // ispell-local-dictionary: "american"
205 // compile-command: "scons -u test"
206 // End: