X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FParseHelpers.ih;h=6392b693ef5ed87f5022850d016f2d4cbd29606b;hb=08bba1cbe020e940671a58c0db5afce75ef84619;hp=d93609743abb9b7d1e7ce2a8bccc3b73ea7ca1ec;hpb=4ee78597a1dae53669f5295cbb686c58146d2449;p=senf.git diff --git a/Packets/ParseHelpers.ih b/Packets/ParseHelpers.ih index d936097..6392b69 100644 --- a/Packets/ParseHelpers.ih +++ b/Packets/ParseHelpers.ih @@ -26,6 +26,10 @@ # # // Custom includes # include +# include +# include +# include +# include # include "../Utils/mpl.hh" # # ////////////////////////////////ih.p/////////////////////////////////////// @@ -146,10 +150,12 @@ size_type BOOST_PP_CAT(name,_offset)() const { \ return field_offset_(static_cast*>(0)); \ } \ - static size_type const BOOST_PP_CAT(name, _init_bytes) = SENF_MPL_SLOT_GET(init_bytes); + static size_type const BOOST_PP_CAT(name, _init_bytes) = \ + SENF_MPL_SLOT_GET(init_bytes); # # define SENF_PARSER_I_FIELD_OFS_fix(name, type, access) \ - static size_type const BOOST_PP_CAT(name, _offset) = SENF_MPL_SLOT_GET(offset); + static size_type const BOOST_PP_CAT(name, _offset) = \ + SENF_MPL_SLOT_GET(offset); # # //////////////////////////////////////// # // SENF_PARSER_I_ADVANCE_OFS_* @@ -283,12 +289,12 @@ return field_offset_(static_cast*>(0)) \ - SENF_MPL_SLOT_GET(bitfield_size); \ } \ - static size_type const BOOST_PP_CAT(name, _init_bytes) = SENF_MPL_SLOT_GET(init_bytes) \ - - SENF_MPL_SLOT_GET(bitfield_size); + static size_type const BOOST_PP_CAT(name, _init_bytes) = \ + SENF_MPL_SLOT_GET(init_bytes) - SENF_MPL_SLOT_GET(bitfield_size); # # define SENF_PARSER_I_BITFIELD_OFS_fix(name, type, access) \ - static size_type const BOOST_PP_CAT(name, _offset) = SENF_MPL_SLOT_GET(offset) \ - - SENF_MPL_SLOT_GET(bitfield_size); + static size_type const BOOST_PP_CAT(name, _offset) = \ + SENF_MPL_SLOT_GET(offset) - SENF_MPL_SLOT_GET(bitfield_size); # # //////////////////////////////////////// # // SENF_PARSER_I_BITFIELD_RESET @@ -323,7 +329,9 @@ # define SENF_PARSER_SKIP_BITS_fix(bits) SENF_PARSER_I_SKIP_BITS(bits, fix) # # define SENF_PARSER_I_SKIP_BITS(bits, ofstype) \ - SENF_MPL_SLOT_SET(bit, SENF_MPL_SLOT_GET(bit) + bits) + private: \ + SENF_MPL_SLOT_SET(bit, SENF_MPL_SLOT_GET(bit) + bits); \ + public: # # /////////////////////////////////////////////////////////////////////////// # // SENF_PARSER_GOTO_* @@ -436,16 +444,87 @@ # /////////////////////////////////////////////////////////////////////////// # // SENF_PARSER_COLLECTION_I # - namespace senf { namespace detail { namespace auxtag { struct none {}; } } } +# ifndef DOXYGEN +# + 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 {}; } } } # +# endif +# +# define SENF_PARSER_COLLECTION_TAG_GOBBLE__bytes(x) +# define SENF_PARSER_COLLECTION_TAG__bytes(x) bytes() +# define SENF_PARSER_COLLECTION_TAG_EXPAND__bytes() senf::detail::auxtag::bytes +# define SENF_PARSER_COLLECTION_TAG_GETAUX__bytes(x) x +# +# // No recursive call so we need some more of theese ... ARGH !!! +# define SENF_CAT_RECURS1(a, b) SENF_CAT_RECURS1_I(a,b) +# define SENF_CAT_RECURS1_I(a, b) a ## b +# define SENF_CAT_RECURS2(a, b) SENF_CAT_RECURS2_I(a,b) +# define SENF_CAT_RECURS2_I(a, b) a ## b +# define SENF_CAT_RECURS3(a, b) SENF_CAT_RECURS3_I(a,b) +# define SENF_CAT_RECURS3_I(a, b) a ## b +# +# define SENF_PARSER_COLLECTION_TAG_GOBBLE__transform(x,y) +# define SENF_PARSER_COLLECTION_TAG__transform(x,y) \ + transform(x, SENF_PARSER_COLLECTION_TAG_RECURS1(y)) +# define SENF_PARSER_COLLECTION_TAG_EXPAND__transform(x,y) \ + senf::detail::auxtag::transform< \ + x, \ + SENF_CAT_RECURS1(SENF_PARSER_COLLECTION_TAG_EXPAND__, y)> +# define SENF_PARSER_COLLECTION_TAG_GETAUX__transform(x,y) \ + SENF_PARSER_COLLECTION_TAG_GETAUX_RECURS1(y) +# +# define SENF_PARSER_COLLECTION_TAG_EXPAND__none() senf::detail::auxtag::none +# +# define SENF_PARSER_COLLECTION_TAG_RECURS1(aux) \ + BOOST_PP_IF( \ + SENF_PARSER_COLLECTION_HAS_KEYWORD(aux), \ + BOOST_PP_CAT(SENF_PARSER_COLLECTION_TAG__, aux), \ + none() ) +# +# define SENF_PARSER_COLLECTION_TAG_GETAUX_RECURS1(aux) \ + BOOST_PP_IF( \ + SENF_PARSER_COLLECTION_HAS_KEYWORD(aux), \ + BOOST_PP_CAT(SENF_PARSER_COLLECTION_TAG_GETAUX__, aux), \ + aux) +# +# define SENF_PARSER_COLLECTION_HAS_KEYWORD(x) \ + BOOST_PP_IS_EMPTY( SENF_CAT_RECURS1(SENF_PARSER_COLLECTION_TAG_GOBBLE__, x) ) +# +# define SENF_PARSER_COLLECTION_GETAUX(aux) \ + BOOST_PP_IF( SENF_PARSER_COLLECTION_HAS_KEYWORD(aux), \ + SENF_CAT_RECURS2(SENF_PARSER_COLLECTION_TAG_GETAUX__, aux), \ + aux ) + # 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, \ + SENF_CAT_RECURS2(SENF_PARSER_COLLECTION_TAG_GETAUX__, aux), \ + SENF_CAT_RECURS2(SENF_PARSER_COLLECTION_TAG__, aux), \ + traits ), \ + ( access, \ + name, \ + aux, \ + 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 \ + BOOST_PP_CAT(SENF_PARSER_COLLECTION_TAG_EXPAND__, tag) \ >::type BOOST_PP_CAT(name, _collection_t); \ access: \ SENF_PARSER_FIELD_SETUP_I( name, \ @@ -462,17 +541,21 @@ # # define SENF_PARSER_COLLECTION_AUXTYPE_fix(name, aux) # +# ifndef DOXYGEN +# namespace senf { namespace detail { template struct DynamicAuxParserPolicy; template struct FixedAuxParserPolicy; template - struct ParserAuxPolicySelect + struct ParserAuxPolicySelect { typedef senf::detail::DynamicAuxParserPolicy type; }; template - struct ParserAuxPolicySelect + struct ParserAuxPolicySelect { typedef senf::detail::FixedAuxParserPolicy type; }; }}; # +# endif +# # define SENF_PARSER_COLLECTION_AUX_I_var(name, aux) \ senf::detail::ParserAuxPolicySelect< BOOST_PP_CAT(aux, _t), \ SENF_PARSER_CURRENT_FIXED_OFFSET() \ @@ -484,17 +567,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( BOOST_PP_CAT(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) \