#ifndef SPROUT_WEED_PARSER_STRING_STRING_HPP #define SPROUT_WEED_PARSER_STRING_STRING_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT #include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace weed { // // lit_str_p // template struct lit_str_p : public sprout::weed::parser_base { public: template struct attribute { public: typedef sprout::weed::unused type; }; template struct result { public: typedef sprout::weed::parser_result::type> type; }; private: T t_; public: lit_str_p() = default; SPROUT_CONSTEXPR explicit lit_str_p(T const& t) : t_(t) {} 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 NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) >= sprout::size(t_) &&NS_SSCRISK_CEL_OR_SPROUT::equal(sprout::begin(t_), sprout::end(t_), first) ? result_type(true, sprout::next(first, sprout::size(t_)), attribute_type()) : result_type(false, first, typename attribute::type()) ; } }; // // lit_g // template struct lit_g::eval< T, typename std::enable_if< sprout::weed::traits::is_c_str::value >::type > { public: typedef sprout::weed::lit_str_p< typename sprout::weed::detail::c_str_as_string::type > result_type; public: SPROUT_CONSTEXPR result_type operator()(T const& t) const { return result_type(sprout::to_string(t)); } }; template struct lit_g::eval< T, typename std::enable_if< sprout::weed::traits::is_string::value >::type > { public: typedef sprout::weed::lit_str_p result_type; public: SPROUT_CONSTEXPR result_type operator()(T const& t) const { return result_type(t); } }; // // str_p // template struct str_p : public sprout::weed::parser_base { public: template struct attribute { public: typedef T type; }; template struct result { public: typedef sprout::weed::parser_result::type> type; }; private: T t_; public: str_p() = default; SPROUT_CONSTEXPR explicit str_p(T const& t) : t_(t) {} 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 NS_SSCRISK_CEL_OR_SPROUT::distance(first, last) >= sprout::size(t_) &&NS_SSCRISK_CEL_OR_SPROUT::equal(sprout::begin(t_), sprout::end(t_), first) ? result_type(true, sprout::next(first, sprout::size(t_)), attribute_type()) : result_type(false, first, typename attribute::type()) ; } }; // // string // template SPROUT_CONSTEXPR inline typename std::enable_if< sprout::weed::traits::is_c_str::value, sprout::weed::str_p< typename sprout::weed::detail::c_str_as_string::type > >::type string(T const& t) { return sprout::weed::str_p< typename sprout::weed::detail::c_str_as_string::type >(sprout::to_string(t)); } template SPROUT_CONSTEXPR inline typename std::enable_if< sprout::weed::traits::is_string::value, sprout::weed::str_p >::type string(T const& t) { return sprout::weed::str_p(t); } } // namespace weed } // namespace sprout #endif // #ifndef SPROUT_WEED_PARSER_STRING_STRING_HPP