/*============================================================================= Copyright (c) 2011-2013 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_WEED_PARSER_CHAR_CHAR_CLASS_HPP #define SPROUT_WEED_PARSER_CHAR_CHAR_CLASS_HPP #include #include #include #include #include #include #include #include namespace sprout { namespace weed { #define SPROUT_WEED_DEFINE_CTYPE_P(NAME, ISNAME) \ template \ struct NAME \ : public sprout::weed::parser_base \ { \ public: \ template \ struct attribute \ : public std::conditional< \ Nil, \ sprout::weed::unused, \ typename std::iterator_traits::value_type \ > \ {}; \ template \ struct result \ : public sprout::identity::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 && sprout::ascii::ISNAME(*first) \ ? result_type(true, sprout::next(first), *first) \ : result_type(false, first, attribute_type()) \ ; \ } \ } // // alnum_p // alpha_p // blank_p // cntrl_p // digit_p // graph_p // print_p // punct_p // space_p // xdigit_p // lower_p // upper_p // SPROUT_WEED_DEFINE_CTYPE_P(alnum_p, isalnum); SPROUT_WEED_DEFINE_CTYPE_P(alpha_p, isalpha); SPROUT_WEED_DEFINE_CTYPE_P(blank_p, isblank); SPROUT_WEED_DEFINE_CTYPE_P(cntrl_p, iscntrl); SPROUT_WEED_DEFINE_CTYPE_P(digit_p, isdigit); SPROUT_WEED_DEFINE_CTYPE_P(graph_p, isgraph); SPROUT_WEED_DEFINE_CTYPE_P(print_p, isprint); SPROUT_WEED_DEFINE_CTYPE_P(punct_p, ispunct); SPROUT_WEED_DEFINE_CTYPE_P(space_p, isspace); SPROUT_WEED_DEFINE_CTYPE_P(xdigit_p, isxdigit); SPROUT_WEED_DEFINE_CTYPE_P(lower_p, islower); SPROUT_WEED_DEFINE_CTYPE_P(upper_p, isupper); #undef SPROUT_WEED_DEFINE_CTYPE_P // // alnum // alpha // blank // cntrl // digit // graph // print // punct // space // xdigit // lower // upper // SPROUT_STATIC_CONSTEXPR sprout::weed::alnum_p<> alnum = sprout::weed::alnum_p<>(); SPROUT_STATIC_CONSTEXPR sprout::weed::alpha_p<> alpha = sprout::weed::alpha_p<>(); SPROUT_STATIC_CONSTEXPR sprout::weed::blank_p<> blank = sprout::weed::blank_p<>(); SPROUT_STATIC_CONSTEXPR sprout::weed::cntrl_p<> cntrl = sprout::weed::cntrl_p<>(); SPROUT_STATIC_CONSTEXPR sprout::weed::digit_p<> digit = sprout::weed::digit_p<>(); SPROUT_STATIC_CONSTEXPR sprout::weed::graph_p<> graph = sprout::weed::graph_p<>(); SPROUT_STATIC_CONSTEXPR sprout::weed::print_p<> print = sprout::weed::print_p<>(); SPROUT_STATIC_CONSTEXPR sprout::weed::punct_p<> punct = sprout::weed::punct_p<>(); SPROUT_STATIC_CONSTEXPR sprout::weed::space_p<> space = sprout::weed::space_p<>(); SPROUT_STATIC_CONSTEXPR sprout::weed::xdigit_p<> xdigit = sprout::weed::xdigit_p<>(); SPROUT_STATIC_CONSTEXPR sprout::weed::lower_p<> lower = sprout::weed::lower_p<>(); SPROUT_STATIC_CONSTEXPR sprout::weed::upper_p<> upper = sprout::weed::upper_p<>(); // // alnum_ // alpha_ // blank_ // cntrl_ // digit_ // graph_ // print_ // punct_ // space_ // xdigit_ // lower_ // upper_ // SPROUT_STATIC_CONSTEXPR sprout::weed::alnum_p alnum_ = sprout::weed::alnum_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::alpha_p alpha_ = sprout::weed::alpha_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::blank_p blank_ = sprout::weed::blank_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::cntrl_p cntrl_ = sprout::weed::cntrl_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::digit_p digit_ = sprout::weed::digit_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::graph_p graph_ = sprout::weed::graph_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::print_p print_ = sprout::weed::print_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::punct_p punct_ = sprout::weed::punct_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::space_p space_ = sprout::weed::space_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::xdigit_p xdigit_ = sprout::weed::xdigit_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::lower_p lower_ = sprout::weed::lower_p(); SPROUT_STATIC_CONSTEXPR sprout::weed::upper_p upper_ = sprout::weed::upper_p(); } // namespace weed } // namespace sprout #endif // #ifndef SPROUT_WEED_PARSER_CHAR_CHAR_CLASS_HPP