4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief AuxParser public header */
26 #ifndef HH_SENF_Packets_AuxParser_
27 #define HH_SENF_Packets_AuxParser_ 1
29 #ifndef HH_SENF_Packets_Packets_
30 #error "Don't include 'AuxParser.hh' directly, include 'Packets.hh'"
34 #include "PacketParser.hh"
35 #include "SafeIterator.hh"
37 //#include "AuxParser.mpp"
38 ///////////////////////////////hh.p////////////////////////////////////////
43 /** \brief Internal: Prefix aux-parser policy
45 Place auxiliary field directly before a container/collection.
48 struct PrefixAuxParserPolicy
50 typedef PrefixAuxParserPolicy WrapperPolicy;
51 typedef PrefixAuxParserPolicy ParserPolicy;
53 static PacketParserBase::size_type const aux_bytes = P::fixed_bytes;
55 typename P::value_type aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
56 void aux(typename P::value_type const & v, PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
57 PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
60 /** \brief Internal: Fixed distance aux-parser policy
62 Place auxiliary field a fixed distance before the container/collection
64 template <class P, unsigned Dist>
65 struct FixedAuxParserPolicy
67 typedef FixedAuxParserPolicy WrapperPolicy;
68 typedef FixedAuxParserPolicy ParserPolicy;
70 static PacketParserBase::size_type const aux_bytes = 0;
72 typename P::value_type aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
73 void aux(typename P::value_type const & v, PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
74 PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
77 template <class P> struct DynamicWrapperAuxParserPolicy;
79 /** \brief Internal: Dynamic aux-parser policy
81 Place auxiliary field at a variable distance before the container/collection
84 struct DynamicAuxParserPolicy
86 typedef DynamicWrapperAuxParserPolicy<P> WrapperPolicy;
87 typedef DynamicAuxParserPolicy<P> ParserPolicy;
89 static PacketParserBase::size_type const aux_bytes = 0;
91 DynamicAuxParserPolicy(P p);
92 DynamicAuxParserPolicy(WrapperPolicy const & other);
94 typename P::value_type aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
95 void aux(typename P::value_type const & v, PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
96 PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
101 /** \brief Internal: Dynamic aux-parser policy (container wrapper)
103 Place auxiliary field at a variable distance before the container/collection. This is the
104 wrapper policy used by DynamicAuxParserPolicy
107 struct DynamicWrapperAuxParserPolicy
109 typedef DynamicWrapperAuxParserPolicy<P> WrapperPolicy;
110 typedef DynamicAuxParserPolicy<P> ParserPolicy;
112 static PacketParserBase::size_type const aux_bytes = 0;
114 DynamicWrapperAuxParserPolicy(ParserPolicy const & other);
116 typename P::value_type aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
117 void aux(typename P::value_type const & v, PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
118 PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
120 mutable SafePacketParserWrapper<P> p_;
123 /** \brief Internal: Apply transformation to arbitrary aux-parser policy
125 Transform must satisfy the interface
129 typedef unspecified value_type;
130 static value_type get(unspecified v);
131 static unspecified set(value_type v);
135 template <class Policy, class Transform>
136 struct TransformAuxParserPolicy
139 typedef TransformAuxParserPolicy<typename Policy::WrapperPolicy, Transform> WrapperPolicy;
140 typedef TransformAuxParserPolicy<typename Policy::ParserPolicy, Transform> ParserPolicy;
142 static PacketParserBase::size_type const aux_bytes = Policy::aux_bytes;
144 TransformAuxParserPolicy();
145 template <class Arg> TransformAuxParserPolicy(Arg const & arg);
147 typename Transform::value_type aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
148 void aux(typename Transform::value_type const & v, PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
151 struct PacketSizeAuxParserPolicy
153 typedef PacketSizeAuxParserPolicy WrapperPolicy;
154 typedef PacketSizeAuxParserPolicy ParserPolicy;
156 static PacketParserBase::size_type const aux_bytes = 0;
158 PacketParserBase::size_type aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
159 void aux(unsigned v, PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
160 PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
164 ///////////////////////////////hh.e////////////////////////////////////////
166 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_AuxParser_i_)
167 #define HH_SENF_Packets_AuxParser_i_
168 #include "AuxParser.cci"
169 //#include "AuxParser.ct"
170 #include "AuxParser.cti"
177 // comment-column: 40
178 // c-file-style: "senf"
179 // indent-tabs-mode: nil
180 // ispell-local-dictionary: "american"
181 // compile-command: "scons -u test"