X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FParseHelpers.ih;h=18f58e586be5962c34e283fbd1e19baddb905ac6;hb=8f1a688cea76f2e76bfa0193dff9c1538929147e;hp=d93609743abb9b7d1e7ce2a8bccc3b73ea7ca1ec;hpb=4ee78597a1dae53669f5295cbb686c58146d2449;p=senf.git diff --git a/Packets/ParseHelpers.ih b/Packets/ParseHelpers.ih index d936097..18f58e5 100644 --- a/Packets/ParseHelpers.ih +++ b/Packets/ParseHelpers.ih @@ -26,6 +26,9 @@ # # // Custom includes # include +# include +# include +# include # include "../Utils/mpl.hh" # # ////////////////////////////////ih.p/////////////////////////////////////// @@ -436,16 +439,49 @@ # /////////////////////////////////////////////////////////////////////////// # // SENF_PARSER_COLLECTION_I # - namespace senf { namespace detail { namespace auxtag { struct none {}; } } } + namespace senf { namespace detail { namespace auxtag { + struct none {}; } } } + namespace senf { namespace detail { namespace auxtag { + struct bytes {}; } } } + namespace senf { namespace detail { namespace auxtag { + template + struct transform {}; } } } +# +# define SENF_PARSER_COLLECTION_TAG_GOBBLE__bytes(x) +# define SENF_PARSER_COLLECTION_TAG__bytes(x) senf::detail::auxtag::bytes +# define SENF_PARSER_COLLECTION_TAG_GETAUX__bytes(x) x +# +# define SENF_PARSER_COLLECTION_TAG_GOBBLE__transform(x,y) +# define SENF_PARSER_COLLECTION_TAG__transform(x,y) senf::detail::auxtag::transform +# define SENF_PARSER_COLLECTION_TAG_GETAUX__transform(x,y) y +# +# define SENF_PARSER_COLLECTION_HAS_KEYWORD(x) \ + BOOST_PP_IS_EMPTY( BOOST_PP_CAT(SENF_PARSER_COLLECTION_TAG_GOBBLE__, x) ) # # define SENF_PARSER_COLLECTION_I(access, name, aux, traits) \ + BOOST_PP_EXPAND( \ + SENF_PARSER_COLLECTION_II \ + BOOST_PP_IF( \ + SENF_PARSER_COLLECTION_HAS_KEYWORD(aux), \ + ( access, \ + name, \ + BOOST_PP_CAT(SENF_PARSER_COLLECTION_TAG_GETAUX__, aux), \ + BOOST_PP_CAT(SENF_PARSER_COLLECTION_TAG__, aux), \ + traits ), \ + ( access, \ + name, \ + aux, \ + senf::detail::auxtag::none, \ + traits ) )) +# +# define SENF_PARSER_COLLECTION_II(access, name, aux, tag, traits) \ private: \ BOOST_PP_CAT(SENF_PARSER_COLLECTION_AUXTYPE_, SENF_PARSER_TYPE)(name, aux) \ typedef BOOST_PP_CAT(SENF_PARSER_COLLECTION_AUX_I_, SENF_PARSER_TYPE)(name, aux) \ BOOST_PP_CAT(name,_aux_policy); \ typedef traits::parser< \ BOOST_PP_CAT(name,_aux_policy), \ - senf::detail::auxtag::none \ + tag \ >::type BOOST_PP_CAT(name, _collection_t); \ access: \ SENF_PARSER_FIELD_SETUP_I( name, \ @@ -484,17 +520,17 @@ SENF_PARSER_CURRENT_FIXED_OFFSET() \ - SENF_PARSER_FIXED_OFFSET(aux) > # -# define SENF_PARSER_COLLECTION_VAL_var(name,aux,access) \ - private: \ - template T BOOST_PP_CAT(name, _dispatch)(boost::true_type) const \ - { return parse( SENF_PARSER_OFFSET(name) ); } \ - template T BOOST_PP_CAT(name, _dispatch)(boost::false_type) const \ - { return parse( BOOST_PP_CAT(name, _aux_policy)(aux()), SENF_PARSER_OFFSET(name) ); } \ - BOOST_PP_CAT(name, _t) BOOST_PP_CAT(name, _)() const \ - { return BOOST_PP_CAT(name, _dispatch) ( \ - boost::integral_constant()); } \ - access: \ - BOOST_PP_CAT(name, _t) name() const \ +# define SENF_PARSER_COLLECTION_VAL_var(name,aux,access) \ + private: \ + template T BOOST_PP_CAT(name, _dispatch)(boost::true_type) const \ + { return parse( SENF_PARSER_OFFSET(name) ); } \ + template T BOOST_PP_CAT(name, _dispatch)(boost::false_type) const \ + { return parse( aux(), SENF_PARSER_OFFSET(name) ); } \ + BOOST_PP_CAT(name, _t) BOOST_PP_CAT(name, _)() const \ + { return BOOST_PP_CAT(name, _dispatch) ( \ + boost::integral_constant()); } \ + access: \ + BOOST_PP_CAT(name, _t) name() const \ { return BOOST_PP_CAT(name, _)(); } # # define SENF_PARSER_COLLECTION_VAL_fix(name,aux,access) \