X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Packets%2FParseHelpers.ih;h=f279f35bbc854d4e9eb279daaeec1e76797099da;hb=fb2fe88ee9a9d2a777ecaf3327d04b60479fcc8d;hp=a1c80bc3b3ea728661eae54fbac0a2be3a3df4dc;hpb=166490fa7396b56c717ab4efea4551b8c5581ef9;p=senf.git diff --git a/Packets/ParseHelpers.ih b/Packets/ParseHelpers.ih index a1c80bc..f279f35 100644 --- a/Packets/ParseHelpers.ih +++ b/Packets/ParseHelpers.ih @@ -147,13 +147,19 @@ # // SENF_PARSER_I_FIELD_OFS_* # # define SENF_PARSER_I_FIELD_OFS_var(name, type, access) \ + protected: \ 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); \ + private: # # define SENF_PARSER_I_FIELD_OFS_fix(name, type, access) \ - static size_type const BOOST_PP_CAT(name, _offset) = SENF_MPL_SLOT_GET(offset); + protected: \ + static size_type const BOOST_PP_CAT(name, _offset) = \ + SENF_MPL_SLOT_GET(offset); \ + private: # # //////////////////////////////////////// # // SENF_PARSER_I_ADVANCE_OFS_* @@ -178,7 +184,9 @@ return BOOST_PP_CAT(name, _next_offset)(); \ } \ SENF_MPL_SLOT_SET(init_bytes, BOOST_PP_CAT(name,_next_init_bytes)); \ + protected: \ static size_type const BOOST_PP_CAT(name, _group) = SENF_MPL_SLOT_GET(group) + isvar; \ + private: \ SENF_MPL_SLOT_SET(group, BOOST_PP_CAT(name, _group)); \ access: # @@ -193,7 +201,7 @@ # // SENF_PARSER_I_FIELD_VAL_* # # define SENF_PARSER_I_FIELD_VAL_rw(name, type, access) \ - private: \ + protected: \ BOOST_PP_CAT(name, _t) BOOST_PP_CAT(name, _)() const { \ return parse( SENF_PARSER_OFFSET(name) ); \ } \ @@ -203,7 +211,7 @@ } # # define SENF_PARSER_I_FIELD_VAL_ro(name, type, access) \ - private: \ + protected: \ BOOST_PP_CAT(name, _t) BOOST_PP_CAT(name, _)() const { \ return parse( SENF_PARSER_OFFSET(name) ); \ } \ @@ -287,12 +295,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 @@ -327,7 +335,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_* @@ -440,14 +450,18 @@ # /////////////////////////////////////////////////////////////////////////// # // SENF_PARSER_COLLECTION_I # - namespace senf { namespace detail { namespace auxtag { +# ifndef DOXYGEN +# + namespace senf { namespace detail { namespace auxtag { struct none {}; } } } - namespace senf { namespace detail { namespace auxtag { + namespace senf { namespace detail { namespace auxtag { struct bytes {}; } } } - namespace senf { namespace detail { namespace auxtag { - template + 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 @@ -458,6 +472,8 @@ # 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) \ @@ -486,6 +502,11 @@ # 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 \ @@ -526,17 +547,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() \ @@ -553,7 +578,7 @@ 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) ); } \ + { 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()); } \