2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 // Stefan Bund <g0dil@berlios.de>
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 \brief ParseList inline template implementation */
24 #include "ParseList.ih"
28 #define prefix_ inline
29 ///////////////////////////////cti.p///////////////////////////////////////
31 ///////////////////////////////////////////////////////////////////////////
32 // senf::Parse_List<ListPolicy>
34 template <class ListPolicy>
35 prefix_ senf::Parse_List<ListPolicy>::Parse_List(data_iterator i, state_type s)
36 : PacketParserBase(i,s), ListPolicy()
39 template <class ListPolicy>
40 prefix_ senf::Parse_List<ListPolicy>::Parse_List(ListPolicy policy,
41 data_iterator i, state_type s)
42 : PacketParserBase(i,s), ListPolicy(policy)
45 template <class ListPolicy>
46 prefix_ senf::PacketParserBase::size_type
47 senf::Parse_List<ListPolicy>::bytes()
50 return ListPolicy::bytes(i(),state());
53 ///////////////////////////////////////////////////////////////////////////
54 // Container interface
56 template <class ListPolicy>
57 prefix_ senf::PacketParserBase::size_type
58 senf::Parse_List<ListPolicy>::size()
61 return ListPolicy::size(i(),state());
64 template <class ListPolicy>
65 prefix_ bool senf::Parse_List<ListPolicy>::empty()
68 return begin() == end();
71 template <class ListPolicy>
72 prefix_ typename senf::Parse_List<ListPolicy>::iterator
73 senf::Parse_List<ListPolicy>::begin()
76 return iterator(i(),state(),iterator::Begin);
79 template <class ListPolicy>
80 prefix_ typename senf::Parse_List<ListPolicy>::iterator
81 senf::Parse_List<ListPolicy>::end()
84 return iterator(i(),state(),iterator::End);
87 template <class ListPolicy>
88 prefix_ typename senf::Parse_List<ListPolicy>::value_type
89 senf::Parse_List<ListPolicy>::front()
92 BOOST_ASSERT( ! empty() );
96 template <class ListPolicy>
97 template <class Value>
98 prefix_ void senf::Parse_List<ListPolicy>::push_back(Value value, size_type n)
102 c.push_back(value,n);
105 template <class ListPolicy>
106 prefix_ void senf::Parse_List<ListPolicy>::push_back_space(size_type n)
110 c.push_back_space(n);
113 template <class ListPolicy>
114 template <class Value>
115 prefix_ void senf::Parse_List<ListPolicy>::push_front(Value value, size_type n)
119 c.push_front(value,n);
122 template <class ListPolicy>
123 prefix_ void senf::Parse_List<ListPolicy>::push_front_space(size_type n)
127 c.push_front_space(n);
130 template <class ListPolicy>
131 prefix_ void senf::Parse_List<ListPolicy>::resize(size_type n)
138 template <class ListPolicy>
139 template <class Value>
140 prefix_ void senf::Parse_List<ListPolicy>::resize(size_type n, Value value)
147 ///////////////////////////////////////////////////////////////////////////
148 // senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>
150 template <class ElementParser, class IteratorPolicy>
151 prefix_ senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::Parse_List_Iterator()
154 template <class ElementParser, class IteratorPolicy>
155 prefix_ senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::
156 Parse_List_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, Begin_t)
157 : IteratorPolicy(), i_(IteratorPolicy::setBegin(i,s)), s_(s)
160 template <class ElementParser, class IteratorPolicy>
161 prefix_ senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::
162 Parse_List_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s, End_t)
163 : IteratorPolicy(), i_(IteratorPolicy::setEnd(i,s)), s_(s)
166 template <class ElementParser, class IteratorPolicy>
167 prefix_ senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::
168 Parse_List_Iterator(PacketParserBase::data_iterator i, PacketParserBase::state_type s,
169 PacketParserBase::data_iterator p)
170 : IteratorPolicy(), i_(p), s_(s)
172 IteratorPolicy::setFromPosition(i,s,p);
175 template <class ElementParser, class IteratorPolicy>
176 prefix_ senf::PacketParserBase::data_iterator
177 senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::raw()
180 return IteratorPolicy::raw(i_,s_);
183 template <class ElementParser, class IteratorPolicy>
184 prefix_ ElementParser
185 senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::dereference()
188 return ElementParser(i_,s_);
191 template <class ElementParser, class IteratorPolicy>
192 prefix_ bool senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::
193 equal(Parse_List_Iterator const & other)
196 return i_ == other.i_;
199 template <class ElementParser, class IteratorPolicy>
200 prefix_ void senf::detail::Parse_List_Iterator<ElementParser,IteratorPolicy>::increment()
202 i_ = IteratorPolicy::next(i_,s_);
205 ///////////////////////////////////////////////////////////////////////////
206 // senf::Parse_List_Container<ListPolicy>
208 // Structors and default members
210 template <class ListPolicy>
211 prefix_ senf::Parse_List_Container<ListPolicy>::
212 Parse_List_Container(parser_type const & list)
213 : ListPolicy(list), state_(list.state()), i_(std::distance(data().begin(),list.i()))
216 template <class ListPolicy>
217 prefix_ senf::Parse_List_Container<ListPolicy>::~Parse_List_Container()
219 ListPolicy::update(i(),state());
224 template <class ListPolicy>
225 prefix_ typename senf::Parse_List_Container<ListPolicy>::size_type
226 senf::Parse_List_Container<ListPolicy>::size()
229 ListPolicy::update(i(),state());
230 return ListPolicy::size(i(),state());
233 template <class ListPolicy>
234 prefix_ bool senf::Parse_List_Container<ListPolicy>::empty()
237 ListPolicy::update(i(),state());
238 return begin() == end();
241 template <class ListPolicy>
242 prefix_ typename senf::Parse_List_Container<ListPolicy>::iterator
243 senf::Parse_List_Container<ListPolicy>::begin()
246 ListPolicy::update(i(),state());
247 return iterator(i(),state(),iterator::Begin);
250 template <class ListPolicy>
251 prefix_ typename senf::Parse_List_Container<ListPolicy>::iterator
252 senf::Parse_List_Container<ListPolicy>::end()
255 ListPolicy::update(i(),state());
256 return iterator(i(),state(),iterator::End);
259 template <class ListPolicy>
260 prefix_ typename senf::Parse_List_Container<ListPolicy>::value_type
261 senf::Parse_List_Container<ListPolicy>::front()
264 BOOST_ASSERT( ! empty() );
270 template <class ListPolicy>
271 template <class Value>
272 prefix_ void senf::Parse_List_Container<ListPolicy>::insert(iterator pos,
278 template <class ListPolicy>
279 prefix_ void senf::Parse_List_Container<ListPolicy>::erase(iterator f, iterator l)
281 erase(f,std::distance(f,l));
284 template <class ListPolicy>
285 template <class Value>
286 prefix_ void senf::Parse_List_Container<ListPolicy>::push_back(Value value,
289 insert(end(),n,value);
292 template <class ListPolicy>
293 prefix_ void senf::Parse_List_Container<ListPolicy>::push_back_space(size_type n)
298 template <class ListPolicy>
299 template <class Value>
300 prefix_ void senf::Parse_List_Container<ListPolicy>::push_front(Value value,
303 insert(begin(),n,value);
306 template <class ListPolicy>
307 prefix_ void senf::Parse_List_Container<ListPolicy>::push_front_space(size_type n)
314 template <class ListPolicy>
315 prefix_ typename senf::Parse_List_Container<ListPolicy>::parser_type
316 senf::Parse_List_Container<ListPolicy>::parser()
319 ListPolicy::update(i(),state());
320 return parser_type(i(),state());
323 template <class ListPolicy>
324 prefix_ typename senf::Parse_List_Container<ListPolicy>::data_iterator
325 senf::Parse_List_Container<ListPolicy>::i()
328 return boost::next(data().begin(),i_);
331 template <class ListPolicy>
332 prefix_ typename senf::Parse_List_Container<ListPolicy>::state_type
333 senf::Parse_List_Container<ListPolicy>::state()
339 template <class ListPolicy>
340 prefix_ senf::PacketData & senf::Parse_List_Container<ListPolicy>::data()
346 template <class ListPolicy>
347 prefix_ typename senf::Parse_List_Container<ListPolicy>::size_type
348 senf::Parse_List_Container<ListPolicy>::bytes()
351 ListPolicy::update(i(),state());
352 return ListPolicy::bytes(i(),state());
355 template <class ListPolicy>
356 prefix_ void senf::Parse_List_Container<ListPolicy>::init()
362 ///////////////////////////////cti.e///////////////////////////////////////
369 // comment-column: 40
370 // c-file-style: "senf"
371 // indent-tabs-mode: nil
372 // ispell-local-dictionary: "american"
373 // compile-command: "scons -u test"