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/basic_chset.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/basic_chset.ipp')
-rw-r--r-- | 3rdParty/Boost/src/boost/spirit/home/classic/utility/impl/chset/basic_chset.ipp | 246 |
1 files changed, 246 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/spirit/home/classic/utility/impl/chset/basic_chset.ipp b/3rdParty/Boost/src/boost/spirit/home/classic/utility/impl/chset/basic_chset.ipp new file mode 100644 index 0000000..e7d9272 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/classic/utility/impl/chset/basic_chset.ipp @@ -0,0 +1,246 @@ +/*============================================================================= + Copyright (c) 2001-2003 Joel de Guzman + Copyright (c) 2001-2003 Daniel Nuffer + 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_BASIC_CHSET_IPP +#define BOOST_SPIRIT_BASIC_CHSET_IPP + +/////////////////////////////////////////////////////////////////////////////// +#include <bitset> +#include <boost/spirit/home/classic/utility/impl/chset/basic_chset.hpp> + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN + +/////////////////////////////////////////////////////////////////////////////// +// +// basic_chset: character set implementation +// +/////////////////////////////////////////////////////////////////////////////// +template <typename CharT> +inline basic_chset<CharT>::basic_chset() {} + +////////////////////////////////// +template <typename CharT> +inline basic_chset<CharT>::basic_chset(basic_chset const& arg_) +: rr(arg_.rr) {} + +////////////////////////////////// +template <typename CharT> +inline bool +basic_chset<CharT>::test(CharT v) const +{ return rr.test(v); } + +////////////////////////////////// +template <typename CharT> +inline void +basic_chset<CharT>::set(CharT from, CharT to) +{ rr.set(utility::impl::range<CharT>(from, to)); } + +////////////////////////////////// +template <typename CharT> +inline void +basic_chset<CharT>::set(CharT c) +{ rr.set(utility::impl::range<CharT>(c, c)); } + +////////////////////////////////// +template <typename CharT> +inline void +basic_chset<CharT>::clear(CharT from, CharT to) +{ rr.clear(utility::impl::range<CharT>(from, to)); } + +////////////////////////////////// +template <typename CharT> +inline void +basic_chset<CharT>::clear() +{ rr.clear(); } + +///////////////////////////////// +template <typename CharT> +inline void +basic_chset<CharT>::inverse() +{ + basic_chset inv; + inv.set( + (std::numeric_limits<CharT>::min)(), + (std::numeric_limits<CharT>::max)() + ); + inv -= *this; + swap(inv); +} + +///////////////////////////////// +template <typename CharT> +inline void +basic_chset<CharT>::swap(basic_chset& x) +{ rr.swap(x.rr); } + +///////////////////////////////// +template <typename CharT> +inline basic_chset<CharT>& +basic_chset<CharT>::operator|=(basic_chset<CharT> const& x) +{ + typedef typename utility::impl::range_run<CharT>::const_iterator const_iterator; + for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter) + rr.set(*iter); + return *this; +} + +///////////////////////////////// +template <typename CharT> +inline basic_chset<CharT>& +basic_chset<CharT>::operator&=(basic_chset<CharT> const& x) +{ + basic_chset inv; + inv.set( + (std::numeric_limits<CharT>::min)(), + (std::numeric_limits<CharT>::max)() + ); + inv -= x; + *this -= inv; + return *this; +} + +///////////////////////////////// +template <typename CharT> +inline basic_chset<CharT>& +basic_chset<CharT>::operator-=(basic_chset<CharT> const& x) +{ + typedef typename utility::impl::range_run<CharT>::const_iterator const_iterator; + for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter) + rr.clear(*iter); + return *this; +} + +///////////////////////////////// +template <typename CharT> +inline basic_chset<CharT>& +basic_chset<CharT>::operator^=(basic_chset<CharT> const& x) +{ + basic_chset bma = x; + bma -= *this; + *this -= x; + *this |= bma; + return *this; +} + +#if (CHAR_BIT == 8) + +/////////////////////////////////////////////////////////////////////////////// +// +// basic_chset: specializations for 8 bit chars using std::bitset +// +/////////////////////////////////////////////////////////////////////////////// +template <typename CharT> +inline basic_chset_8bit<CharT>::basic_chset_8bit() {} + +///////////////////////////////// +template <typename CharT> +inline basic_chset_8bit<CharT>::basic_chset_8bit(basic_chset_8bit const& arg_) +: bset(arg_.bset) {} + +///////////////////////////////// +template <typename CharT> +inline bool +basic_chset_8bit<CharT>::test(CharT v) const +{ return bset.test((unsigned char)v); } + +///////////////////////////////// +template <typename CharT> +inline void +basic_chset_8bit<CharT>::set(CharT from, CharT to) +{ + for (int i = from; i <= to; ++i) + bset.set((unsigned char)i); +} + +///////////////////////////////// +template <typename CharT> +inline void +basic_chset_8bit<CharT>::set(CharT c) +{ bset.set((unsigned char)c); } + +///////////////////////////////// +template <typename CharT> +inline void +basic_chset_8bit<CharT>::clear(CharT from, CharT to) +{ + for (int i = from; i <= to; ++i) + bset.reset((unsigned char)i); +} + +///////////////////////////////// +template <typename CharT> +inline void +basic_chset_8bit<CharT>::clear(CharT c) +{ bset.reset((unsigned char)c); } + +///////////////////////////////// +template <typename CharT> +inline void +basic_chset_8bit<CharT>::clear() +{ bset.reset(); } + +///////////////////////////////// +template <typename CharT> +inline void +basic_chset_8bit<CharT>::inverse() +{ bset.flip(); } + +///////////////////////////////// +template <typename CharT> +inline void +basic_chset_8bit<CharT>::swap(basic_chset_8bit& x) +{ std::swap(bset, x.bset); } + +///////////////////////////////// +template <typename CharT> +inline basic_chset_8bit<CharT>& +basic_chset_8bit<CharT>::operator|=(basic_chset_8bit const& x) +{ + bset |= x.bset; + return *this; +} + +///////////////////////////////// +template <typename CharT> +inline basic_chset_8bit<CharT>& +basic_chset_8bit<CharT>::operator&=(basic_chset_8bit const& x) +{ + bset &= x.bset; + return *this; +} + +///////////////////////////////// +template <typename CharT> +inline basic_chset_8bit<CharT>& +basic_chset_8bit<CharT>::operator-=(basic_chset_8bit const& x) +{ + bset &= ~x.bset; + return *this; +} + +///////////////////////////////// +template <typename CharT> +inline basic_chset_8bit<CharT>& +basic_chset_8bit<CharT>::operator^=(basic_chset_8bit const& x) +{ + bset ^= x.bset; + return *this; +} + +#endif + +BOOST_SPIRIT_CLASSIC_NAMESPACE_END + +}} // namespace boost::spirit + +#endif + |