162657e15ef37bd4a44c4144c51254e1b7f48a92
[senf.git] / Packets / AuxParser.hh
1 // $Id$
2 //
3 // Copyright (C) 2008 
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief AuxParser public header */
25
26 #ifndef HH_AuxParser_
27 #define HH_AuxParser_ 1
28
29 #ifndef HH_Packets_
30 #error "Don't include 'AuxParser.hh' directly, include 'Packets.hh'"
31 #endif
32
33 // Custom includes
34 #include "PacketParser.hh"
35 #include "SafeIterator.hh"
36
37 //#include "AuxParser.mpp"
38 ///////////////////////////////hh.p////////////////////////////////////////
39
40 namespace senf {
41 namespace detail {
42
43     template <class P>
44     struct PrefixAuxParserPolicy
45     {
46         typedef PrefixAuxParserPolicy WrapperPolicy;
47         typedef P ParserType;
48
49         static PacketParserBase::size_type const aux_bytes = ParserType::fixed_bytes;
50         
51         ParserType aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
52         PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
53     };
54
55     template <class P, unsigned Dist>
56     struct FixedAuxParserPolicy
57     {
58         typedef FixedAuxParserPolicy WrapperPolicy;
59         typedef P ParserType;
60
61         static PacketParserBase::size_type const aux_bytes = 0;
62         
63         ParserType aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
64         PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
65     };
66
67     template <class P> struct DynamicWrapperAuxParserPolicy;
68     
69     template <class P>
70     struct DynamicAuxParserPolicy
71     {
72         typedef DynamicWrapperAuxParserPolicy<P> WrapperPolicy;
73         typedef P ParserType;
74
75         static PacketParserBase::size_type const aux_bytes = 0;
76
77         DynamicAuxParserPolicy(ParserType p);
78         DynamicAuxParserPolicy(WrapperPolicy const & other);
79         
80         ParserType aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
81         PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
82
83         ParserType p_;
84     };
85
86     template <class P>
87     struct DynamicWrapperAuxParserPolicy
88     {
89         typedef DynamicAuxParserPolicy<P> ParserPolicy;
90         typedef P ParserType;
91
92         static PacketParserBase::size_type const aux_bytes = 0;
93
94         DynamicWrapperAuxParserPolicy(ParserPolicy const & other);
95         
96         ParserType aux(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
97         PacketParserBase::data_iterator adjust(PacketParserBase::data_iterator i, PacketParserBase::state_type s) const;
98
99         SafePacketParserWrapper<ParserType> p_;
100     };
101 }}
102
103 ///////////////////////////////hh.e////////////////////////////////////////
104 #endif
105 #if !defined(HH_Packets__decls_) && !defined(HH_AuxParser_i_)
106 #define HH_AuxParser_i_
107 //#include "AuxParser.cci"
108 //#include "AuxParser.ct"
109 #include "AuxParser.cti"
110 #endif
111
112 \f
113 // Local Variables:
114 // mode: c++
115 // fill-column: 100
116 // comment-column: 40
117 // c-file-style: "senf"
118 // indent-tabs-mode: nil
119 // ispell-local-dictionary: "american"
120 // compile-command: "scons -u test"
121 // End: