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);
102 template <class ListPolicy>
103 template <class ForwardIterator>
104 prefix_ void senf::Parse_List_Container<ListPolicy>::
105 insert(iterator pos, ForwardIterator f, ForwardIterator l,
106 typename boost::disable_if< boost::is_convertible<ForwardIterator,size_type> >::type *)
108 ListPolicy::update(i(),state());
109 safe_data_iterator sp (data(),pos.raw());
110 safe_data_iterator si (data(),i());
112 data().insert(sp,senf::init_bytes<value_type>::value,0);
113 value_type(sp,state()).init();
114 value_type(sp,state()) << *f;
115 ListPolicy::insert(si,state(),sp);
116 sp += senf::bytes(value_type(sp,state()));
120 template <class ListPolicy>
121 prefix_ void senf::Parse_List_Container<ListPolicy>::erase(iterator pos,
124 ListPolicy::update(i(),state());
125 safe_data_iterator si (data(),i());
126 safe_data_iterator sp (data(),pos.raw());
128 ListPolicy::erase(si,state(),sp);
129 data().erase(sp,boost::next(sp,senf::bytes(value_type(sp,state()))));
133 template <class ListPolicy>
134 prefix_ void senf::Parse_List_Container<ListPolicy>::clear()
136 size_type sz (bytes());
137 if (sz > ListPolicy::init_bytes)
138 data().erase(boost::next(i(),ListPolicy::init_bytes),boost::next(i(),sz));
140 data().insert(boost::next(i(),sz), ListPolicy::init_bytes-sz, 0u);
141 std::fill(i(),boost::next(i(),ListPolicy::init_bytes), 0u);
142 ListPolicy::init(i(),state());
145 template <class ListPolicy>
146 prefix_ void senf::Parse_List_Container<ListPolicy>::resize(size_type n)
148 size_type sz (size());
150 erase(boost::next(begin(),n),end());
152 push_back_space(n-sz);
155 template <class ListPolicy>
156 template <class Value>
157 prefix_ void senf::Parse_List_Container<ListPolicy>::resize(size_type n,
160 size_type sz (size());
162 erase(boost::next(begin(),n),end());
164 push_back(value,n-sz);
167 ///////////////////////////////ct.e////////////////////////////////////////
174 // comment-column: 40
175 // c-file-style: "senf"
176 // indent-tabs-mode: nil
177 // ispell-local-dictionary: "american"
178 // compile-command: "scons -u test"