16c4a336084a5e13a298965265cc90809179794c
[senf.git] / senf / Packets / ListNParser.cti
1 // $Id$
2 //
3 // Copyright (C) 2007
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 ListNParser inline template implementation */
25
26 #include "ListNParser.ih"
27
28 // Custom includes
29
30 #define prefix_ inline
31 //-/////////////////////////////////////////////////////////////////////////////////////////////////
32
33 template <class ElementParser, class AuxPolicy>
34 prefix_ senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::ListNParser_Policy()
35 {}
36
37 template <class ElementParser, class AuxPolicy>
38 prefix_ senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::
39 ListNParser_Policy(parser_policy const & policy)
40   : AuxPolicy(policy)
41 {}
42
43 template <class ElementParser, class AuxPolicy>
44 template <class Arg>
45 prefix_
46 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::ListNParser_Policy(Arg const & aux)
47     : AuxPolicy (aux)
48 {}
49
50 template <class ElementParser, class AuxPolicy>
51 prefix_ typename senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::size_type
52 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::bytes(data_iterator i, state_type s)
53     const
54 {
55     container_type c (parser_type(*this, i, s));
56     return std::distance(i,c.end().raw());
57 }
58
59 template <class ElementParser, class AuxPolicy>
60 prefix_ typename senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::size_type
61 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::size(data_iterator i, state_type s)
62     const
63 {
64     return AuxPolicy::aux(i,s);
65 }
66
67 template <class ElementParser, class AuxPolicy>
68 prefix_ void senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::init(data_iterator i,
69                                                                              state_type s)
70     const
71 {
72     AuxPolicy::aux(0,i,s);
73 }
74
75 template <class ElementParser, class AuxPolicy>
76 prefix_ void
77 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::construct(container_type & c)
78     const
79 {}
80
81 template <class ElementParser, class AuxPolicy>
82 prefix_ void
83 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::destruct(container_type & c)
84     const
85 {}
86
87 template <class ElementParser, class AuxPolicy>
88 prefix_ void
89 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::erase(container_type & c,
90                                                                  data_iterator p)
91     const
92 {
93     this->aux(this->aux(c.i(),c.state())-1,c.i(),c.state());
94 }
95
96 template <class ElementParser, class AuxPolicy>
97 prefix_ void
98 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::insert(container_type & c,
99                                                                   data_iterator p)
100     const
101 {
102     this->aux(this->aux(c.i(),c.state())+1,c.i(),c.state());
103 }
104
105 template <class ElementParser, class AuxPolicy>
106 prefix_ void
107 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::update(container_type const & c)
108     const
109 {}
110
111 template <class ElementParser, class AuxPolicy>
112 prefix_ typename senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::data_iterator
113 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::setBegin(container_type const & c,
114                                                                     iterator_data & d)
115     const
116 {
117     d.n_ = this->aux(c.i(),c.state());
118     return d.n_ ? this->adjust(c.i(),c.state()) : c.data().end();
119 }
120
121 template <class ElementParser, class AuxPolicy>
122 prefix_ typename senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::data_iterator
123 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::setEnd(container_type const & c,
124                                                                   iterator_data & d)
125     const
126 {
127     d.n_ = 0;
128     return c.data().end();
129 }
130
131 template <class ElementParser, class AuxPolicy>
132 prefix_ typename senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::data_iterator
133 senf::detail::ListNParser_Policy<ElementParser,AuxPolicy>::next(container_type const & c,
134                                                                 iterator_data & d)
135     const
136 {
137     --d.n_;
138     return d.n_ ? boost::next( container_type::iterator::get(d).i(),
139                                senf::bytes(* container_type::iterator::get(d)) )
140         : c.data().end();
141 }
142
143 //-/////////////////////////////////////////////////////////////////////////////////////////////////
144 #undef prefix_
145
146 \f
147 // Local Variables:
148 // mode: c++
149 // fill-column: 100
150 // comment-column: 40
151 // c-file-style: "senf"
152 // indent-tabs-mode: nil
153 // ispell-local-dictionary: "american"
154 // compile-command: "scons -u test"
155 // End: