2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 // Stefan Bund <g0dil@berlios.de>
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the
18 // Free Software Foundation, Inc.,
19 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 \brief ParseListB public header */
24 #ifndef HH_ParseListB_
25 #define HH_ParseListB_ 1
28 #include "ParseList.hh"
30 //#include "ParseListB.mpp"
31 ///////////////////////////////hh.p////////////////////////////////////////
35 namespace detail { template <class ElementParser, class BytesParser>
36 class Parse_ListB_Policy; }
38 /** \brief List parser with size-field in bytes
40 This list parser will parse a list which size is given by a preceding field containing the
41 length of the list in bytes. This struct is just a template typedef:
43 typedef senf::Parse_VectorN< Parser_UInt32, Parser_UInt16 >::parser Parse_MyVector;
44 typedef senf::Parse_ListB< Parse_MyVector, Parse_UInt16 >::parser Parse_MyList;
46 This first defines a Vector of 32 bit unsigned integers with 16 bit length counter. Then it
47 defines a list of such vectors with a 16 bit bytes field.
49 \warning There are some caveats when working with this kind of list
50 \li You may <b>only change the size of a contained element from a container wrapper</b>.
51 \li While you hold a container wrapper, <b>only access the packet through this wrapper</b>
52 or a nested wrapper either for reading or writing.
54 If lists are nested, you need to allocate a container wrapper for each level and may only
55 access the packet through the lowest-level active container wrapper.
57 \implementation These restrictions are necessary to ensure correct recalculation of the
58 <tt>bytes</tt> field. For more info, see the comments in \ref ParseListB.ih
61 \ingroup parsecollection
63 template <class ElementParser, class BytesParser>
65 typedef Parse_List< detail::Parse_ListB_Policy<ElementParser,BytesParser> > parser;
68 /** \brief Define Parse_ListB field
70 This macro is a special helper to define a senf::Parse_ListB type field, a list of elements
71 of type \a elt_type (a parser type) directly preceded by a numeric size field of type \a
72 size_type (another parser type) giving the total number of bytes of the list (not the
75 \param[in] name field name
76 \param[in] elt_type list element type
77 \param[in] size_type size type
79 \ingroup packetparsermacros
81 # define SENF_PARSER_LIST_B(name, elt_type, size_type) \
82 typedef senf::Parse_ListB<elt_type, size_type>::parser BOOST_PP_CAT(name, _list_t); \
83 SENF_PARSER_FIELD( name, BOOST_PP_CAT(name, _list_t) )
87 ///////////////////////////////hh.e////////////////////////////////////////
89 #if !defined(HH_Packets__decls_) && !defined(HH_ParseListB_i_)
90 #define HH_ParseListB_i_
91 //#include "ParseListB.cci"
92 //#include "ParseListB.ct"
93 #include "ParseListB.cti"
100 // comment-column: 40
101 // c-file-style: "senf"
102 // indent-tabs-mode: nil
103 // ispell-local-dictionary: "american"
104 // compile-command: "scons -u test"