X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FPackets%2FVectorParser.hh;h=66c03f534490b38bbe6492ec4cc3d2c703e64ba5;hb=99c145da3884f5c20a74337927ef2cbc073d80d7;hp=12c599b25a856079c1faff99540545e13ad25397;hpb=601d1f509f5bb24df167a4dd5a20da67a0af9af8;p=senf.git diff --git a/senf/Packets/VectorParser.hh b/senf/Packets/VectorParser.hh index 12c599b..66c03f5 100644 --- a/senf/Packets/VectorParser.hh +++ b/senf/Packets/VectorParser.hh @@ -27,16 +27,13 @@ #define HH_SENF_Packets_VectorParser_ 1 // Custom includes -#include -#include -#include #include #include "PacketParser.hh" #include "ArrayParser.hh" // for ArrayParser_iterator #include "AuxParser.hh" // for the AuxPolicies //#include "VectorParser.mpp" -///////////////////////////////hh.p//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// namespace senf { @@ -47,7 +44,7 @@ namespace senf { A Vector is a collection of fixed-size elements of which the size of the collection can be determined directly (that is without traversing the collection). This allows very efficient random access to the elements of the collection. - + A vector is a model of an STL random-access sequence. The parser only provides a reduced interface, the container wrapper however completes this interface. @@ -58,7 +55,7 @@ namespace senf { Some basic vector access methods are defined as parser members. To access the complete list API however you will need to instantiate a container wrapper for the vector. See \ref packet_usage_fields_collection. - + \see \ref How to access \ref packet_usage_fields_collection \n SENF_PARSER_VECTOR() macro used to define vector fields \n @@ -67,8 +64,8 @@ namespace senf { \ingroup parsecollection */ template - struct VectorParser - : public PacketParserBase, + struct VectorParser + : public PacketParserBase, private AuxPolicy { VectorParser(data_iterator i, state_type s); @@ -82,7 +79,7 @@ namespace senf { static const size_type init_bytes = AuxPolicy::aux_bytes; - /////////////////////////////////////////////////////////////////////////// + //-//////////////////////////////////////////////////////////////////////// // Container interface typedef ElementParser value_type; @@ -101,16 +98,16 @@ namespace senf { value_type back() const; // Mutators - + // The mutators provided here are those which don't take an iterator argument. // If you need to pass an iterator it is much simpler and cleaner to use the // 'container' wrapper - - template void push_back (Value value, size_type n=1) const; - void push_back_space (size_type n=1) const; - template void push_front (Value value, size_type n=1) const; - void push_front_space (size_type n=1) const; - void resize (size_type n) const; + + template void push_back (Value const & value, size_type n=1) const; + value_type push_back_space (size_type n=1) const; + template void push_front (Value const & value, size_type n=1) const; + value_type push_front_space (size_type n=1) const; + void resize (size_type n) const; template void resize (size_type n, Value value) const; private: @@ -123,11 +120,11 @@ namespace senf { This is the container wrapper used for vector parsers. The container wrapper will stay valid after changing the collection. However the container still depends on the packet and will be invalidated if the Packet is deallocated or if the packet size is changed from without the - container wrapper (more precisely, it is invalided if the insertion/deletion happens before + container wrapper (more precisely, it is invalidated if the insertion/deletion happens before the vector in the packet data). The vector container wrapper provides a complete STL random-access sequence interface. - + \code SomePacket p (...); SomePacket::aVectorCollection_t::container c (p->aVectorCollection()); @@ -141,7 +138,7 @@ namespace senf { : private AuxPolicy::WrapperPolicy { public: - /////////////////////////////////////////////////////////////////////////// + //-//////////////////////////////////////////////////////////////////////// // Types typedef VectorParser parser_type; @@ -153,9 +150,9 @@ namespace senf { typedef iterator const_iterator; typedef PacketParserBase::state_type state_type; - /////////////////////////////////////////////////////////////////////////// + //-//////////////////////////////////////////////////////////////////////// ///\name Structors and default members - ///@{ + //\{ // no default constructor // default copy @@ -164,11 +161,11 @@ namespace senf { VectorParser_Container(parser_type const & vector); - ///@} - /////////////////////////////////////////////////////////////////////////// + //\} + //-//////////////////////////////////////////////////////////////////////// ///\name Accessors - ///@{ + //\{ size_type size() const; bool empty() const; @@ -180,9 +177,9 @@ namespace senf { value_type front() const; value_type back() const; - ///@} + //\} ///\name Mutators - ///@{ + //\{ iterator shift(iterator pos, size_type n=1); template @@ -202,17 +199,17 @@ namespace senf { void erase(iterator f, iterator l); void clear(); - template void push_back (Value value, size_type n=1); - void push_back_space (size_type n=1); - template void push_front (Value value, size_type n=1); - void push_front_space (size_type n=1); - void resize (size_type n); + template void push_back (Value const & value, size_type n=1); + value_type push_back_space (size_type n=1); + template void push_front (Value const & value, size_type n=1); + value_type push_front_space (size_type n=1); + void resize (size_type n); template void resize (size_type n, Value value); - ///@} + //\} ///\name Parser interface - ///@{ + //\{ parser_type parser() const; data_iterator i() const; @@ -221,8 +218,8 @@ namespace senf { size_type bytes() const; void init() const; - - ///@} + + //\} protected: @@ -234,7 +231,7 @@ namespace senf { }; /** \brief Define VectorParser field - + This macro is a special helper to define a senf::VectorParser type field, a vector of elements of type \a elt_type (a parser) which size is given by the \a size field. @@ -255,7 +252,7 @@ namespace senf { - + @@ -280,12 +277,12 @@ namespace senf { SENF_PARSER_VECTOR ( vec, transform(MyTransform, vec_size_), senf::UInt32Parser ); SENF_PARSER_VECTOR ( vec, packetSize(), senf::UInt32Parser ); \endcode - + \param[in] name field name \param[in] size name of field giving the vector size \param[in] elt_type vector element type - \see + \see How to use \ref packet_usage_fields_collection \n senf::VectorParser the vector parser API for vector field access senf::VectorParser_Container the vector parser container API for vector field access @@ -307,7 +304,7 @@ namespace senf { SENF_PARSER_VECTOR_I(protected, name, size, elt_type) } -///////////////////////////////hh.e//////////////////////////////////////// +//-///////////////////////////////////////////////////////////////////////////////////////////////// #endif #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_VectorParser_i_) #define HH_SENF_Packets_VectorParser_i_
\c bytes(\a size)\a size gives the size of the vector in bytes not the number of contained elements
\c packetSize()Use the size of the packet to get the vector size. The vector will occupy all space up to the end of the packet.