Utils/Logger: Complete unit testing
[senf.git] / Packets / ParseListN.hh
1
2 // Copyright (C) 2007 
3 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
4 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
5 //     Stefan Bund <g0dil@berlios.de>
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the
19 // Free Software Foundation, Inc.,
20 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
22 /** \file
23     \brief ParseListN public header */
24
25 #ifndef HH_ParseListN_
26 #define HH_ParseListN_ 1
27
28 // Custom includes
29 #include "ParseList.hh"
30
31 //#include "ParseListN.mpp"
32 ///////////////////////////////hh.p////////////////////////////////////////
33
34 namespace senf {
35
36     namespace detail { template <class ElementParser, class SizeParser>
37                        class Parse_ListN_Policy; }
38
39     /** \brief List parser with size-field giving number of list elements
40
41         This parser will parse a list which size is giving by a preceding field containing the
42         number of list elements. This struct is just a 'template typedef':
43         \code
44         senf::Parse_VectorN< Parser_UInt32, Parser_UInt16 >::parser Parse_MyVector;
45         senf::Parse_ListN< Parse_MyVector, Parse_UInt16 >::parser Parse_MyList;
46         \endcode
47         This first defines a Vector of 32 bit unsigned integers with 16 bit length counter. Then it
48         defines a list of such vectors with a 16 bit size field.
49
50         \see Parse_List
51         \ingroup parsecollection
52      */
53     template <class ElementParser, class SizeParser>
54     struct Parse_ListN {
55         typedef Parse_List< detail::Parse_ListN_Policy<ElementParser,SizeParser> > parser;
56     };
57
58     /** \brief Define Parse_ListN field
59
60         This macro is a special helper to define a senf::Parse_ListN type field, a list of elements
61         of type \a elt_type (a parser type) directly preceded by a numeric size field of type \a
62         size_type (another parser type).
63
64         \param[in] name field name
65         \param[in] elt_type list element type
66         \param[in] size_type size type
67         \hideinitializer
68         \ingroup packetparsermacros
69      */
70 #    define SENF_PARSER_LIST_N(name, elt_type, size_type)                                         \
71         typedef senf::Parse_ListN<elt_type, size_type>::parser BOOST_PP_CAT(name, _list_t);       \
72         SENF_PARSER_FIELD( name, BOOST_PP_CAT(name, _list_t) )
73
74 }
75
76 ///////////////////////////////hh.e////////////////////////////////////////
77 #endif
78 #if !defined(HH_Packets__decls_) && !defined(HH_ParseListN_i_)
79 #define HH_ParseListN_i_
80 //#include "ParseListN.cci"
81 #include "ParseListN.ct"
82 #include "ParseListN.cti"
83 #endif
84
85 \f
86 // Local Variables:
87 // mode: c++
88 // fill-column: 100
89 // comment-column: 40
90 // c-file-style: "senf"
91 // indent-tabs-mode: nil
92 // ispell-local-dictionary: "american"
93 // compile-command: "scons -u test"
94 // End: