205d88dc0e0c326e466c14f26f462117d9719817
[senf.git] / Packets / AuxParser.cti
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 inline template implementation */
25
26 //#include "AuxParser.ih"
27
28 // Custom includes
29
30 #define prefix_ inline
31 ///////////////////////////////cti.p///////////////////////////////////////
32
33 ///////////////////////////////////////////////////////////////////////////
34 // senf::detail::PrefixAuxParserPolicy<P>
35
36 template <class P>
37 prefix_ typename senf::detail::PrefixAuxParserPolicy<P>::ParserType
38 senf::detail::PrefixAuxParserPolicy<P>::aux(PacketParserBase::data_iterator i,
39                                             PacketParserBase::state_type s)
40     const
41 {
42     return ParserType(i, s);
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+ParserType::fixed_bytes;
52 }
53
54 ///////////////////////////////////////////////////////////////////////////
55 // senf::detail::FixedAuxParserPolicy<P>
56
57 template <class P, unsigned Dist>
58 prefix_ typename senf::detail::FixedAuxParserPolicy<P,Dist>::ParserType
59 senf::detail::FixedAuxParserPolicy<P,Dist>::aux(PacketParserBase::data_iterator i,
60                                                 PacketParserBase::state_type s)
61     const
62 {
63     return ParserType(i-Dist, s);
64 }
65
66 template <class P, unsigned Dist>
67 prefix_ senf::PacketParserBase::data_iterator
68 senf::detail::FixedAuxParserPolicy<P,Dist>::adjust(PacketParserBase::data_iterator i,
69                                                    PacketParserBase::state_type s)
70     const
71 {
72     return i;
73 }
74
75 ///////////////////////////////////////////////////////////////////////////
76 // senf::detail::DynamicAuxParserPolicy<P>
77
78 template <class P>
79 prefix_ senf::detail::DynamicAuxParserPolicy<P>::DynamicAuxParserPolicy(ParserType p)
80     : p_ (p)
81 {}
82
83 template <class P>
84 prefix_
85 senf::detail::DynamicAuxParserPolicy<P>::DynamicAuxParserPolicy(WrapperPolicy const & other)
86     : p_ (* other.p_)
87 {}
88
89 template <class P>
90 prefix_ typename senf::detail::DynamicAuxParserPolicy<P>::ParserType
91 senf::detail::DynamicAuxParserPolicy<P>::aux(PacketParserBase::data_iterator i,
92                                              PacketParserBase::state_type s)
93     const
94 {
95     return p_;
96 }
97
98 template <class P>
99 prefix_ senf::PacketParserBase::data_iterator
100 senf::detail::DynamicAuxParserPolicy<P>::adjust(PacketParserBase::data_iterator i,
101                                                 PacketParserBase::state_type s)
102     const
103 {
104     return i;
105 }
106
107 ///////////////////////////////////////////////////////////////////////////
108 // senf::detail::DynamicWrapperAuxParserPolicy<P>
109
110 template <class P>
111 prefix_ senf::detail::DynamicWrapperAuxParserPolicy<P>::
112 DynamicWrapperAuxParserPolicy(ParserPolicy const & other)
113     : p_ (other.p_)
114 {}
115
116 template <class P>
117 prefix_ typename senf::detail::DynamicWrapperAuxParserPolicy<P>::ParserType
118 senf::detail::DynamicWrapperAuxParserPolicy<P>::aux(PacketParserBase::data_iterator i,
119                                                     PacketParserBase::state_type s)
120     const
121 {
122     return * p_;
123 }
124
125 template <class P>
126 prefix_ senf::PacketParserBase::data_iterator
127 senf::detail::DynamicWrapperAuxParserPolicy<P>::adjust(PacketParserBase::data_iterator i,
128                                                        PacketParserBase::state_type s)
129     const
130 {
131     return i;
132 }
133
134 ///////////////////////////////cti.e///////////////////////////////////////
135 #undef prefix_
136
137 \f
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: