diff options
author | Kevin Smith <git@kismith.co.uk> | 2013-01-04 19:42:37 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2013-04-06 13:36:54 (GMT) |
commit | 3333ab69d62d1be7ae7dd7a4e56cc4bb608d3add (patch) | |
tree | 5ee630b666ae21dd4c4202703c158383de1faf91 /3rdParty/Boost/src/boost/spirit/home/classic/utility/impl/chset_operators.ipp | |
parent | b9ef4566d31219d66a615b1eae042a01828c8b7d (diff) | |
download | swift-3333ab69d62d1be7ae7dd7a4e56cc4bb608d3add.zip swift-3333ab69d62d1be7ae7dd7a4e56cc4bb608d3add.tar.bz2 |
Add boost serialization library
We'll need it before too long
Change-Id: Ia34c7f26e1aedbc13a2fc10c980994cbcb7cb348
Diffstat (limited to '3rdParty/Boost/src/boost/spirit/home/classic/utility/impl/chset_operators.ipp')
-rw-r--r-- | 3rdParty/Boost/src/boost/spirit/home/classic/utility/impl/chset_operators.ipp | 666 |
1 files changed, 666 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/spirit/home/classic/utility/impl/chset_operators.ipp b/3rdParty/Boost/src/boost/spirit/home/classic/utility/impl/chset_operators.ipp new file mode 100644 index 0000000..4319c9b --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/classic/utility/impl/chset_operators.ipp @@ -0,0 +1,666 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to 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) +=============================================================================*/ +#ifndef BOOST_SPIRIT_CHSET_OPERATORS_IPP +#define BOOST_SPIRIT_CHSET_OPERATORS_IPP + +/////////////////////////////////////////////////////////////////////////////// +#include <boost/limits.hpp> + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN + +/////////////////////////////////////////////////////////////////////////////// +// +// chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(chset<CharT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) |= b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(chset<CharT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) -= b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator~(chset<CharT> const& a) +{ + return chset<CharT>(a).inverse(); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(chset<CharT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) &= b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(chset<CharT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) ^= b; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// range <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(chset<CharT> const& a, range<CharT> const& b) +{ + chset<CharT> a_(a); + a_.set(b); + return a_; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(chset<CharT> const& a, range<CharT> const& b) +{ + chset<CharT> a_(a); + if(b.first != (std::numeric_limits<CharT>::min)()) { + a_.clear(range<CharT>((std::numeric_limits<CharT>::min)(), b.first - 1)); + } + if(b.last != (std::numeric_limits<CharT>::max)()) { + a_.clear(range<CharT>(b.last + 1, (std::numeric_limits<CharT>::max)())); + } + return a_; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(chset<CharT> const& a, range<CharT> const& b) +{ + chset<CharT> a_(a); + a_.clear(b); + return a_; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(chset<CharT> const& a, range<CharT> const& b) +{ + return a ^ chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(range<CharT> const& a, chset<CharT> const& b) +{ + chset<CharT> b_(b); + b_.set(a); + return b_; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(range<CharT> const& a, chset<CharT> const& b) +{ + chset<CharT> b_(b); + if(a.first != (std::numeric_limits<CharT>::min)()) { + b_.clear(range<CharT>((std::numeric_limits<CharT>::min)(), a.first - 1)); + } + if(a.last != (std::numeric_limits<CharT>::max)()) { + b_.clear(range<CharT>(a.last + 1, (std::numeric_limits<CharT>::max)())); + } + return b_; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(range<CharT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) - b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(range<CharT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) ^ b; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// literal primitives <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(chset<CharT> const& a, CharT b) +{ + return a | chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(chset<CharT> const& a, CharT b) +{ + return a & chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(chset<CharT> const& a, CharT b) +{ + return a - chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(chset<CharT> const& a, CharT b) +{ + return a ^ chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(CharT a, chset<CharT> const& b) +{ + return chset<CharT>(a) | b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(CharT a, chset<CharT> const& b) +{ + return chset<CharT>(a) & b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(CharT a, chset<CharT> const& b) +{ + return chset<CharT>(a) - b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(CharT a, chset<CharT> const& b) +{ + return chset<CharT>(a) ^ b; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// chlit <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(chset<CharT> const& a, chlit<CharT> const& b) +{ + return a | chset<CharT>(b.ch); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(chset<CharT> const& a, chlit<CharT> const& b) +{ + return a & chset<CharT>(b.ch); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(chset<CharT> const& a, chlit<CharT> const& b) +{ + return a - chset<CharT>(b.ch); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(chset<CharT> const& a, chlit<CharT> const& b) +{ + return a ^ chset<CharT>(b.ch); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(chlit<CharT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a.ch) | b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(chlit<CharT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a.ch) & b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(chlit<CharT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a.ch) - b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(chlit<CharT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a.ch) ^ b; +} + +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +/////////////////////////////////////////////////////////////////////////////// +// +// negated_char_parser <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template <typename CharT, typename ParserT> +inline chset<CharT> +operator|(chset<CharT> const& a, negated_char_parser<ParserT> const& b) +{ + return a | chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT, typename ParserT> +inline chset<CharT> +operator&(chset<CharT> const& a, negated_char_parser<ParserT> const& b) +{ + return a & chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT, typename ParserT> +inline chset<CharT> +operator-(chset<CharT> const& a, negated_char_parser<ParserT> const& b) +{ + return a - chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT, typename ParserT> +inline chset<CharT> +operator^(chset<CharT> const& a, negated_char_parser<ParserT> const& b) +{ + return a ^ chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT, typename ParserT> +inline chset<CharT> +operator|(negated_char_parser<ParserT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) | b; +} + +////////////////////////////////// +template <typename CharT, typename ParserT> +inline chset<CharT> +operator&(negated_char_parser<ParserT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) & b; +} + +////////////////////////////////// +template <typename CharT, typename ParserT> +inline chset<CharT> +operator-(negated_char_parser<ParserT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) - b; +} + +////////////////////////////////// +template <typename CharT, typename ParserT> +inline chset<CharT> +operator^(negated_char_parser<ParserT> const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) ^ b; +} + +#else // BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +/////////////////////////////////////////////////////////////////////////////// +// +// negated_char_parser<range> <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b) +{ + return a | chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b) +{ + return a & chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b) +{ + return a - chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(chset<CharT> const& a, negated_char_parser<range<CharT> > const& b) +{ + return a ^ chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) | b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) & b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) - b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(negated_char_parser<range<CharT> > const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) ^ b; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// negated_char_parser<chlit> <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b) +{ + return a | chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b) +{ + return a & chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b) +{ + return a - chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(chset<CharT> const& a, negated_char_parser<chlit<CharT> > const& b) +{ + return a ^ chset<CharT>(b); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) | b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) & b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) - b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(negated_char_parser<chlit<CharT> > const& a, chset<CharT> const& b) +{ + return chset<CharT>(a) ^ b; +} + +#endif // BOOST_WORKAROUND(BOOST_MSVC, < 1300) + +/////////////////////////////////////////////////////////////////////////////// +// +// anychar_parser <--> chset free operators +// +// Where a is chset and b is a anychar_parser, and vice-versa, implements: +// +// a | b, a & b, a - b, a ^ b +// +/////////////////////////////////////////////////////////////////////////////// +namespace impl { + + template <typename CharT> + inline BOOST_SPIRIT_CLASSIC_NS::range<CharT> const& + full() + { + static BOOST_SPIRIT_CLASSIC_NS::range<CharT> full_( + (std::numeric_limits<CharT>::min)(), + (std::numeric_limits<CharT>::max)()); + return full_; + } + + template <typename CharT> + inline BOOST_SPIRIT_CLASSIC_NS::range<CharT> const& + empty() + { + static BOOST_SPIRIT_CLASSIC_NS::range<CharT> empty_; + return empty_; + } +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(chset<CharT> const&, anychar_parser) +{ + return chset<CharT>(impl::full<CharT>()); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(chset<CharT> const& a, anychar_parser) +{ + return a; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(chset<CharT> const&, anychar_parser) +{ + return chset<CharT>(); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(chset<CharT> const& a, anychar_parser) +{ + return ~a; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(anychar_parser, chset<CharT> const& /*b*/) +{ + return chset<CharT>(impl::full<CharT>()); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(anychar_parser, chset<CharT> const& b) +{ + return b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(anychar_parser, chset<CharT> const& b) +{ + return ~b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(anychar_parser, chset<CharT> const& b) +{ + return ~b; +} + +/////////////////////////////////////////////////////////////////////////////// +// +// nothing_parser <--> chset free operators implementation +// +/////////////////////////////////////////////////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(chset<CharT> const& a, nothing_parser) +{ + return a; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(chset<CharT> const& /*a*/, nothing_parser) +{ + return impl::empty<CharT>(); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(chset<CharT> const& a, nothing_parser) +{ + return a; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(chset<CharT> const& a, nothing_parser) +{ + return a; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator|(nothing_parser, chset<CharT> const& b) +{ + return b; +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator&(nothing_parser, chset<CharT> const& /*b*/) +{ + return impl::empty<CharT>(); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator-(nothing_parser, chset<CharT> const& /*b*/) +{ + return impl::empty<CharT>(); +} + +////////////////////////////////// +template <typename CharT> +inline chset<CharT> +operator^(nothing_parser, chset<CharT> const& b) +{ + return b; +} + +/////////////////////////////////////////////////////////////////////////////// +BOOST_SPIRIT_CLASSIC_NAMESPACE_END + +}} // namespace boost::spirit + +#endif + |