Merged revisions 262,264-265,267-282,284-298,300-311 via svnmerge from
[senf.git] / Packets / ParseListB.hh
1 // Copyright (C) 2007 
2 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
3 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
4 //     Stefan Bund <g0dil@berlios.de>
5 //
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.
10 //
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.
15 //
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.
20
21 /** \file
22     \brief ParseListB public header */
23
24 #ifndef HH_ParseListB_
25 #define HH_ParseListB_ 1
26
27 // Custom includes
28 #include "ParseList.hh"
29
30 //#include "ParseListB.mpp"
31 ///////////////////////////////hh.p////////////////////////////////////////
32
33 namespace senf {
34     
35     namespace detail { template <class ElementParser, class BytesParser>
36                        class Parse_ListB_Policy; }
37
38     /** \brief List parser with size-field in bytes
39
40         This list parser will parse a list which size is given by a preceding field containing the
41         lenght of the list in bytes. This struct is just a template typedef:
42         \code
43           typedef senf::Parse_VectorN< Parser_UInt32, Parser_UInt16 >::parser Parse_MyVector;
44           typedef senf::Parse_ListB< Parse_MyVector, Parse_UInt16 >::parser Parse_MyList;
45         \endcode
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.
48
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 wrepper either for reading or writing.
53
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.
56
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
59      */
60     template <class ElementParser, class BytesParser>
61     struct Parse_ListB {
62         typedef Parse_List< detail::Parse_ListB_Policy<ElementParser,BytesParser> > parser;
63     };
64
65 }
66
67 ///////////////////////////////hh.e////////////////////////////////////////
68 //#include "ParseListB.cci"
69 //#include "ParseListB.ct"
70 #include "ParseListB.cti"
71 #endif
72
73 \f
74 // Local Variables:
75 // mode: c++
76 // fill-column: 100
77 // comment-column: 40
78 // c-file-style: "senf"
79 // indent-tabs-mode: nil
80 // ispell-local-dictionary: "american"
81 // compile-command: "scons -u test"
82 // End: