#ifndef BOOST_METAPARSE_V1_STRING_HPP #define BOOST_METAPARSE_V1_STRING_HPP // Copyright Abel Sinkovics (abel@sinkovics.hu) 2012. // 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) #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* * The string type */ namespace boost { namespace metaparse { namespace v1 { #ifdef BOOST_METAPARSE_VARIADIC_STRING template struct string { typedef string type; typedef string_tag tag; }; #else template struct string { typedef string type; typedef string_tag tag; }; #endif } } } /* * Boost.MPL overloads */ namespace boost { namespace mpl { // push_back template struct push_back_impl; template <> struct push_back_impl { typedef push_back_impl type; template struct apply : boost::metaparse::v1::impl::push_back_c< typename S::type, C::type::value > {}; }; // pop_back template struct pop_back_impl; template <> struct pop_back_impl { typedef pop_back_impl type; template struct apply : boost::metaparse::v1::impl::pop_back {}; }; // push_front template struct push_front_impl; template <> struct push_front_impl { typedef push_front_impl type; template struct apply : boost::metaparse::v1::impl::push_front_c< typename S::type, C::type::value > {}; }; // pop_front template struct pop_front_impl; template <> struct pop_front_impl { typedef pop_front_impl type; template struct apply : boost::metaparse::v1::impl::pop_front {}; }; // clear template struct clear_impl; template <> struct clear_impl { typedef clear_impl type; template struct apply : boost::metaparse::v1::string<> {}; }; // begin template struct begin_impl; template <> struct begin_impl { typedef begin_impl type; template struct apply : boost::metaparse::v1::impl::string_iterator {}; }; // end template struct end_impl; template <> struct end_impl { typedef end_impl type; template struct apply : boost::metaparse::v1::impl::string_iterator< typename S::type, boost::metaparse::v1::impl::size::type::value > {}; }; // equal_to template struct equal_to_impl; template <> struct equal_to_impl< boost::metaparse::v1::string_tag, boost::metaparse::v1::string_tag > { typedef equal_to_impl type; template struct apply : boost::is_same {}; }; template struct equal_to_impl { typedef equal_to_impl type; template struct apply : false_ {}; }; template struct equal_to_impl : equal_to_impl {}; // c_str template struct c_str; #ifdef BOOST_METAPARSE_VARIADIC_STRING template struct c_str> { typedef c_str type; #ifdef BOOST_NO_CONSTEXPR_C_STR static const char value[sizeof...(Cs) + 1]; #else static constexpr char value[sizeof...(Cs) + 1] = {Cs..., 0}; #endif }; template <> struct c_str> : boost::metaparse::v1::impl::empty_string<> {}; #ifdef BOOST_NO_CONSTEXPR_C_STR template const char c_str>::value[] = {Cs..., 0}; #else template constexpr char c_str>::value[]; #endif #else template struct c_str< boost::metaparse::v1::string< BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C) > > { typedef c_str type; static BOOST_CONSTEXPR const char value[BOOST_METAPARSE_LIMIT_STRING_SIZE + 1] #if !defined BOOST_NO_CONSTEXPR && !defined BOOST_NO_CXX11_CONSTEXPR = {BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C), 0} #endif ; }; template BOOST_CONSTEXPR const char c_str< boost::metaparse::v1::string< BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C) > >::value[BOOST_METAPARSE_LIMIT_STRING_SIZE + 1] #if defined BOOST_NO_CONSTEXPR || defined BOOST_NO_CXX11_CONSTEXPR = {BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_STRING_SIZE, C), 0} #endif ; template <> struct c_str > : boost::metaparse::v1::impl::empty_string<> { typedef c_str type; }; #ifdef BOOST_METAPARSE_DEF # error BOOST_METAPARSE_DEF already defined #endif #define BOOST_METAPARSE_DEF(n) \ = {BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) 0} #ifdef BOOST_METAPARSE_STRING_DECLARE # error BOOST_METAPARSE_STRING_DECLARE already defined #endif #ifdef BOOST_METAPARSE_STRING_DEFINE # error BOOST_METAPARSE_STRING_DECLARE already defined #endif #if !defined BOOST_NO_CONSTEXPR && !defined BOOST_NO_CXX11_CONSTEXPR # define BOOST_METAPARSE_STRING_DECLARE(n) BOOST_METAPARSE_DEF(n) # define BOOST_METAPARSE_STRING_DEFINE(n) #else # define BOOST_METAPARSE_STRING_DECLARE(n) # define BOOST_METAPARSE_STRING_DEFINE(n) BOOST_METAPARSE_DEF(n) #endif #ifdef BOOST_METAPARSE_STRING_CASE # error BOOST_METAPARSE_STRING_CASE is already defined #endif #define BOOST_METAPARSE_STRING_CASE(z, n, unused) \ template \ struct \ c_str< \ boost::metaparse::v1::string< \ BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) \ BOOST_PP_ENUM( \ BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \ BOOST_NO_CHAR BOOST_PP_TUPLE_EAT(3), \ ~ \ ) \ > \ > \ { \ typedef c_str type; \ static BOOST_CONSTEXPR const char value[n + 1] \ BOOST_METAPARSE_STRING_DECLARE(n); \ }; \ \ template \ BOOST_CONSTEXPR const char c_str< \ boost::metaparse::v1::string< \ BOOST_PP_ENUM_PARAMS(n, C) BOOST_PP_COMMA_IF(n) \ BOOST_PP_ENUM( \ BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_STRING_SIZE, n), \ BOOST_NO_CHAR BOOST_PP_TUPLE_EAT(3), \ ~ \ ) \ > \ >::value[n + 1] BOOST_METAPARSE_STRING_DEFINE(n); BOOST_PP_REPEAT_FROM_TO( 1, BOOST_METAPARSE_LIMIT_STRING_SIZE, BOOST_METAPARSE_STRING_CASE, ~ ) #undef BOOST_METAPARSE_STRING_CASE #undef BOOST_METAPARSE_STRING_DECLARE #undef BOOST_METAPARSE_STRING_DEFINE #undef BOOST_METAPARSE_DEF #endif } } #include #if \ defined BOOST_METAPARSE_VARIADIC_STRING \ && !defined BOOST_NO_CONSTEXPR && !defined BOOST_NO_CXX11_CONSTEXPR # include #else # define BOOST_METAPARSE_V1_CONFIG_NO_BOOST_METAPARSE_STRING 1 #endif #endif