From ad94c0b247ebc4a5bd35b56652b5f35a16b781b0 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Mon, 14 Nov 2011 13:22:04 +0900 Subject: [PATCH] =?UTF-8?q?sprout/weed/parser/numeric/*=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sprout/weed/detail/bdigits.hpp | 88 +++++++++++++++ sprout/weed/detail/digits.hpp | 88 +++++++++++++++ sprout/weed/detail/ndigits.hpp | 52 +++++++++ sprout/weed/detail/odigits.hpp | 88 +++++++++++++++ sprout/weed/detail/xdigits.hpp | 2 + sprout/weed/parser/numeric.hpp | 4 + sprout/weed/parser/numeric/bin.hpp | 40 +++++++ sprout/weed/parser/numeric/hex.hpp | 122 +++----------------- sprout/weed/parser/numeric/oct.hpp | 40 +++++++ sprout/weed/parser/numeric/uint.hpp | 29 +++++ sprout/weed/parser/numeric/uint_p.hpp | 157 ++++++++++++++++++++++++++ 11 files changed, 603 insertions(+), 107 deletions(-) create mode 100644 sprout/weed/detail/bdigits.hpp create mode 100644 sprout/weed/detail/digits.hpp create mode 100644 sprout/weed/detail/ndigits.hpp create mode 100644 sprout/weed/detail/odigits.hpp create mode 100644 sprout/weed/parser/numeric/bin.hpp create mode 100644 sprout/weed/parser/numeric/oct.hpp create mode 100644 sprout/weed/parser/numeric/uint.hpp create mode 100644 sprout/weed/parser/numeric/uint_p.hpp diff --git a/sprout/weed/detail/bdigits.hpp b/sprout/weed/detail/bdigits.hpp new file mode 100644 index 00000000..71c1b0d7 --- /dev/null +++ b/sprout/weed/detail/bdigits.hpp @@ -0,0 +1,88 @@ +#ifndef SPROUT_WEED_DETAIL_BDIGITS_HPP +#define SPROUT_WEED_DETAIL_BDIGITS_HPP + +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace weed { + namespace detail { + template + struct bdigits; + + template<> + struct bdigits { + public: + SPROUT_STATIC_CONSTEXPR sprout::basic_string table = sprout::to_string("01"); + }; + SPROUT_CONSTEXPR sprout::basic_string sprout::weed::detail::bdigits::table; + + template<> + struct bdigits { + public: + SPROUT_STATIC_CONSTEXPR sprout::basic_string table = sprout::to_string(L"01"); + }; + SPROUT_CONSTEXPR sprout::basic_string sprout::weed::detail::bdigits::table; + + template<> + struct bdigits { + public: + SPROUT_STATIC_CONSTEXPR sprout::basic_string table = sprout::to_string(u"01"); + }; + SPROUT_CONSTEXPR sprout::basic_string sprout::weed::detail::bdigits::table; + + template<> + struct bdigits { + public: + SPROUT_STATIC_CONSTEXPR sprout::basic_string table = sprout::to_string(U"01"); + }; + SPROUT_CONSTEXPR sprout::basic_string sprout::weed::detail::bdigits::table; + + template + struct bvalues; + + template<> + struct bvalues { + public: + SPROUT_STATIC_CONSTEXPR sprout::array table = sprout::array{ + {0, 1} + }; + }; + SPROUT_CONSTEXPR sprout::array sprout::weed::detail::bvalues::table; + + template + SPROUT_CONSTEXPR sprout::tuples::tuple bvalue_at(std::size_t i) { + return i < 2 + ? sprout::tuples::tuple( + static_cast(sprout::weed::detail::bvalues::table[i]), + true + ) + : sprout::tuples::tuple( + IntType(), + false + ) + ; + } + template + SPROUT_CONSTEXPR sprout::tuples::tuple from_bdigit(Elem c) { + return sprout::weed::detail::bvalue_at( + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance( + sprout::weed::detail::bdigits::table.begin(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::find( + sprout::weed::detail::bdigits::table.begin(), + sprout::weed::detail::bdigits::table.end(), + c + ) + ) + ); + } + } // namespace detail + } // namespace weed +} // namespace sprout + +#endif // #ifndef SPROUT_WEED_DETAIL_BDIGITS_HPP diff --git a/sprout/weed/detail/digits.hpp b/sprout/weed/detail/digits.hpp new file mode 100644 index 00000000..adaea7c5 --- /dev/null +++ b/sprout/weed/detail/digits.hpp @@ -0,0 +1,88 @@ +#ifndef SPROUT_WEED_DETAIL_DIGITS_HPP +#define SPROUT_WEED_DETAIL_DIGITS_HPP + +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace weed { + namespace detail { + template + struct digits; + + template<> + struct digits { + public: + SPROUT_STATIC_CONSTEXPR sprout::basic_string table = sprout::to_string("0123456789"); + }; + SPROUT_CONSTEXPR sprout::basic_string sprout::weed::detail::digits::table; + + template<> + struct digits { + public: + SPROUT_STATIC_CONSTEXPR sprout::basic_string table = sprout::to_string(L"0123456789"); + }; + SPROUT_CONSTEXPR sprout::basic_string sprout::weed::detail::digits::table; + + template<> + struct digits { + public: + SPROUT_STATIC_CONSTEXPR sprout::basic_string table = sprout::to_string(u"0123456789"); + }; + SPROUT_CONSTEXPR sprout::basic_string sprout::weed::detail::digits::table; + + template<> + struct digits { + public: + SPROUT_STATIC_CONSTEXPR sprout::basic_string table = sprout::to_string(U"0123456789"); + }; + SPROUT_CONSTEXPR sprout::basic_string sprout::weed::detail::digits::table; + + template + struct values; + + template<> + struct values { + public: + SPROUT_STATIC_CONSTEXPR sprout::array table = sprout::array{ + {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} + }; + }; + SPROUT_CONSTEXPR sprout::array sprout::weed::detail::values::table; + + template + SPROUT_CONSTEXPR sprout::tuples::tuple value_at(std::size_t i) { + return i < 10 + ? sprout::tuples::tuple( + static_cast(sprout::weed::detail::values::table[i]), + true + ) + : sprout::tuples::tuple( + IntType(), + false + ) + ; + } + template + SPROUT_CONSTEXPR sprout::tuples::tuple from_digit(Elem c) { + return sprout::weed::detail::value_at( + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance( + sprout::weed::detail::digits::table.begin(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::find( + sprout::weed::detail::digits::table.begin(), + sprout::weed::detail::digits::table.end(), + c + ) + ) + ); + } + } // namespace detail + } // namespace weed +} // namespace sprout + +#endif // #ifndef SPROUT_WEED_DETAIL_DIGITS_HPP diff --git a/sprout/weed/detail/ndigits.hpp b/sprout/weed/detail/ndigits.hpp new file mode 100644 index 00000000..430fe59a --- /dev/null +++ b/sprout/weed/detail/ndigits.hpp @@ -0,0 +1,52 @@ +#ifndef SPROUT_WEED_DETAIL_NDIGITS_HPP +#define SPROUT_WEED_DETAIL_NDIGITS_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace weed { + namespace detail { + template + SPROUT_CONSTEXPR sprout::tuples::tuple from_ndigit( + Elem c, + typename std::enable_if::type* = 0 + ) + { + return sprout::weed::detail::from_digit(c); + } + template + SPROUT_CONSTEXPR sprout::tuples::tuple from_ndigit( + Elem c, + typename std::enable_if::type* = 0 + ) + { + return sprout::weed::detail::from_bdigit(c); + } + template + SPROUT_CONSTEXPR sprout::tuples::tuple from_ndigit( + Elem c, + typename std::enable_if::type* = 0 + ) + { + return sprout::weed::detail::from_odigit(c); + } + template + SPROUT_CONSTEXPR sprout::tuples::tuple from_ndigit( + Elem c, + typename std::enable_if::type* = 0 + ) + { + return sprout::weed::detail::from_xdigit(c); + } + } // namespace detail + } // namespace weed +} // namespace sprout + +#endif // #ifndef SPROUT_WEED_DETAIL_NDIGITS_HPP diff --git a/sprout/weed/detail/odigits.hpp b/sprout/weed/detail/odigits.hpp new file mode 100644 index 00000000..ea692df0 --- /dev/null +++ b/sprout/weed/detail/odigits.hpp @@ -0,0 +1,88 @@ +#ifndef SPROUT_WEED_DETAIL_ODIGITS_HPP +#define SPROUT_WEED_DETAIL_ODIGITS_HPP + +#include +#include +#include +#include +#include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL + +namespace sprout { + namespace weed { + namespace detail { + template + struct odigits; + + template<> + struct odigits { + public: + SPROUT_STATIC_CONSTEXPR sprout::basic_string table = sprout::to_string("01234567"); + }; + SPROUT_CONSTEXPR sprout::basic_string sprout::weed::detail::odigits::table; + + template<> + struct odigits { + public: + SPROUT_STATIC_CONSTEXPR sprout::basic_string table = sprout::to_string(L"01234567"); + }; + SPROUT_CONSTEXPR sprout::basic_string sprout::weed::detail::odigits::table; + + template<> + struct odigits { + public: + SPROUT_STATIC_CONSTEXPR sprout::basic_string table = sprout::to_string(u"01234567"); + }; + SPROUT_CONSTEXPR sprout::basic_string sprout::weed::detail::odigits::table; + + template<> + struct odigits { + public: + SPROUT_STATIC_CONSTEXPR sprout::basic_string table = sprout::to_string(U"01234567"); + }; + SPROUT_CONSTEXPR sprout::basic_string sprout::weed::detail::odigits::table; + + template + struct ovalues; + + template<> + struct ovalues { + public: + SPROUT_STATIC_CONSTEXPR sprout::array table = sprout::array{ + {0, 1, 2, 3, 4, 5, 6, 7} + }; + }; + SPROUT_CONSTEXPR sprout::array sprout::weed::detail::ovalues::table; + + template + SPROUT_CONSTEXPR sprout::tuples::tuple ovalue_at(std::size_t i) { + return i < 8 + ? sprout::tuples::tuple( + static_cast(sprout::weed::detail::ovalues::table[i]), + true + ) + : sprout::tuples::tuple( + IntType(), + false + ) + ; + } + template + SPROUT_CONSTEXPR sprout::tuples::tuple from_odigit(Elem c) { + return sprout::weed::detail::ovalue_at( + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::distance( + sprout::weed::detail::odigits::table.begin(), + NS_SSCRISK_CEL_OR_SPROUT_DETAIL::find( + sprout::weed::detail::odigits::table.begin(), + sprout::weed::detail::odigits::table.end(), + c + ) + ) + ); + } + } // namespace detail + } // namespace weed +} // namespace sprout + +#endif // #ifndef SPROUT_WEED_DETAIL_ODIGITS_HPP diff --git a/sprout/weed/detail/xdigits.hpp b/sprout/weed/detail/xdigits.hpp index 319c9b80..948c7f1e 100644 --- a/sprout/weed/detail/xdigits.hpp +++ b/sprout/weed/detail/xdigits.hpp @@ -6,6 +6,8 @@ #include #include #include +#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT_DETAIL +#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT_DETAIL namespace sprout { namespace weed { diff --git a/sprout/weed/parser/numeric.hpp b/sprout/weed/parser/numeric.hpp index 5ebc6083..b38c4962 100644 --- a/sprout/weed/parser/numeric.hpp +++ b/sprout/weed/parser/numeric.hpp @@ -2,6 +2,10 @@ #define SPROUT_WEED_PARSER_NUMERIC_HPP #include +#include +#include +#include +#include #include #endif // #ifndef SPROUT_WEED_PARSER_NUMERIC_HPP diff --git a/sprout/weed/parser/numeric/bin.hpp b/sprout/weed/parser/numeric/bin.hpp new file mode 100644 index 00000000..92cb05c5 --- /dev/null +++ b/sprout/weed/parser/numeric/bin.hpp @@ -0,0 +1,40 @@ +#ifndef SPROUT_WEED_PARSER_NUMERIC_BIN_HPP +#define SPROUT_WEED_PARSER_NUMERIC_BIN_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace weed { + // + // bin + // + SPROUT_STATIC_CONSTEXPR auto bin = sprout::weed::uint_p(); + + // + // bin8 + // bin16 + // bin32 + // bin64 + // + SPROUT_STATIC_CONSTEXPR auto bin8 = sprout::weed::uint_p(); + SPROUT_STATIC_CONSTEXPR auto bin16 = sprout::weed::uint_p(); + SPROUT_STATIC_CONSTEXPR auto bin32 = sprout::weed::uint_p(); + SPROUT_STATIC_CONSTEXPR auto bin64 = sprout::weed::uint_p(); + + // + // bin8f + // bin16f + // bin32f + // bin64f + // + SPROUT_STATIC_CONSTEXPR auto bin8f = sprout::weed::uint_p::value>(); + SPROUT_STATIC_CONSTEXPR auto bin16f = sprout::weed::uint_p::value>(); + SPROUT_STATIC_CONSTEXPR auto bin32f = sprout::weed::uint_p::value>(); + SPROUT_STATIC_CONSTEXPR auto bin64f = sprout::weed::uint_p::value>(); + } // namespace weed +} // namespace sprout + +#endif // #ifndef SPROUT_WEED_PARSER_NUMERIC_BIN_HPP diff --git a/sprout/weed/parser/numeric/hex.hpp b/sprout/weed/parser/numeric/hex.hpp index a2ddf42a..827bb714 100644 --- a/sprout/weed/parser/numeric/hex.hpp +++ b/sprout/weed/parser/numeric/hex.hpp @@ -1,131 +1,39 @@ #ifndef SPROUT_WEED_PARSER_NUMERIC_HEX_HPP #define SPROUT_WEED_PARSER_NUMERIC_HEX_HPP -#include +#include #include -#include -#include -#include -#include -#include -#include +#include +#include namespace sprout { namespace weed { // - // hex_p + // hex // - 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()) - ; - } - }; + SPROUT_STATIC_CONSTEXPR auto hex = sprout::weed::uint_p(); + // // 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(); + SPROUT_STATIC_CONSTEXPR auto hex8 = sprout::weed::uint_p(); + SPROUT_STATIC_CONSTEXPR auto hex16 = sprout::weed::uint_p(); + SPROUT_STATIC_CONSTEXPR auto hex32 = sprout::weed::uint_p(); + SPROUT_STATIC_CONSTEXPR auto hex64 = sprout::weed::uint_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(); + SPROUT_STATIC_CONSTEXPR auto hex8f = sprout::weed::uint_p::value>(); + SPROUT_STATIC_CONSTEXPR auto hex16f = sprout::weed::uint_p::value>(); + SPROUT_STATIC_CONSTEXPR auto hex32f = sprout::weed::uint_p::value>(); + SPROUT_STATIC_CONSTEXPR auto hex64f = sprout::weed::uint_p::value>(); } // namespace weed } // namespace sprout diff --git a/sprout/weed/parser/numeric/oct.hpp b/sprout/weed/parser/numeric/oct.hpp new file mode 100644 index 00000000..8d65a4eb --- /dev/null +++ b/sprout/weed/parser/numeric/oct.hpp @@ -0,0 +1,40 @@ +#ifndef SPROUT_WEED_PARSER_NUMERIC_OCT_HPP +#define SPROUT_WEED_PARSER_NUMERIC_OCT_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace weed { + // + // oct + // + SPROUT_STATIC_CONSTEXPR auto oct = sprout::weed::uint_p(); + + // + // oct8 + // oct16 + // oct32 + // oct64 + // + SPROUT_STATIC_CONSTEXPR auto oct8 = sprout::weed::uint_p(); + SPROUT_STATIC_CONSTEXPR auto oct16 = sprout::weed::uint_p(); + SPROUT_STATIC_CONSTEXPR auto oct32 = sprout::weed::uint_p(); + SPROUT_STATIC_CONSTEXPR auto oct64 = sprout::weed::uint_p(); + + // + // oct8f + // oct16f + // oct32f + // oct64f + // + SPROUT_STATIC_CONSTEXPR auto oct8f = sprout::weed::uint_p::value>(); + SPROUT_STATIC_CONSTEXPR auto oct16f = sprout::weed::uint_p::value>(); + SPROUT_STATIC_CONSTEXPR auto oct32f = sprout::weed::uint_p::value>(); + SPROUT_STATIC_CONSTEXPR auto oct64f = sprout::weed::uint_p::value>(); + } // namespace weed +} // namespace sprout + +#endif // #ifndef SPROUT_WEED_PARSER_NUMERIC_OCT_HPP diff --git a/sprout/weed/parser/numeric/uint.hpp b/sprout/weed/parser/numeric/uint.hpp new file mode 100644 index 00000000..2bb583ad --- /dev/null +++ b/sprout/weed/parser/numeric/uint.hpp @@ -0,0 +1,29 @@ +#ifndef SPROUT_WEED_PARSER_NUMERIC_UINT_HPP +#define SPROUT_WEED_PARSER_NUMERIC_UINT_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace weed { + // + // uint + // + SPROUT_STATIC_CONSTEXPR auto uint = sprout::weed::uint_p(); + + // + // uint8 + // uint16 + // uint32 + // uint64 + // + SPROUT_STATIC_CONSTEXPR auto uint8 = sprout::weed::uint_p(); + SPROUT_STATIC_CONSTEXPR auto uint16 = sprout::weed::uint_p(); + SPROUT_STATIC_CONSTEXPR auto uint32 = sprout::weed::uint_p(); + SPROUT_STATIC_CONSTEXPR auto uint64 = sprout::weed::uint_p(); + } // namespace weed +} // namespace sprout + +#endif // #ifndef SPROUT_WEED_PARSER_NUMERIC_UINT_HPP diff --git a/sprout/weed/parser/numeric/uint_p.hpp b/sprout/weed/parser/numeric/uint_p.hpp new file mode 100644 index 00000000..8595bc84 --- /dev/null +++ b/sprout/weed/parser/numeric/uint_p.hpp @@ -0,0 +1,157 @@ +#ifndef SPROUT_WEED_PARSER_NUMERIC_UINT_P_HPP +#define SPROUT_WEED_PARSER_NUMERIC_UINT_P_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + namespace weed { + // + // uint_p + // + template< + typename IntType, + std::size_t Radix, + std::size_t MinDigits = 1, + std::size_t MaxDigits = sprout::integer_digits::value + > + struct uint_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 == MaxDigits, + 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 * Radix | sprout::tuples::get<0>(res)) + ) + : N < MinDigits + ? result_type(false, temp_first, attribute_type()) + : result_type(true, first, t) + ; + } + template + SPROUT_CONSTEXPR typename std::enable_if< + N != MaxDigits, + 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 * Radix | sprout::tuples::get<0>(res)) + ) + : N < MinDigits + ? 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_ndigit(*first) + ) + : N < MinDigits + ? 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_ndigit(*first) + ) + : result_type(false, first, attribute_type()) + ; + } + }; + } // namespace weed +} // namespace sprout + +#endif // #ifndef SPROUT_WEED_PARSER_NUMERIC_UINT_P_HPP