4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief ListBParser public header */
26 #ifndef HH_ListBParser_
27 #define HH_ListBParser_ 1
30 #include "ListParser.hh"
32 //#include "ListBParser.mpp"
33 ///////////////////////////////hh.p////////////////////////////////////////
37 namespace detail { template <class ElementParser, class BytesParser>
38 class ListBParser_Policy; }
40 /** \brief List parser with size-field in bytes
42 This list parser will parse a list which size is given by a preceding field containing the
43 length of the list in bytes. This struct is just a template typedef:
45 typedef senf::VectorNParser< Parser_UInt32, Parser_UInt16 >::parser MyVectorParser;
46 typedef senf::ListBParser< MyVectorParser, UInt16Parser >::parser MyListParser;
48 This first defines a Vector of 32 bit unsigned integers with 16 bit length counter. Then it
49 defines a list of such vectors with a 16 bit bytes field.
51 \warning There are some caveats when working with this kind of list
52 \li You may <b>only change the size of a contained element from a container wrapper</b>.
53 \li While you hold a container wrapper, <b>only access the packet through this wrapper</b>
54 or a nested wrapper either for reading or writing.
56 If lists are nested, you need to allocate a container wrapper for each level and may only
57 access the packet through the lowest-level active container wrapper.
59 \implementation These restrictions are necessary to ensure correct recalculation of the
60 <tt>bytes</tt> field. For more info, see the comments in \ref ListBParser.ih
63 \ingroup parsecollection
65 template <class ElementParser, class BytesParser>
67 typedef ListParser< detail::ListBParser_Policy<ElementParser,BytesParser> > parser;
70 /** \brief Define ListBParser field
72 This macro is a special helper to define a senf::ListBParser type field, a list of elements
73 of type \a elt_type (a parser type) directly preceded by a numeric size field of type \a
74 size_type (another parser type) giving the total number of bytes of the list (not the
77 \param[in] name field name
78 \param[in] elt_type list element type
79 \param[in] size_type size type
81 \ingroup packetparsermacros
83 # define SENF_PARSER_LIST_B(name, elt_type, size_type) \
84 typedef senf::ListBParser<elt_type, size_type>::parser BOOST_PP_CAT(name, _list_t); \
85 SENF_PARSER_FIELD( name, BOOST_PP_CAT(name, _list_t) )
89 ///////////////////////////////hh.e////////////////////////////////////////
91 #if !defined(HH_Packets__decls_) && !defined(HH_ListBParser_i_)
92 #define HH_ListBParser_i_
93 //#include "ListBParser.cci"
94 //#include "ListBParser.ct"
95 #include "ListBParser.cti"
102 // comment-column: 40
103 // c-file-style: "senf"
104 // indent-tabs-mode: nil
105 // ispell-local-dictionary: "american"
106 // compile-command: "scons -u test"