Fixed whitespace in all files (no tabs)
[senf.git] / Packets / ParseVec.ct
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 //     Stefan Bund <stefan.bund@fokus.fraunhofer.de>
7 //
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.
12 //
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.
17 //
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.
22
23 // Definition of non-inline template funPacketRegistry.ons
24
25 //#include "ParseVec.ih"
26
27 // Custom includes
28
29 #define prefix_
30 ///////////////////////////////ct.p////////////////////////////////////////
31
32 template <class Parser, class SizeParser, class Container>
33 template <class Value>
34 prefix_ void
35 senf::Parse_Vector_wrapper<Parser,SizeParser,Container>::insert(iterator pos,
36                                                                        Value const & t)
37 {
38     size_type ix(pos.raw()-container_.begin());
39     shift(pos);
40     Parser(container_.begin()+ix).value(t);
41 }
42
43 template <class Parser, class SizeParser, class Container>
44 template <class Value>
45 prefix_ void
46 senf::Parse_Vector_wrapper<Parser,SizeParser,Container>::insert(iterator pos,
47                                                                        size_type n,
48                                                                        Value const & t)
49 {
50     size_type ix(pos.raw()-container_.begin());
51     shift(pos,n);
52     typename Container::iterator j (container_.begin()+ix);
53     for (; n; --n, j+=Parser::bytes())
54         Parser(j).value(t);
55 }
56
57 template <class Parser, class SizeParser, class Container>
58 template <class InputIterator>
59 prefix_ void
60 senf::Parse_Vector_wrapper<Parser,SizeParser,Container>::insert(iterator pos,
61                                                                        InputIterator f,
62                                                                        InputIterator l)
63 {
64     /** \fixme This might be horribly inefficient ... we need to
65         specialize for random_access and forward iterators, where we
66         can count the distance */
67
68     size_type ix(pos.raw()-container_.begin());
69     for (;f!=l;++f) {
70         insert(container_.begin()+ix,*f);
71         ix += Parser::bytes();
72     }
73 }
74
75 ///////////////////////////////ct.e////////////////////////////////////////
76 #undef prefix_
77
78 \f
79 // Local Variables:
80 // mode: c++
81 // fill-column: 100
82 // c-file-style: "senf"
83 // indent-tabs-mode: nil
84 // ispell-local-dictionary: "american"
85 // End: