Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Packets / PacketParser.ih
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief PacketParser internal header */
25
26 #ifndef IH_SENF_Packets_PacketParser_
27 #define IH_SENF_Packets_PacketParser_ 1
28
29 // Custom includes
30 #include <senf/Utils/mpl.hh>
31
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33
34 namespace senf {
35 namespace detail {
36
37     // PLEASE don't add this to doxygen ... it just looks to weird and does not help ...
38
39 #   ifndef DOXYGEN
40
41     // Use SFINAE to check, if Parser has an integer-valued init_bytes member. If not,
42     // 'Parser_TakeNum<Parser::init_bytes>' fails and the overload is removed from the overload
43     // set.
44     template <class Parser>
45     PacketParserBase::size_type packetParserSize(
46         Parser p, int, senf::mpl::take_uint<Parser::init_bytes> * = 0);
47
48     // An ellipsis is always the worst match. A call 'packetParserSize(p,0) will prefer above
49     // overload if that is not disabled by SFINAE.
50     template <class Parser>
51     PacketParserBase::size_type packetParserSize(Parser p, ...);
52
53     // Same as above: This overload is only enabled, if Parser has an integer values 'init_bytes'
54     // member.
55     template <class Parser>
56     senf::mpl::rv<0> ParserInitBytes_Choose_(senf::mpl::take_uint<Parser::init_bytes> *);
57
58     template <class Parser>
59     senf::mpl::rv<1> ParserInitBytes_Choose_(...);
60
61     // This version of ParserInitBytes_Choose uses 'Parser::init_bytes' to provide 'value' (via
62     // 'boost::integral_constant')
63     template <class Parser, unsigned _>
64     struct ParserInitBytes_Choose
65         : public boost::integral_constant<PacketParserBase::size_type, Parser::init_bytes> {};
66     // ^^-- g++ error signaled here:
67     //    error: 'fixed_bytes' is not a member of 'some-class-name'
68     //
69     // The 'some-class-name' class (as given in the error message) does not seem to be a parser at
70     // all (it has neither a 'fixed_bytes' nor an 'init_bytes' member).
71     //
72     // Either 'some-class-name' is not the class you wanted to use (it really is no parser) or you
73     // left out either 'init_bytes' or 'fixed_bytes' when defining the parser. This will also
74     // happen, if you forget to call 'SENF_PARSER_FINALIZE()' when defining a composite parser.
75     //-/////////////////////////////////////////////////////////////////////////////////////////////
76
77     // If Parser::init_bytes is not defined, this specialization is chosen which instead uses
78     // 'Parser::fixed_bytes'
79     template <class Parser>
80     struct ParserInitBytes_Choose<Parser, 1>
81         : public boost::integral_constant<PacketParserBase::size_type, Parser::fixed_bytes> {};
82
83     template <class Parser>
84     struct ParserInitBytes
85         : public ParserInitBytes_Choose<Parser,SENF_MPL_RV(ParserInitBytes_Choose_<Parser>(0))> {};
86
87     template <class Parser, unsigned _>
88     struct ParserIsFixed_Choose
89         : public boost::false_type {};
90
91     template <class Parser>
92     struct ParserIsFixed_Choose<Parser, 1>
93         : public boost::true_type {};
94
95     template <class Parser>
96     struct ParserIsFixed
97         : public ParserIsFixed_Choose<Parser,SENF_MPL_RV(ParserInitBytes_Choose_<Parser>(0))> {};
98
99 #   endif
100
101 }}
102
103 //-/////////////////////////////////////////////////////////////////////////////////////////////////
104 #endif
105
106 \f
107 // Local Variables:
108 // mode: c++
109 // fill-column: 100
110 // c-file-style: "senf"
111 // indent-tabs-mode: nil
112 // ispell-local-dictionary: "american"
113 // compile-command: "scons -u test"
114 // comment-column: 40
115 // End: