diff options
Diffstat (limited to 'boost/metaparse/v1/cpp98')
-rw-r--r-- | boost/metaparse/v1/cpp98/first_of.hpp | 35 | ||||
-rw-r--r-- | boost/metaparse/v1/cpp98/impl/nth_of_c.hpp | 61 | ||||
-rw-r--r-- | boost/metaparse/v1/cpp98/impl/nth_of_c_impl.hpp | 77 | ||||
-rw-r--r-- | boost/metaparse/v1/cpp98/impl/skip_seq.hpp | 74 | ||||
-rw-r--r-- | boost/metaparse/v1/cpp98/last_of.hpp | 66 | ||||
-rw-r--r-- | boost/metaparse/v1/cpp98/nth_of.hpp | 40 | ||||
-rw-r--r-- | boost/metaparse/v1/cpp98/nth_of_c.hpp | 70 |
7 files changed, 423 insertions, 0 deletions
diff --git a/boost/metaparse/v1/cpp98/first_of.hpp b/boost/metaparse/v1/cpp98/first_of.hpp new file mode 100644 index 0000000000..7f27ddabf0 --- /dev/null +++ b/boost/metaparse/v1/cpp98/first_of.hpp @@ -0,0 +1,35 @@ +#ifndef BOOST_METAPARSE_V1_CPP98_FIRST_OF_HPP +#define BOOST_METAPARSE_V1_CPP98_FIRST_OF_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2009 - 2010. +// 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 <boost/metaparse/v1/cpp98/nth_of_c.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + template < + BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( + BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, + class P, + boost::mpl::na + ) + > + struct first_of : + nth_of_c< + 0, + BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, P) + > + {}; + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp98/impl/nth_of_c.hpp b/boost/metaparse/v1/cpp98/impl/nth_of_c.hpp new file mode 100644 index 0000000000..f71728c62c --- /dev/null +++ b/boost/metaparse/v1/cpp98/impl/nth_of_c.hpp @@ -0,0 +1,61 @@ +#ifndef BOOST_METAPARSE_V1_CPP98_IMPL_NTH_OF_C_HPP +#define BOOST_METAPARSE_V1_CPP98_IMPL_NTH_OF_C_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// 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 <boost/metaparse/v1/cpp98/impl/nth_of_c_impl.hpp> +#include <boost/metaparse/v1/error/index_out_of_range.hpp> +#include <boost/metaparse/v1/fail.hpp> +#include <boost/metaparse/limit_sequence_size.hpp> + +#include <boost/mpl/list.hpp> + +#include <boost/preprocessor/repetition/repeat.hpp> +#include <boost/preprocessor/punctuation/comma_if.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/cat.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + namespace impl + { + #ifdef BOOST_METAPARSE_NTH_OF_CASE + # error BOOST_METAPARSE_NTH_OF_CASE already defined + #endif + #define BOOST_METAPARSE_NTH_OF_CASE(z, n, unused) \ + template < \ + int K BOOST_PP_COMMA_IF(n) \ + BOOST_PP_ENUM_PARAMS(n, class P) \ + > \ + struct BOOST_PP_CAT(nth_of_c, n) : \ + boost::mpl::if_< \ + boost::mpl::bool_<(0 <= K && K < n)>, \ + nth_of_c_impl< \ + K, \ + boost::mpl::list<BOOST_PP_ENUM_PARAMS(n, P)> \ + >, \ + fail<error::index_out_of_range<0, n - 1, K> > \ + >::type \ + {}; + + BOOST_PP_REPEAT( + BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, + BOOST_METAPARSE_NTH_OF_CASE, + ~ + ) + + #undef BOOST_METAPARSE_NTH_OF_CASE + } + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp98/impl/nth_of_c_impl.hpp b/boost/metaparse/v1/cpp98/impl/nth_of_c_impl.hpp new file mode 100644 index 0000000000..125267a56e --- /dev/null +++ b/boost/metaparse/v1/cpp98/impl/nth_of_c_impl.hpp @@ -0,0 +1,77 @@ +#ifndef BOOST_METAPARSE_V1_CPP98_IMPL_NTH_OF_C_IMPL_HPP +#define BOOST_METAPARSE_V1_CPP98_IMPL_NTH_OF_C_IMPL_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// 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 <boost/metaparse/v1/cpp98/impl/skip_seq.hpp> + +#include <boost/mpl/front.hpp> +#include <boost/mpl/pop_front.hpp> +#include <boost/mpl/fold.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + namespace impl + { + template <int N, class Seq> + struct nth_of_c_impl + { + private: + template <class NextResult> + struct apply_unchecked : + nth_of_c_impl< + N - 1, + typename boost::mpl::pop_front<Seq>::type + >::template apply< + typename get_remaining<NextResult>::type, + typename get_position<NextResult>::type + > + {}; + public: + typedef nth_of_c_impl type; + + template <class S, class Pos> + struct apply : + boost::mpl::eval_if< + typename is_error< + typename boost::mpl::front<Seq>::type::template apply<S, Pos> + >::type, + typename boost::mpl::front<Seq>::type::template apply<S, Pos>, + apply_unchecked< + typename boost::mpl::front<Seq>::type::template apply<S, Pos> + > + > + {}; + }; + + template <class Seq> + struct nth_of_c_impl<0, Seq> + { + typedef nth_of_c_impl type; + + template <class S, class Pos> + struct apply : + boost::mpl::fold< + typename boost::mpl::pop_front<Seq>::type, + typename boost::mpl::front<Seq>::type::template apply< + S, + Pos + >::type, + skip_seq + > + {}; + }; + } + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp98/impl/skip_seq.hpp b/boost/metaparse/v1/cpp98/impl/skip_seq.hpp new file mode 100644 index 0000000000..ef4e7c0325 --- /dev/null +++ b/boost/metaparse/v1/cpp98/impl/skip_seq.hpp @@ -0,0 +1,74 @@ +#ifndef BOOST_METAPARSE_V1_CPP98_IMPL_SKIP_SEQ_HPP +#define BOOST_METAPARSE_V1_CPP98_IMPL_SKIP_SEQ_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// 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 <boost/metaparse/v1/is_error.hpp> +#include <boost/metaparse/v1/accept.hpp> +#include <boost/metaparse/v1/get_remaining.hpp> +#include <boost/metaparse/v1/get_position.hpp> +#include <boost/metaparse/v1/get_result.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + namespace impl + { + struct skip_seq + { + private: + template <class ParsingResult, class NewResultValue> + struct change_result : + accept< + NewResultValue, + typename get_remaining<ParsingResult>::type, + typename get_position<ParsingResult>::type + > + {}; + + template <class Result, class P> + struct apply_unchecked : + boost::mpl::eval_if< + typename is_error< + typename P::template apply< + typename get_remaining<Result>::type, + typename get_position<Result>::type + > + >::type, + typename P::template apply< + typename get_remaining<Result>::type, + typename get_position<Result>::type + >, + change_result< + typename P::template apply< + typename get_remaining<Result>::type, + typename get_position<Result>::type + >, + typename get_result<Result>::type + > + > + {}; + + public: + template <class Result, class P> + struct apply : + boost::mpl::eval_if< + is_error<Result>, + Result, + apply_unchecked<Result, P> + > + {}; + }; + } + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp98/last_of.hpp b/boost/metaparse/v1/cpp98/last_of.hpp new file mode 100644 index 0000000000..4e5e4756a3 --- /dev/null +++ b/boost/metaparse/v1/cpp98/last_of.hpp @@ -0,0 +1,66 @@ +#ifndef BOOST_METAPARSE_V1_CPP98_LAST_OF_HPP +#define BOOST_METAPARSE_V1_CPP98_LAST_OF_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2009 - 2010. +// 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 <boost/metaparse/v1/cpp98/nth_of_c.hpp> + +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/punctuation/comma_if.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> +#include <boost/preprocessor/repetition/enum.hpp> +#include <boost/preprocessor/repetition/repeat.hpp> +#include <boost/preprocessor/arithmetic/sub.hpp> +#include <boost/preprocessor/tuple/eat.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + template < + BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( + BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, + class P, + boost::mpl::na + ) + > + struct last_of; + + #ifdef BOOST_METAPARSE_LAST_OF_N + # error BOOST_METAPARSE_LAST_OF_N already defined + #endif + #define BOOST_METAPARSE_LAST_OF_N(z, n, unused) \ + template <BOOST_PP_ENUM_PARAMS(n, class P)> \ + struct last_of< \ + BOOST_PP_ENUM_PARAMS(n, P) \ + BOOST_PP_COMMA_IF(n) \ + BOOST_PP_ENUM( \ + BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, n), \ + boost::mpl::na BOOST_PP_TUPLE_EAT(3), \ + ~ \ + ) \ + > : \ + impl::BOOST_PP_CAT(nth_of_c, n)< \ + n - 1 BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, P) \ + > \ + {}; + + BOOST_PP_REPEAT( + BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, + BOOST_METAPARSE_LAST_OF_N, + ~ + ) + + #undef BOOST_METAPARSE_LAST_OF_N + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp98/nth_of.hpp b/boost/metaparse/v1/cpp98/nth_of.hpp new file mode 100644 index 0000000000..94b5613eac --- /dev/null +++ b/boost/metaparse/v1/cpp98/nth_of.hpp @@ -0,0 +1,40 @@ +#ifndef BOOST_METAPARSE_V1_CPP98_NTH_OF_HPP +#define BOOST_METAPARSE_V1_CPP98_NTH_OF_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2010. +// 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 <boost/metaparse/v1/nth_of_c.hpp> +#include <boost/metaparse/limit_sequence_size.hpp> + +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + template < + class K, + BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( + BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, + class P, + boost::mpl::na + ) + > + struct nth_of : + nth_of_c< + K::type::value, + BOOST_PP_ENUM_PARAMS(BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, P) + > + {}; + } + } +} + +#endif + diff --git a/boost/metaparse/v1/cpp98/nth_of_c.hpp b/boost/metaparse/v1/cpp98/nth_of_c.hpp new file mode 100644 index 0000000000..ae86d31c5b --- /dev/null +++ b/boost/metaparse/v1/cpp98/nth_of_c.hpp @@ -0,0 +1,70 @@ +#ifndef BOOST_METAPARSE_V1_CPP98_NTH_OF_C_HPP +#define BOOST_METAPARSE_V1_CPP98_NTH_OF_C_HPP + +// Copyright Abel Sinkovics (abel@sinkovics.hu) 2013. +// 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 <boost/metaparse/v1/cpp98/impl/nth_of_c.hpp> +#include <boost/metaparse/limit_sequence_size.hpp> + +#include <boost/preprocessor/repetition/repeat.hpp> +#include <boost/preprocessor/repetition/enum.hpp> +#include <boost/preprocessor/punctuation/comma_if.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> +#include <boost/preprocessor/arithmetic/sub.hpp> +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/tuple/eat.hpp> + +namespace boost +{ + namespace metaparse + { + namespace v1 + { + template < + int N, + BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( + BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, + class P, + boost::mpl::na + ) + > + struct nth_of_c; + + #ifdef BOOST_METAPARSE_NTH_OF_N + # error BOOST_METAPARSE_NTH_OF_N already defined + #endif + #define BOOST_METAPARSE_NTH_OF_N(z, n, unused) \ + template <int K BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class P)> \ + struct nth_of_c< \ + K, \ + BOOST_PP_ENUM_PARAMS(n, P) \ + BOOST_PP_COMMA_IF(n) \ + BOOST_PP_ENUM( \ + BOOST_PP_SUB(BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, n), \ + boost::mpl::na BOOST_PP_TUPLE_EAT(3), \ + ~ \ + ) \ + > : \ + impl::BOOST_PP_CAT(nth_of_c, n)< \ + K BOOST_PP_COMMA_IF(n) \ + BOOST_PP_ENUM_PARAMS(n, P) \ + > \ + {}; + + BOOST_PP_REPEAT( + BOOST_METAPARSE_LIMIT_SEQUENCE_SIZE, + BOOST_METAPARSE_NTH_OF_N, + ~ + ) + + #undef BOOST_METAPARSE_NTH_OF_N + } + } +} + +#endif + |