1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/sprout/weed/traits/parser/attribute_of.hpp

84 lines
2.8 KiB
C++
Raw Normal View History

2013-08-08 09:54:33 +00:00
/*=============================================================================
2016-02-25 09:48:28 +00:00
Copyright (c) 2011-2016 Bolero MURAKAMI
2013-08-08 09:54:33 +00:00
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)
=============================================================================*/
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>
2013-03-25 03:43:47 +00:00
#include <sprout/weed/traits/expr/is_expr.hpp>
2011-11-13 08:54:38 +00:00
#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
2013-03-25 03:43:47 +00:00
>
: public T::template attribute<Context, Iterator>
{};
2011-11-13 08:54:38 +00:00
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
2013-03-25 03:43:47 +00:00
>
: public sprout::identity<typename Context::template eval<T>::attribute_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