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 ListBParser inline template implementation */
26 #include "ListBParser.ih"
30 #define prefix_ inline
31 ///////////////////////////////cti.p///////////////////////////////////////
33 ///////////////////////////////////////////////////////////////////////////
34 // senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>
36 template <class ElementParser, class AuxPolicy>
37 prefix_ senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::ListBParser_Policy()
40 template <class ElementParser, class AuxPolicy>
43 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::ListBParser_Policy(Arg const & arg)
47 template <class ElementParser, class AuxPolicy>
48 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::size_type
49 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::bytes(data_iterator i, state_type s)
52 return AuxPolicy::aux(i,s) + AuxPolicy::aux_bytes;
55 template <class ElementParser, class AuxPolicy>
56 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::size_type
57 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::size(data_iterator i, state_type s)
60 parser_type p (*this, i, s);
62 return std::distance(c.begin(),c.end());
65 template <class ElementParser, class AuxPolicy>
66 prefix_ void senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::init(data_iterator i,
70 AuxPolicy::aux(0,i,s);
73 ///////////////////////////////////////////////////////////////////////////
74 // senf::detail::ListBParser_Policy<ElementParser,BytesParser>
76 template <class ElementParser, class AuxPolicy>
78 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
79 container_policy(parser_policy const & p)
82 data_iterator const e (boost::next(parser_type::get(p).i(),parser_type::get(p).bytes()));
83 data_iterator i (AuxPolicy::adjust(parser_type::get(p).i(), parser_type::get(p).state()));
85 ++n_, std::advance(i,senf::bytes(ElementParser(i,parser_type::get(p).state())))) ;
86 container_size_ = parser_type::get(p).data().size();
89 template <class ElementParser, class AuxPolicy>
90 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::size_type
91 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::bytes(data_iterator i,
95 return AuxPolicy::aux(i,s) + AuxPolicy::aux_bytes;
98 template <class ElementParser, class AuxPolicy>
99 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::size_type
100 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::size(data_iterator i,
107 template <class ElementParser, class AuxPolicy>
108 prefix_ void senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
109 init(data_iterator i, state_type s)
112 container_size_ = s->size();
113 AuxPolicy::aux(0,i,s);
116 template <class ElementParser, class AuxPolicy>
117 prefix_ void senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
118 erase(container_type & c, data_iterator p)
120 size_type b (senf::bytes(ElementParser(p,c.state())));
121 AuxPolicy::aux( AuxPolicy::aux(c.i(), c.state())-b, c.i(), c.state());
123 // The container will be reduced by b bytes directly after this call
124 container_size_ = c.data().size()-b;
127 template <class ElementParser, class AuxPolicy>
129 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
130 insert(container_type & c, data_iterator p)
132 size_type b (senf::bytes(ElementParser(p,c.state())));
133 AuxPolicy::aux( AuxPolicy::aux(c.i(), c.state())+b, c.i(), c.state());
135 container_size_ = c.data().size();
138 template <class ElementParser, class AuxPolicy>
140 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
141 update(container_type const & c)
144 if (container_size_ == c.data().size())
146 data_iterator i (AuxPolicy::adjust(c.i(), c.state()));
148 for (size_type n (n_); n; --n, std::advance(j,senf::bytes(ElementParser(j,c.state())))) ;
149 aux( std::distance(i,j), c.i(), c.state() );
150 container_size_ = c.data().size();
153 template <class ElementParser, class AuxPolicy>
154 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::data_iterator
155 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
156 setBegin(container_type const & c, iterator_data & d)
159 return AuxPolicy::adjust(c.i(), c.state());
162 template <class ElementParser, class AuxPolicy>
163 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::data_iterator
164 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
165 setEnd(container_type const & c, iterator_data & d)
168 return boost::next(AuxPolicy::adjust(c.i(), c.state()),aux(c.i(),c.state()));
171 template <class ElementParser, class AuxPolicy>
173 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
174 setFromPosition(container_type const & c, iterator_data & d, data_iterator p)
178 template <class ElementParser, class AuxPolicy>
179 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::data_iterator
180 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
181 next(container_type const & c, iterator_data & d)
184 return boost::next( container_type::iterator::get(d).i(),
185 senf::bytes(ElementParser( container_type::iterator::get(d).i(),
189 template <class ElementParser, class AuxPolicy>
190 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::data_iterator
191 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
192 raw(container_type const & c, iterator_data const & d)
195 return container_type::iterator::get(d).i();
198 ///////////////////////////////cti.e///////////////////////////////////////
205 // comment-column: 40
206 // c-file-style: "senf"
207 // indent-tabs-mode: nil
208 // ispell-local-dictionary: "american"
209 // compile-command: "scons -u test"