#ifndef SPROUT_WEED_PARSER_NUMERIC_HEX_HPP #define SPROUT_WEED_PARSER_NUMERIC_HEX_HPP #include #include #include #include #include #include #include #include namespace sprout { namespace weed { // // hex_p // template struct hex_p : public sprout::weed::parser_base { public: template struct attribute { public: typedef IntType type; }; template struct result { public: typedef sprout::weed::parser_result::type> type; }; private: template SPROUT_CONSTEXPR typename std::enable_if< N == Max, typename result::type >::type call_1(Iterator first, Iterator last, Iterator temp_first, IntType t, PResult const& res) const { typedef typename result::type result_type; typedef typename attribute::type attribute_type; return sprout::tuples::get<1>(res) ? result_type(true, sprout::next(first), static_cast(t << 4 | sprout::tuples::get<0>(res))) : N < Min ? result_type(false, temp_first, attribute_type()) : result_type(true, first, t) ; } template SPROUT_CONSTEXPR typename std::enable_if< N != Max, typename result::type >::type call_1(Iterator first, Iterator last, Iterator temp_first, IntType t, PResult const& res) const { typedef typename result::type result_type; typedef typename attribute::type attribute_type; return sprout::tuples::get<1>(res) ? call_0(sprout::next(first), last, temp_first, static_cast(t << 4 | sprout::tuples::get<0>(res))) : N < Min ? result_type(false, temp_first, attribute_type()) : result_type(true, first, t) ; } template SPROUT_CONSTEXPR typename result::type call_0(Iterator first, Iterator last, Iterator temp_first, IntType t) const { typedef typename result::type result_type; typedef typename attribute::type attribute_type; return first != last ? call_1(first, last, temp_first, t, sprout::weed::detail::from_xdigit(*first)) : N < Min ? result_type(false, temp_first, attribute_type()) : result_type(true, first, t) ; } template SPROUT_CONSTEXPR typename result::type call(Iterator first, Iterator last, Iterator temp_first, PResult const& res) const { typedef typename result::type result_type; typedef typename attribute::type attribute_type; return sprout::tuples::get<1>(res) ? call_0<1, Context>(sprout::next(first), last, temp_first, sprout::tuples::get<0>(res)) : result_type(false, temp_first, attribute_type()) ; } public: template SPROUT_CONSTEXPR typename result::type operator()(Iterator first, Iterator last, Context const&) const { typedef typename result::type result_type; typedef typename attribute::type attribute_type; return first != last ? call(first, last, first, sprout::weed::detail::from_xdigit(*first)) : result_type(false, first, attribute_type()) ; } }; // // hex8 // hex16 // hex32 // hex64 // uhex8 // uhex16 // uhex32 // uhex64 // SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p hex8 = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p hex16 = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p hex32 = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p hex64 = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p uhex8 = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p uhex16 = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p uhex32 = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p uhex64 = sprout::weed::hex_p(); // // hex8f // hex16f // hex32f // hex64f // uhex8f // uhex16f // uhex32f // uhex64f // SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p hex8f = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p hex16f = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p hex32f = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p hex64f = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p uhex8f = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p uhex16f = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p uhex32f = sprout::weed::hex_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::hex_p uhex64f = sprout::weed::hex_p(); } // namespace weed } // namespace sprout #endif // #ifndef SPROUT_WEED_PARSER_NUMERIC_HEX_HPP