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