00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #ifndef HH_SENF_Packets_VectorParser_
00027 #define HH_SENF_Packets_VectorParser_ 1
00028
00029
00030 #include <boost/type_traits.hpp>
00031 #include "PacketParser.hh"
00032 #include "ArrayParser.hh"
00033 #include "AuxParser.hh"
00034
00035
00036
00037
00038 namespace senf {
00039
00040 template <class ElementParser, class AuxPolicy> class VectorParser_Container;
00041
00066 template <class ElementParser, class AuxPolicy>
00067 struct VectorParser
00068 : public PacketParserBase,
00069 private AuxPolicy
00070 {
00071 VectorParser(data_iterator i, state_type s);
00072 VectorParser(AuxPolicy policy, data_iterator i, state_type s);
00074
00077 size_type bytes() const;
00078 void init() const;
00079
00080 static const size_type init_bytes = AuxPolicy::aux_bytes;
00081
00082
00083
00084
00085 typedef ElementParser value_type;
00086 typedef detail::ArrayParser_iterator<value_type> iterator;
00087 typedef iterator const_iterator;
00088 typedef VectorParser_Container<ElementParser,AuxPolicy> container;
00089
00090 size_type size() const;
00091 bool empty() const;
00092
00093 iterator begin() const;
00094 iterator end() const;
00095
00096 value_type operator[](difference_type i) const;
00097 value_type front() const;
00098 value_type back() const;
00099
00100
00101
00102
00103
00104
00105
00106 template <class Value> void push_back (Value const & value, size_type n=1) const;
00107 value_type push_back_space (size_type n=1) const;
00108 template <class Value> void push_front (Value const & value, size_type n=1) const;
00109 value_type push_front_space (size_type n=1) const;
00110 void resize (size_type n) const;
00111 template <class Value> void resize (size_type n, Value value) const;
00112
00113 private:
00114
00115 friend class VectorParser_Container<ElementParser,AuxPolicy>;
00116 };
00117
00136 template <class ElementParser, class AuxPolicy>
00137 class VectorParser_Container
00138 : private AuxPolicy::WrapperPolicy
00139 {
00140 public:
00141
00142
00143
00144 typedef VectorParser<ElementParser,AuxPolicy> parser_type;
00145 typedef PacketParserBase::data_iterator data_iterator;
00146 typedef PacketParserBase::size_type size_type;
00147 typedef PacketParserBase::difference_type difference_type;
00148 typedef ElementParser value_type;
00149 typedef detail::ArrayParser_iterator<value_type> iterator;
00150 typedef iterator const_iterator;
00151 typedef PacketParserBase::state_type state_type;
00152
00153
00155
00156
00157
00158
00159
00160
00161
00162 VectorParser_Container(parser_type const & vector);
00163
00164
00165
00166
00168
00169
00170 size_type size() const;
00171 bool empty() const;
00172
00173 iterator begin() const;
00174 iterator end() const;
00175
00176 value_type operator[](difference_type i) const;
00177 value_type front() const;
00178 value_type back() const;
00179
00180
00182
00183
00184 iterator shift(iterator pos, size_type n=1);
00185 template <class Value>
00186 void insert(iterator pos, Value const & t);
00187 template <class Value>
00188 void insert(iterator pos, size_type n, Value const & t);
00189 # ifndef DOXYGEN
00190 template <class ForwardIterator>
00191 void insert(iterator pos, ForwardIterator f, ForwardIterator l,
00192 typename boost::disable_if< boost::is_convertible<ForwardIterator,size_type> >::type * = 0);
00193 # else
00194 template <class ForwardIterator>
00195 void insert(iterator pos, ForwardIterator f, ForwardIterator l);
00196 # endif
00197
00198 void erase(iterator pos, size_type n=1);
00199 void erase(iterator f, iterator l);
00200 void clear();
00201
00202 template <class Value> void push_back (Value const & value, size_type n=1);
00203 value_type push_back_space (size_type n=1);
00204 template <class Value> void push_front (Value const & value, size_type n=1);
00205 value_type push_front_space (size_type n=1);
00206 void resize (size_type n);
00207 template <class Value> void resize (size_type n, Value value);
00208
00209
00210
00212
00213
00214 parser_type parser() const;
00215 data_iterator i() const;
00216 state_type state() const;
00217 PacketData & data() const;
00218
00219 size_type bytes() const;
00220 void init() const;
00221
00222
00223
00224 protected:
00225
00226 private:
00227 void setSize(size_type value);
00228
00229 state_type state_;
00230 size_type i_;
00231 };
00232
00293 # define SENF_PARSER_VECTOR(name, size, elt_type) \
00294 SENF_PARSER_VECTOR_I(public, name, size, elt_type)
00295
00303 # define SENF_PARSER_PRIVATE_VECTOR(name, size, elt_type) \
00304 SENF_PARSER_VECTOR_I(protected, name, size, elt_type)
00305 }
00306
00307
00308 #endif
00309 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_VectorParser_i_)
00310 #define HH_SENF_Packets_VectorParser_i_
00311
00312 #include "VectorParser.ct"
00313 #include "VectorParser.cti"
00314 #endif
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325