4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief AuxParser public header */
31 #ifndef HH_SENF_Packets_AuxParser_
32 #define HH_SENF_Packets_AuxParser_ 1
34 #ifndef HH_SENF_Packets_Packets_
35 #error "Don't include 'AuxParser.hh' directly, include 'Packets.hh'"
39 #include "PacketParser.hh"
40 #include "SafeIterator.hh"
42 //#include "AuxParser.mpp"
43 //-/////////////////////////////////////////////////////////////////////////////////////////////////
48 /** \brief Internal: Prefix aux-parser policy
50 Place auxiliary field directly before a container/collection.
53 struct PrefixAuxParserPolicy
55 typedef PrefixAuxParserPolicy WrapperPolicy;
56 typedef PrefixAuxParserPolicy ParserPolicy;
58 static PacketParserBase::size_type const aux_bytes = P::fixed_bytes;
60 typename P::value_type aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
61 void aux(typename P::value_type const & v, PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
62 PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
65 /** \brief Internal: Fixed distance aux-parser policy
67 Place auxiliary field a fixed distance before the container/collection
69 template <class P, unsigned Dist>
70 struct FixedAuxParserPolicy
72 typedef FixedAuxParserPolicy WrapperPolicy;
73 typedef FixedAuxParserPolicy ParserPolicy;
75 static PacketParserBase::size_type const aux_bytes = 0;
77 typename P::value_type aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
78 void aux(typename P::value_type const & v, PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
79 PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
82 template <class P> struct DynamicWrapperAuxParserPolicy;
84 /** \brief Internal: Dynamic aux-parser policy
86 Place auxiliary field at a variable distance before the container/collection
89 struct DynamicAuxParserPolicy
91 typedef DynamicWrapperAuxParserPolicy<P> WrapperPolicy;
92 typedef DynamicAuxParserPolicy<P> ParserPolicy;
94 static PacketParserBase::size_type const aux_bytes = 0;
96 DynamicAuxParserPolicy(P p);
97 DynamicAuxParserPolicy(WrapperPolicy const & other);
99 typename P::value_type aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
100 void aux(typename P::value_type const & v, PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
101 PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
106 /** \brief Internal: Dynamic aux-parser policy (container wrapper)
108 Place auxiliary field at a variable distance before the container/collection. This is the
109 wrapper policy used by DynamicAuxParserPolicy
112 struct DynamicWrapperAuxParserPolicy
114 typedef DynamicWrapperAuxParserPolicy<P> WrapperPolicy;
115 typedef DynamicAuxParserPolicy<P> ParserPolicy;
117 static PacketParserBase::size_type const aux_bytes = 0;
119 DynamicWrapperAuxParserPolicy(ParserPolicy const & other);
121 typename P::value_type aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
122 void aux(typename P::value_type const & v, PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
123 PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
125 mutable SafePacketParserWrapper<P> p_;
128 /** \brief Internal: Apply transformation to arbitrary aux-parser policy
130 Transform must satisfy the interface
134 typedef unspecified value_type;
135 static value_type get(unspecified v);
136 static unspecified set(value_type v);
140 template <class Policy, class Transform>
141 struct TransformAuxParserPolicy
144 typedef TransformAuxParserPolicy<typename Policy::WrapperPolicy, Transform> WrapperPolicy;
145 typedef TransformAuxParserPolicy<typename Policy::ParserPolicy, Transform> ParserPolicy;
147 static PacketParserBase::size_type const aux_bytes = Policy::aux_bytes;
149 TransformAuxParserPolicy();
150 template <class Arg> TransformAuxParserPolicy(Arg const & arg);
152 typename Transform::value_type aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
153 void aux(typename Transform::value_type const & v, PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
156 struct PacketSizeAuxParserPolicy
158 typedef PacketSizeAuxParserPolicy WrapperPolicy;
159 typedef PacketSizeAuxParserPolicy ParserPolicy;
161 static PacketParserBase::size_type const aux_bytes = 0;
163 PacketParserBase::size_type aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
164 void aux(unsigned v, PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
165 PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
169 //-/////////////////////////////////////////////////////////////////////////////////////////////////
171 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_AuxParser_i_)
172 #define HH_SENF_Packets_AuxParser_i_
173 #include "AuxParser.cci"
174 //#include "AuxParser.ct"
175 #include "AuxParser.cti"
182 // comment-column: 40
183 // c-file-style: "senf"
184 // indent-tabs-mode: nil
185 // ispell-local-dictionary: "american"
186 // compile-command: "scons -u test"