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_ListParser_
00027 #define HH_SENF_Packets_ListParser_ 1
00028
00029
00030 #include <boost/utility.hpp>
00031 #include "PacketParser.hh"
00032
00033
00034
00035
00036 namespace senf {
00037
00038 namespace detail { template <class Container> class ListParser_Iterator; }
00039
00040 template <class ListPolicy>
00041 class ListParser_Container;
00042
00073 template <class ListPolicy>
00074 class ListParser
00075 : public PacketParserBase,
00076 private ListPolicy
00077 {
00078 public:
00079 typedef ListPolicy policy;
00080
00081 ListParser(data_iterator i, state_type s);
00082 ListParser(ListPolicy policy, data_iterator i, state_type s);
00084
00087 size_type bytes() const;
00088 void init() const;
00089
00090 static const size_type init_bytes = ListPolicy::init_bytes;
00091
00092
00093
00094
00095 typedef typename ListPolicy::element_type value_type;
00096 typedef typename ListPolicy::container_type container;
00097
00098 size_type size() const;
00099 bool empty() const;
00100
00101 value_type front() const;
00102 value_type back() const;
00103
00104 template <class Value> void push_back (Value const & value, size_type n=1) const;
00105 value_type push_back_space (size_type n=1) const;
00106 template <class Value> void push_front (Value const & value, size_type n=1) const;
00107 value_type push_front_space (size_type n=1) const;
00108 void resize (size_type n) const;
00109 template <class Value> void resize (size_type n, Value value) const;
00110
00111 static ListParser & get(ListPolicy & p);
00112 static ListParser const & get(ListPolicy const & p);
00113
00114 private:
00115 template <class Policy> friend class ListParser_Container;
00116 };
00117
00136 template <class ListPolicy>
00137 class ListParser_Container
00138 : private ListPolicy
00139 {
00140 public:
00141
00142
00143
00144 typedef ListPolicy policy;
00145 typedef typename ListPolicy::parser_type parser_type;
00146 typedef PacketParserBase::data_iterator data_iterator;
00147 typedef PacketParserBase::size_type size_type;
00148 typedef PacketParserBase::difference_type difference_type;
00149 typedef typename ListPolicy::element_type value_type;
00150 typedef detail::ListParser_Iterator<ListParser_Container> iterator;
00151 typedef iterator const_iterator;
00152 typedef PacketParserBase::state_type state_type;
00153
00154
00156
00157
00158
00159
00160
00161
00162
00163 ListParser_Container(parser_type const & list);
00164 ~ListParser_Container();
00165
00166
00167
00168
00170
00171
00172 size_type size() const;
00173 bool empty() const;
00174
00175 iterator begin() const;
00176 iterator end() const;
00177
00178 value_type front() const;
00179 value_type back() const;
00180
00181
00183
00184
00185
00186 value_type shift(iterator pos, size_type n=1);
00187 template <class Value>
00188 void insert(iterator pos, Value const & t);
00189 template <class Value>
00190 void insert(iterator pos, size_type n, Value const & t);
00191 template <class ForwardIterator>
00192 # ifndef DOXYGEN
00193 void insert(iterator pos, ForwardIterator f, ForwardIterator l,
00194 typename boost::disable_if< boost::is_convertible<ForwardIterator,size_type> >::type * = 0);
00195 # else
00196 void insert(iterator pos, ForwardIterator f, ForwardIterator l);
00197 # endif
00198
00199 void erase(iterator pos, size_type n=1);
00200 void erase(iterator f, iterator l);
00201 void clear();
00202
00203 template <class Value> void push_back (Value const & value, size_type n=1);
00204 value_type push_back_space (size_type n=1);
00205 template <class Value> void push_front (Value const & value, size_type n=1);
00206 value_type push_front_space (size_type n=1);
00207 void resize (size_type n);
00208 template <class Value> void resize (size_type n, Value value);
00209
00210
00211
00213
00214
00215 parser_type parser() const;
00216 data_iterator i() const;
00217 state_type state() const;
00218 PacketData & data() const;
00219
00220 size_type bytes() const;
00221 void init() const;
00222
00223
00224
00225 private:
00226 friend class detail::ListParser_Iterator<ListParser_Container>;
00227
00228 state_type state_;
00229 size_type i_;
00230 };
00231
00308 # define SENF_PARSER_LIST(name, size, elt_type) \
00309 SENF_PARSER_LIST_I(public, name, size, elt_type)
00310
00318 # define SENF_PARSER_PRIVATE_LIST(name, size, elt_type) \
00319 SENF_PARSER_LIST_I(protected, name, size, elt_type)
00320
00321 }
00322
00323
00324 #endif
00325 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_ListParser_i_)
00326 #define HH_SENF_Packets_ListParser_i_
00327
00328 #include "ListParser.ct"
00329 #include "ListParser.cti"
00330 #endif
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341