X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FParseListB.hh;h=ce94153e586322bbc118089c355348f6d713805d;hb=6116cb96ea7bdcb42b7d12165a05fcbe0687226d;hp=72b5159e1297617e60e343b56607c7e605d6124a;hpb=2d6585ff852e9d282c17003ba1db0b73eb3a8500;p=senf.git diff --git a/Packets/ParseListB.hh b/Packets/ParseListB.hh index 72b5159..ce94153 100644 --- a/Packets/ParseListB.hh +++ b/Packets/ParseListB.hh @@ -1,3 +1,5 @@ +// $Id$ +// // Copyright (C) 2007 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) // Kompetenzzentrum fuer Satelitenkommunikation (SatCom) @@ -38,10 +40,10 @@ namespace senf { /** \brief List parser with size-field in bytes This list parser will parse a list which size is given by a preceding field containing the - lenght of the list in bytes. This struct is just a template typedef: + length of the list in bytes. This struct is just a template typedef: \code - typedef senf::Parse_VectorN< Parser_UInt32, Parser_UInt16 >::parser Parse_MyVector; - typedef senf::Parse_ListB< Parse_MyVector, Parse_UInt16 >::parser Parse_MyList; + typedef senf::Parse_VectorN< Parser_UInt32, Parser_UInt16 >::parser Parse_MyVector; + typedef senf::Parse_ListB< Parse_MyVector, Parse_UInt16 >::parser Parse_MyList; \endcode This first defines a Vector of 32 bit unsigned integers with 16 bit length counter. Then it defines a list of such vectors with a 16 bit bytes field. @@ -49,24 +51,44 @@ namespace senf { \warning There are some caveats when working with this kind of list \li You may only change the size of a contained element from a container wrapper. \li While you hold a container wrapper, only access the packet through this wrapper - or a nested wrepper either for reading or writing. + or a nested wrapper either for reading or writing. If lists are nested, you need to allocate a container wrapper for each level and may only access the packet through the lowest-level active container wrapper. \implementation These restrictions are necessary to ensure correct recalculation of the bytes field. For more info, see the comments in \ref ParseListB.ih + + \see Parse_List + \ingroup parsecollection */ template struct Parse_ListB { typedef Parse_List< detail::Parse_ListB_Policy > parser; }; + /** \brief Define Parse_ListB field + + This macro is a special helper to define a senf::Parse_ListB type field, a list of elements + of type \a elt_type (a parser type) directly preceded by a numeric size field of type \a + size_type (another parser type) giving the total number of bytes of the list (not the + element count). + + \param[in] name field name + \param[in] elt_type list element type + \param[in] size_type size type + \hideinitializer + \ingroup packetparsermacros + */ +# define SENF_PARSER_LIST_B(name, elt_type, size_type) \ + typedef senf::Parse_ListB::parser BOOST_PP_CAT(name, _list_t); \ + SENF_PARSER_FIELD( name, BOOST_PP_CAT(name, _list_t) ) + } ///////////////////////////////hh.e//////////////////////////////////////// #endif -#if !defined(SENF_PACKETS_DECL_ONLY) && !defined(HH_ParseListB_i_) +#if !defined(HH_Packets__decls_) && !defined(HH_ParseListB_i_) #define HH_ParseListB_i_ //#include "ParseListB.cci" //#include "ParseListB.ct"