Sprout/sprout/weed/traits/parser/attribute_of.hpp

78 lines
2.4 KiB
C++
Raw Normal View History

2011-11-13 08:54:38 +00:00
#ifndef SPROUT_WEED_TRAITS_PARSER_ATTRIBUTE_OF_HPP
#define SPROUT_WEED_TRAITS_PARSER_ATTRIBUTE_OF_HPP
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/weed/unused.hpp>
#include <sprout/weed/expr/expr.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/traits/type/is_char_type.hpp>
#include <sprout/weed/traits/type/is_c_str.hpp>
#include <sprout/weed/traits/type/is_string.hpp>
#include <sprout/weed/traits/expr/is_expr.hpp>
#include <sprout/weed/traits/expr/terminal_of.hpp>
2011-11-13 08:54:38 +00:00
#include <sprout/weed/traits/parser/is_parser.hpp>
namespace sprout {
namespace weed {
namespace traits {
//
// attribute_of
//
template<typename T, typename Iterator, typename Context, typename = void>
struct attribute_of;
template<typename T, typename Iterator, typename Context>
struct attribute_of<T const, Iterator, Context>
: public sprout::weed::traits::attribute_of<T, Iterator, Context>
{};
template<typename T, typename Iterator, typename Context>
struct attribute_of<
T,
Iterator,
Context,
typename std::enable_if<
sprout::weed::traits::is_parser<T>::value
&& !sprout::weed::traits::is_expr<T>::value
&& !sprout::weed::traits::is_char_type<T>::value
&& !sprout::weed::traits::is_c_str<T>::value
&& !sprout::weed::traits::is_string<T>::value
>::type
> {
public:
typedef typename T::template attribute<Context, Iterator>::type type;
};
template<typename T, typename Iterator, typename Context>
struct attribute_of<
T,
Iterator,
Context,
typename std::enable_if<
sprout::weed::traits::is_expr<T>::value
2011-11-13 08:54:38 +00:00
>::type
> {
public:
typedef typename Context::template eval<T>::attribute_type type;
};
template<typename T, typename Iterator, typename Context>
struct attribute_of<
T,
Iterator,
Context,
typename std::enable_if<
sprout::weed::traits::is_char_type<T>::value
|| sprout::weed::traits::is_c_str<T>::value
|| sprout::weed::traits::is_string<T>::value
>::type
>
: public sprout::weed::traits::attribute_of<
typename sprout::weed::traits::terminal_of<T>::type,
Iterator,
Context
2011-11-13 08:54:38 +00:00
>
{};
} // namespace traits
} // namespace weed
} // namespace sprout
#endif // #ifndef SPROUT_WEED_TRAITS_PARSER_ATTRIBUTE_OF_HPP