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 non-inline template implementation */
24 #include "ParseList.ih"
29 ///////////////////////////////ct.p////////////////////////////////////////
31 ///////////////////////////////////////////////////////////////////////////
32 // senf::Parse_List<ElementParser,ListPolicy>
34 template <class ListPolicy>
35 prefix_ void senf::Parse_List<ListPolicy>::init()
38 ListPolicy::init(i(),state());
40 iterator const e (end());
45 template <class ListPolicy>
46 prefix_ typename senf::Parse_List<ListPolicy>::value_type
47 senf::Parse_List<ListPolicy>::back()
50 BOOST_ASSERT( ! empty() );
51 iterator i (begin()), j;
52 iterator const e (end());
53 for (j=i; i!=e; j=i, ++i) ;
57 ///////////////////////////////////////////////////////////////////////////
58 // senf::Parse_List_Container<ListPolicy>
60 template <class ListPolicy>
61 prefix_ typename senf::Parse_List_Container<ListPolicy>::value_type
62 senf::Parse_List_Container<ListPolicy>::back()
65 BOOST_ASSERT( ! empty() );
66 iterator i (begin()), j;
67 iterator const e (end());
68 for (j=i; i!=e; j=i, ++i) ;
72 template <class ListPolicy>
73 prefix_ void senf::Parse_List_Container<ListPolicy>::shift(iterator pos, size_type n)
75 ListPolicy::update(i(),state());
76 safe_data_iterator sp (data(),pos.raw());
77 safe_data_iterator si (data(),i());
79 data().insert(sp,senf::init_bytes<value_type>::value,0);
80 value_type(sp,state()).init();
81 ListPolicy::insert(si,state(),sp);
85 template <class ListPolicy>
86 template <class Value>
87 prefix_ void senf::Parse_List_Container<ListPolicy>::insert(iterator pos,
91 ListPolicy::update(i(),state());
92 safe_data_iterator sp (data(),pos.raw());
93 safe_data_iterator si (data(),i());
95 data().insert(sp,senf::init_bytes<value_type>::value,0);
96 value_type(sp,state()).init();
97 value_type(sp,state()) << t;
98 ListPolicy::insert(si,state(),sp);
103 template <class ListPolicy>
104 template <class ForwardIterator>
105 prefix_ void senf::Parse_List_Container<ListPolicy>::
106 insert(iterator pos, ForwardIterator f, ForwardIterator l,
107 typename boost::disable_if< boost::is_convertible<ForwardIterator,size_type> >::type *)
109 ListPolicy::update(i(),state());
110 safe_data_iterator sp (data(),pos.raw());
111 safe_data_iterator si (data(),i());
113 data().insert(sp,senf::init_bytes<value_type>::value,0);
114 value_type(sp,state()).init();
115 value_type(sp,state()) << *f;
116 ListPolicy::insert(si,state(),sp);
117 sp += senf::bytes(value_type(sp,state()));
121 template <class ListPolicy>
122 template <class ForwardIterator>
123 prefix_ void senf::Parse_List_Container<ListPolicy>::
124 insert(iterator pos, ForwardIterator f, ForwardIterator l)
128 template <class ListPolicy>
129 prefix_ void senf::Parse_List_Container<ListPolicy>::erase(iterator pos,
132 ListPolicy::update(i(),state());
133 safe_data_iterator si (data(),i());
134 safe_data_iterator sp (data(),pos.raw());
136 ListPolicy::erase(si,state(),sp);
137 data().erase(sp,boost::next(sp,senf::bytes(value_type(sp,state()))));
141 template <class ListPolicy>
142 prefix_ void senf::Parse_List_Container<ListPolicy>::clear()
144 size_type sz (bytes());
145 if (sz > ListPolicy::init_bytes)
146 data().erase(boost::next(i(),ListPolicy::init_bytes),boost::next(i(),sz));
148 data().insert(boost::next(i(),sz), ListPolicy::init_bytes-sz, 0u);
149 std::fill(i(),boost::next(i(),ListPolicy::init_bytes), 0u);
150 ListPolicy::init(i(),state());
153 template <class ListPolicy>
154 prefix_ void senf::Parse_List_Container<ListPolicy>::resize(size_type n)
156 size_type sz (size());
158 erase(boost::next(begin(),n),end());
160 push_back_space(n-sz);
163 template <class ListPolicy>
164 template <class Value>
165 prefix_ void senf::Parse_List_Container<ListPolicy>::resize(size_type n,
168 size_type sz (size());
170 erase(boost::next(begin(),n),end());
172 push_back(value,n-sz);
175 ///////////////////////////////ct.e////////////////////////////////////////
182 // comment-column: 40
183 // c-file-style: "senf"
184 // indent-tabs-mode: nil
185 // ispell-local-dictionary: "american"
186 // compile-command: "scons -u test"