4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief ListBParser inline template implementation */
31 #include "ListBParser.ih"
35 #define prefix_ inline
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 // senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>
41 template <class ElementParser, class AuxPolicy>
42 prefix_ senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::ListBParser_Policy()
45 template <class ElementParser, class AuxPolicy>
48 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::ListBParser_Policy(Arg const & arg)
52 template <class ElementParser, class AuxPolicy>
53 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::size_type
54 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::bytes(data_iterator i, state_type s)
57 return AuxPolicy::aux(i,s) + AuxPolicy::aux_bytes;
60 template <class ElementParser, class AuxPolicy>
61 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::size_type
62 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::size(data_iterator i, state_type s)
65 parser_type p (*this, i, s);
67 return std::distance(c.begin(),c.end());
70 template <class ElementParser, class AuxPolicy>
71 prefix_ void senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::init(data_iterator i,
75 AuxPolicy::aux(0,i,s);
78 //-/////////////////////////////////////////////////////////////////////////////////////////////////
79 // senf::detail::ListBParser_Policy<ElementParser,BytesParser>
81 template <class ElementParser, class AuxPolicy>
82 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::size_type
83 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::bytes(data_iterator i,
87 return AuxPolicy::WrapperPolicy::aux(i,s) + AuxPolicy::aux_bytes;
90 template <class ElementParser, class AuxPolicy>
91 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::size_type
92 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::size(data_iterator i,
99 template <class ElementParser, class AuxPolicy>
100 prefix_ void senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
101 init(data_iterator i, state_type s)
104 container_size_ = s->size();
105 AuxPolicy::WrapperPolicy::aux(0,i,s);
108 template <class ElementParser, class AuxPolicy>
110 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
111 construct(container_type & c)
115 template <class ElementParser, class AuxPolicy>
117 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
118 destruct(container_type & c)
122 template <class ElementParser, class AuxPolicy>
123 prefix_ void senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
124 erase(container_type & c, data_iterator p)
126 size_type b (senf::bytes(ElementParser(p,c.state())));
127 AuxPolicy::WrapperPolicy::aux(
128 AuxPolicy::WrapperPolicy::aux(c.i(), c.state())-b, c.i(), c.state());
130 // The container will be reduced by b bytes directly after this call
131 container_size_ = c.data().size()-b;
134 template <class ElementParser, class AuxPolicy>
136 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
137 insert(container_type & c, data_iterator p)
139 size_type b (senf::bytes(ElementParser(p,c.state())));
140 AuxPolicy::WrapperPolicy::aux(
141 AuxPolicy::WrapperPolicy::aux(c.i(), c.state())+b, c.i(), c.state());
143 container_size_ = c.data().size();
146 template <class ElementParser, class AuxPolicy>
148 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
149 update(container_type const & c)
152 if (container_size_ == c.data().size())
155 data_iterator i (AuxPolicy::WrapperPolicy::adjust(c.i(), c.state()));
157 for (size_type n (n_); n; --n, std::advance(j,senf::bytes(ElementParser(j,c.state())))) ;
158 aux( std::distance(i,j), c.i(), c.state() );
160 aux ( aux(c.i(),c.state()) + c.data().size() - container_size_, c.i(), c.state() );
162 container_size_ = c.data().size();
165 template <class ElementParser, class AuxPolicy>
166 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::data_iterator
167 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
168 setBegin(container_type const & c, iterator_data & d)
171 return AuxPolicy::WrapperPolicy::adjust(c.i(), c.state());
174 template <class ElementParser, class AuxPolicy>
175 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::data_iterator
176 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
177 setEnd(container_type const & c, iterator_data & d)
180 return boost::next(AuxPolicy::WrapperPolicy::adjust(c.i(), c.state()),aux(c.i(),c.state()));
183 template <class ElementParser, class AuxPolicy>
185 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
186 setFromPosition(container_type const & c, iterator_data & d, data_iterator p)
190 template <class ElementParser, class AuxPolicy>
191 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::data_iterator
192 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
193 next(container_type const & c, iterator_data & d)
196 return boost::next( container_type::iterator::get(d).i(),
197 senf::bytes(ElementParser( container_type::iterator::get(d).i(),
201 template <class ElementParser, class AuxPolicy>
202 prefix_ typename senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::data_iterator
203 senf::detail::ListBParser_Policy<ElementParser,AuxPolicy>::container_policy::
204 raw(container_type const & c, iterator_data const & d)
207 return container_type::iterator::get(d).i();
210 //-/////////////////////////////////////////////////////////////////////////////////////////////////
217 // comment-column: 40
218 // c-file-style: "senf"
219 // indent-tabs-mode: nil
220 // ispell-local-dictionary: "american"
221 // compile-command: "scons -u test"