00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #ifndef HH_SENF_Packets_VariantParser_
00027 #define HH_SENF_Packets_VariantParser_ 1
00028
00029 #ifndef HH_SENF_Packets_Packets_
00030 #error "Don't include 'VariantParser.hh' directly, include 'Packets.hh'"
00031 #endif
00032
00033
00034 #include <boost/mpl/vector.hpp>
00035 #include <boost/mpl/at.hpp>
00036 #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
00037 #include <boost/preprocessor/repetition/enum_params.hpp>
00038 #include <boost/preprocessor/seq/for_each.hpp>
00039 #include "PacketParser.hh"
00040
00041
00042
00043
00044 namespace senf {
00045
00046 # ifndef SENF_LIMIT_PARSE_VARIANT
00047
00051 # define SENF_LIMIT_PARSE_VARIANT 6
00052 # endif
00053
00079 template <class AuxPolicy, class Parsers>
00080 class VariantParser
00081 : public PacketParserBase, private AuxPolicy
00082 {
00083 typedef Parsers parsers;
00084
00085 public:
00087
00088
00089 VariantParser(data_iterator i, state_type s);
00090 VariantParser(AuxPolicy policy, data_iterator i, state_type s);
00091
00092 size_type bytes() const;
00093 void init();
00094
00095 static const size_type init_bytes = senf::init_bytes<
00096 typename boost::mpl::at<parsers, boost::mpl::int_<0> >::type>::value
00097 + AuxPolicy::aux_bytes;
00098
00099
00100
00101
00102 unsigned variant() const;
00103
00109 template <unsigned N>
00110 typename boost::mpl::at< parsers, boost::mpl::int_<N> >::type get() const;
00112
00118 template <unsigned N>
00119 void init();
00120
00124 };
00125
00245 # define SENF_PARSER_VARIANT(name, chooser, types) \
00246 SENF_PARSER_VARIANT_I(public, name, chooser, types)
00247
00254 # define SENF_PARSER_PRIVATE_VARIANT(name, chooser, types) \
00255 SENF_PARSER_VARIANT_I(protected, name, chooser, types)
00256 }
00257
00258
00259 #endif
00260 #if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_VariantParser_i_)
00261 #define HH_SENF_Packets_VariantParser_i_
00262
00263 #include "VariantParser.ct"
00264 #include "VariantParser.cti"
00265 #endif
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276