4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
6 // Stefan Bund <stefan.bund@fokus.fraunhofer.de>
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.
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.
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.
24 #define HH_ParseVec_ 1
27 #include <utility> // for std::pair
28 #include <boost/iterator/iterator_facade.hpp>
29 #include <boost/utility.hpp> // for boost::noncopyable
30 #include "ParserBase.hh"
31 #include "ParseArray.hh" // for Parse_Array_iterator
33 //#include "ParseVec.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
39 template <class Parser, class SizeParser, class Container> class Parse_Vector_wrapper;
41 template <class Parser, class SizeParser, class Iterator=nil, class IPacket=nil>
42 struct Parse_Vector : public ParserBase<Iterator,IPacket>
44 typedef typename SizeParser::template rebind<Iterator>::parser size_parser;
46 ///////////////////////////////////////////////////////////////////////////
49 template <class I=nil, class P=nil>
50 struct rebind { typedef Parse_Vector<Parser,SizeParser,I,P> parser; };
51 typedef Iterator byte_iterator;
53 explicit Parse_Vector(SizeParser const & size);
54 Parse_Vector(size_parser const & size, Iterator const & i);
56 unsigned bytes() const;
57 void check(Iterator const & e) const;
60 ///////////////////////////////////////////////////////////////////////////
61 // Container interface
63 typedef typename Parser::template rebind<Iterator>::parser value_type;
64 typedef impl::Parse_Array_iterator<value_type,Iterator> iterator;
65 typedef unsigned size_type;
66 typedef int difference_type;
67 typedef std::pair<iterator,iterator> range_type;
69 template <class Container>
70 struct wrapper { typedef Parse_Vector_wrapper<value_type, size_parser, Container> t; };
72 size_type size() const;
75 iterator begin() const;
77 range_type range() const;
78 range_type value() const;
80 value_type operator[](difference_type i) const;
85 template <class P, class SP, class C> friend class Parse_Vector_wrapper;
90 Holds a reference to the container !
92 template <class Parser, class SizeParser, class Container>
93 class Parse_Vector_wrapper
94 : public boost::noncopyable
97 ///////////////////////////////////////////////////////////////////////////
100 typedef Container container;
101 typedef SizeParser size_parser;
102 typedef typename Parser::byte_iterator byte_iterator;
103 typedef Parser value_type;
104 typedef impl::Parse_Array_iterator<value_type,byte_iterator> iterator;
105 typedef unsigned size_type;
106 typedef int difference_type;
107 typedef std::pair<iterator,iterator> range_type;
109 ///////////////////////////////////////////////////////////////////////////
110 ///\name Structors and default members
113 template <class P, class SP, class I, class IP>
114 Parse_Vector_wrapper(Parse_Vector<P,SP,I,IP> const & vector, Container & container);
116 // no default constructor
118 // default destructor
119 // no conversion constructors
122 ///////////////////////////////////////////////////////////////////////////
123 ///\name APacketRegistry.essors
126 size_type size() const;
129 iterator begin() const;
130 iterator end() const;
131 range_type range() const;
133 value_type operator[](difference_type i) const;
136 ///////////////////////////////////////////////////////////////////////////
140 void shift(iterator pos, size_type n=1);
141 template <class Value>
142 void insert(iterator pos, Value const & t);
143 template <class Value>
144 void insert(iterator pos, size_type n, Value const & t);
145 template <class InputIterator>
146 void insert(iterator pos, InputIterator f, InputIterator l);
148 void erase(iterator pos, size_type n=1);
149 void erase(iterator f, iterator l);
160 Container & container_;
165 ///////////////////////////////hh.e////////////////////////////////////////
166 //#include "ParseVec.cci"
167 #include "ParseVec.ct"
168 #include "ParseVec.cti"
175 // c-file-style: "senf"
176 // indent-tabs-mode: nil
177 // ispell-local-dictionary: "american"