Added boost header

This commit is contained in:
Christophe Riccio
2012-01-08 01:26:07 +00:00
parent 9c3faaca40
commit c7d752cdf8
8946 changed files with 1732316 additions and 0 deletions

View File

@@ -0,0 +1,172 @@
/*=============================================================================
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_XPRESSIVE_SPIRIT_BASIC_CHSET_HPP_EAN_10_04_2005
#define BOOST_XPRESSIVE_SPIRIT_BASIC_CHSET_HPP_EAN_10_04_2005
///////////////////////////////////////////////////////////////////////////////
#include <bitset>
#include <boost/mpl/bool.hpp>
#include <boost/xpressive/detail/utility/chset/range_run.ipp>
namespace boost { namespace xpressive { namespace detail
{
///////////////////////////////////////////////////////////////////////////
//
// basic_chset: basic character set implementation using range_run
//
///////////////////////////////////////////////////////////////////////////
template<typename Char>
struct basic_chset
{
basic_chset();
basic_chset(basic_chset const &arg);
bool empty() const;
void set(Char from, Char to);
template<typename Traits>
void set(Char from, Char to, Traits const &tr);
void set(Char c);
template<typename Traits>
void set(Char c, Traits const &tr);
void clear(Char from, Char to);
template<typename Traits>
void clear(Char from, Char to, Traits const &tr);
void clear(Char c);
template<typename Traits>
void clear(Char c, Traits const &tr);
void clear();
template<typename Traits>
bool test(Char v, Traits const &tr, mpl::false_) const; // case-sensitive
template<typename Traits>
bool test(Char v, Traits const &tr, mpl::true_) const; // case-insensitive
void inverse();
void swap(basic_chset& x);
basic_chset &operator |=(basic_chset const &x);
basic_chset &operator &=(basic_chset const &x);
basic_chset &operator -=(basic_chset const &x);
basic_chset &operator ^=(basic_chset const &x);
private:
range_run<Char> rr_;
};
#if(CHAR_BIT == 8)
///////////////////////////////////////////////////////////////////////////
//
// basic_chset: specializations for 8 bit chars using std::bitset
//
///////////////////////////////////////////////////////////////////////////
template<typename Char>
struct basic_chset_8bit
{
basic_chset_8bit();
basic_chset_8bit(basic_chset_8bit const &arg);
bool empty() const;
void set(Char from, Char to);
template<typename Traits>
void set(Char from, Char to, Traits const &tr);
void set(Char c);
template<typename Traits>
void set(Char c, Traits const &tr);
void clear(Char from, Char to);
template<typename Traits>
void clear(Char from, Char to, Traits const &tr);
void clear(Char c);
template<typename Traits>
void clear(Char c, Traits const &tr);
void clear();
template<typename Traits>
bool test(Char v, Traits const &tr, mpl::false_) const; // case-sensitive
template<typename Traits>
bool test(Char v, Traits const &tr, mpl::true_) const; // case-insensitive
void inverse();
void swap(basic_chset_8bit& x);
basic_chset_8bit &operator |=(basic_chset_8bit const &x);
basic_chset_8bit &operator &=(basic_chset_8bit const &x);
basic_chset_8bit &operator -=(basic_chset_8bit const &x);
basic_chset_8bit &operator ^=(basic_chset_8bit const &x);
std::bitset<256> const &base() const;
private:
std::bitset<256> bset_; // BUGBUG range-checking slows this down
};
/////////////////////////////////
template<>
struct basic_chset<char>
: basic_chset_8bit<char>
{
};
/////////////////////////////////
template<>
struct basic_chset<signed char>
: basic_chset_8bit<signed char>
{
};
/////////////////////////////////
template<>
struct basic_chset<unsigned char>
: basic_chset_8bit<unsigned char>
{
};
#endif
///////////////////////////////////////////////////////////////////////////////
// is_narrow_char
template<typename Char>
struct is_narrow_char
: mpl::false_
{};
template<>
struct is_narrow_char<char>
: mpl::true_
{};
template<>
struct is_narrow_char<signed char>
: mpl::true_
{};
template<>
struct is_narrow_char<unsigned char>
: mpl::true_
{};
///////////////////////////////////////////////////////////////////////////////
// helpers
template<typename Char, typename Traits>
void set_char(basic_chset<Char> &chset, Char ch, Traits const &tr, bool icase);
template<typename Char, typename Traits>
void set_range(basic_chset<Char> &chset, Char from, Char to, Traits const &tr, bool icase);
template<typename Char, typename Traits>
void set_class(basic_chset<Char> &chset, typename Traits::char_class_type char_class, bool no, Traits const &tr);
}}} // namespace boost::xpressive::detail
#endif

View File

@@ -0,0 +1,409 @@
/*=============================================================================
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_XPRESSIVE_SPIRIT_BASIC_CHSET_IPP
#define BOOST_XPRESSIVE_SPIRIT_BASIC_CHSET_IPP
///////////////////////////////////////////////////////////////////////////////
#include <bitset>
#include <boost/xpressive/detail/utility/chset/basic_chset.hpp>
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace xpressive { namespace detail
{
///////////////////////////////////////////////////////////////////////////////
//
// basic_chset: character set implementation
//
///////////////////////////////////////////////////////////////////////////////
template<typename Char>
inline basic_chset<Char>::basic_chset()
{
}
//////////////////////////////////
template<typename Char>
inline basic_chset<Char>::basic_chset(basic_chset const &arg)
: rr_(arg.rr_)
{
}
//////////////////////////////////
template<typename Char>
inline bool basic_chset<Char>::empty() const
{
return this->rr_.empty();
}
//////////////////////////////////
template<typename Char>
template<typename Traits>
inline bool basic_chset<Char>::test(Char v, Traits const &, mpl::false_) const // case-sensitive
{
return this->rr_.test(v);
}
//////////////////////////////////
template<typename Char>
template<typename Traits>
inline bool basic_chset<Char>::test(Char v, Traits const &tr, mpl::true_) const // case-insensitive
{
return this->rr_.test(v, tr);
}
//////////////////////////////////
template<typename Char>
inline void basic_chset<Char>::set(Char from, Char to)
{
this->rr_.set(range<Char>(from, to));
}
//////////////////////////////////
template<typename Char>
template<typename Traits>
inline void basic_chset<Char>::set(Char from, Char to, Traits const &)
{
this->rr_.set(range<Char>(from, to));
}
//////////////////////////////////
template<typename Char>
inline void basic_chset<Char>::set(Char c)
{
this->rr_.set(range<Char>(c, c));
}
//////////////////////////////////
template<typename Char>
template<typename Traits>
inline void basic_chset<Char>::set(Char c, Traits const &)
{
this->rr_.set(range<Char>(c, c));
}
//////////////////////////////////
template<typename Char>
inline void basic_chset<Char>::clear(Char c)
{
this->rr_.clear(range<Char>(c, c));
}
//////////////////////////////////
template<typename Char>
template<typename Traits>
inline void basic_chset<Char>::clear(Char c, Traits const &)
{
this->rr_.clear(range<Char>(c, c));
}
//////////////////////////////////
template<typename Char>
inline void basic_chset<Char>::clear(Char from, Char to)
{
this->rr_.clear(range<Char>(from, to));
}
//////////////////////////////////
template<typename Char>
template<typename Traits>
inline void basic_chset<Char>::clear(Char from, Char to, Traits const &)
{
this->rr_.clear(range<Char>(from, to));
}
//////////////////////////////////
template<typename Char>
inline void basic_chset<Char>::clear()
{
this->rr_.clear();
}
/////////////////////////////////
template<typename Char>
inline void basic_chset<Char>::inverse()
{
// BUGBUG is this right? Does this handle icase correctly?
basic_chset<Char> inv;
inv.set((std::numeric_limits<Char>::min)(), (std::numeric_limits<Char>::max)());
inv -= *this;
this->swap(inv);
}
/////////////////////////////////
template<typename Char>
inline void basic_chset<Char>::swap(basic_chset<Char> &that)
{
this->rr_.swap(that.rr_);
}
/////////////////////////////////
template<typename Char>
inline basic_chset<Char> &
basic_chset<Char>::operator |=(basic_chset<Char> const &that)
{
typedef typename range_run<Char>::const_iterator const_iterator;
for(const_iterator iter = that.rr_.begin(); iter != that.rr_.end(); ++iter)
{
this->rr_.set(*iter);
}
return *this;
}
/////////////////////////////////
template<typename Char>
inline basic_chset<Char> &
basic_chset<Char>::operator &=(basic_chset<Char> const &that)
{
basic_chset<Char> inv;
inv.set((std::numeric_limits<Char>::min)(), (std::numeric_limits<Char>::max)());
inv -= that;
*this -= inv;
return *this;
}
/////////////////////////////////
template<typename Char>
inline basic_chset<Char> &
basic_chset<Char>::operator -=(basic_chset<Char> const &that)
{
typedef typename range_run<Char>::const_iterator const_iterator;
for(const_iterator iter = that.rr_.begin(); iter != that.rr_.end(); ++iter)
{
this->rr_.clear(*iter);
}
return *this;
}
/////////////////////////////////
template<typename Char>
inline basic_chset<Char> &
basic_chset<Char>::operator ^=(basic_chset<Char> const &that)
{
basic_chset bma = that;
bma -= *this;
*this -= that;
*this |= bma;
return *this;
}
#if(CHAR_BIT == 8)
///////////////////////////////////////////////////////////////////////////////
//
// basic_chset: specializations for 8 bit chars using std::bitset
//
///////////////////////////////////////////////////////////////////////////////
template<typename Char>
inline basic_chset_8bit<Char>::basic_chset_8bit()
{
}
/////////////////////////////////
template<typename Char>
inline basic_chset_8bit<Char>::basic_chset_8bit(basic_chset_8bit<Char> const &arg)
: bset_(arg.bset_)
{
}
/////////////////////////////////
template<typename Char>
inline bool basic_chset_8bit<Char>::empty() const
{
return !this->bset_.any();
}
/////////////////////////////////
template<typename Char>
template<typename Traits>
inline bool basic_chset_8bit<Char>::test(Char v, Traits const &, mpl::false_) const // case-sensitive
{
return this->bset_.test((unsigned char)v);
}
/////////////////////////////////
template<typename Char>
template<typename Traits>
inline bool basic_chset_8bit<Char>::test(Char v, Traits const &tr, mpl::true_) const // case-insensitive
{
return this->bset_.test((unsigned char)tr.translate_nocase(v));
}
/////////////////////////////////
template<typename Char>
inline void basic_chset_8bit<Char>::set(Char from, Char to)
{
for(int i = from; i <= to; ++i)
{
this->bset_.set((unsigned char)i);
}
}
/////////////////////////////////
template<typename Char>
template<typename Traits>
inline void basic_chset_8bit<Char>::set(Char from, Char to, Traits const &tr)
{
for(int i = from; i <= to; ++i)
{
this->bset_.set((unsigned char)tr.translate_nocase((Char)i));
}
}
/////////////////////////////////
template<typename Char>
inline void basic_chset_8bit<Char>::set(Char c)
{
this->bset_.set((unsigned char)c);
}
/////////////////////////////////
template<typename Char>
template<typename Traits>
inline void basic_chset_8bit<Char>::set(Char c, Traits const &tr)
{
this->bset_.set((unsigned char)tr.translate_nocase(c));
}
/////////////////////////////////
template<typename Char>
inline void basic_chset_8bit<Char>::clear(Char from, Char to)
{
for(int i = from; i <= to; ++i)
{
this->bset_.reset((unsigned char)i);
}
}
/////////////////////////////////
template<typename Char>
template<typename Traits>
inline void basic_chset_8bit<Char>::clear(Char from, Char to, Traits const &tr)
{
for(int i = from; i <= to; ++i)
{
this->bset_.reset((unsigned char)tr.translate_nocase((Char)i));
}
}
/////////////////////////////////
template<typename Char>
inline void basic_chset_8bit<Char>::clear(Char c)
{
this->bset_.reset((unsigned char)c);
}
/////////////////////////////////
template<typename Char>
template<typename Traits>
inline void basic_chset_8bit<Char>::clear(Char c, Traits const &tr)
{
this->bset_.reset((unsigned char)tr.tranlsate_nocase(c));
}
/////////////////////////////////
template<typename Char>
inline void basic_chset_8bit<Char>::clear()
{
this->bset_.reset();
}
/////////////////////////////////
template<typename Char>
inline void basic_chset_8bit<Char>::inverse()
{
this->bset_.flip();
}
/////////////////////////////////
template<typename Char>
inline void basic_chset_8bit<Char>::swap(basic_chset_8bit<Char> &that)
{
std::swap(this->bset_, that.bset_);
}
/////////////////////////////////
template<typename Char>
inline basic_chset_8bit<Char> &
basic_chset_8bit<Char>::operator |=(basic_chset_8bit<Char> const &that)
{
this->bset_ |= that.bset_;
return *this;
}
/////////////////////////////////
template<typename Char>
inline basic_chset_8bit<Char> &
basic_chset_8bit<Char>::operator &=(basic_chset_8bit<Char> const &that)
{
this->bset_ &= that.bset_;
return *this;
}
/////////////////////////////////
template<typename Char>
inline basic_chset_8bit<Char> &
basic_chset_8bit<Char>::operator -=(basic_chset_8bit<Char> const &that)
{
this->bset_ &= ~that.bset_;
return *this;
}
/////////////////////////////////
template<typename Char>
inline basic_chset_8bit<Char> &
basic_chset_8bit<Char>::operator ^=(basic_chset_8bit<Char> const &that)
{
this->bset_ ^= that.bset_;
return *this;
}
template<typename Char>
inline std::bitset<256> const &
basic_chset_8bit<Char>::base() const
{
return this->bset_;
}
#endif // if(CHAR_BIT == 8)
///////////////////////////////////////////////////////////////////////////////
// helpers
template<typename Char, typename Traits>
inline void set_char(basic_chset<Char> &chset, Char ch, Traits const &tr, bool icase)
{
icase ? chset.set(ch, tr) : chset.set(ch);
}
template<typename Char, typename Traits>
inline void set_range(basic_chset<Char> &chset, Char from, Char to, Traits const &tr, bool icase)
{
icase ? chset.set(from, to, tr) : chset.set(from, to);
}
template<typename Char, typename Traits>
inline void set_class(basic_chset<Char> &chset, typename Traits::char_class_type char_class, bool no, Traits const &tr)
{
BOOST_MPL_ASSERT_RELATION(1, ==, sizeof(Char));
for(std::size_t i = 0; i <= UCHAR_MAX; ++i)
{
typedef typename std::char_traits<Char>::int_type int_type;
Char ch = std::char_traits<Char>::to_char_type(static_cast<int_type>(i));
if(no != tr.isctype(ch, char_class))
{
chset.set(ch);
}
}
}
}}} // namespace boost::xpressive::detail
#endif

View File

@@ -0,0 +1,165 @@
///////////////////////////////////////////////////////////////////////////////
// chset.hpp
//
// Copyright 2008 Eric Niebler. 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)
#ifndef BOOST_XPRESSIVE_DETAIL_CHSET_CHSET_HPP_EAN_10_04_2005
#define BOOST_XPRESSIVE_DETAIL_CHSET_CHSET_HPP_EAN_10_04_2005
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <vector>
#include <boost/call_traits.hpp>
#include <boost/xpressive/detail/detail_fwd.hpp>
#include <boost/xpressive/detail/utility/algorithm.hpp>
#include <boost/xpressive/detail/utility/chset/basic_chset.ipp>
namespace boost { namespace xpressive { namespace detail
{
///////////////////////////////////////////////////////////////////////////////
// compound_charset
//
template<typename Traits>
struct compound_charset
: private basic_chset<typename Traits::char_type>
{
typedef typename Traits::char_type char_type;
typedef basic_chset<char_type> base_type;
typedef Traits traits_type;
typedef typename Traits::char_class_type char_class_type;
compound_charset()
: base_type()
, complement_(false)
, has_posix_(false)
, posix_yes_()
, posix_no_()
{
}
///////////////////////////////////////////////////////////////////////////////
// accessors
basic_chset<char_type> const &base() const
{
return *this;
}
bool is_inverted() const
{
return this->complement_;
}
char_class_type posix_yes() const
{
return this->posix_yes_;
}
std::vector<char_class_type> const &posix_no() const
{
return this->posix_no_;
}
///////////////////////////////////////////////////////////////////////////////
// complement
void inverse()
{
this->complement_ = !this->complement_;
}
///////////////////////////////////////////////////////////////////////////////
// set
void set_char(char_type ch, Traits const &tr, bool icase)
{
icase ? this->base_type::set(ch, tr) : this->base_type::set(ch);
}
void set_range(char_type from, char_type to, Traits const &tr, bool icase)
{
icase ? this->base_type::set(from, to, tr) : this->base_type::set(from, to);
}
void set_class(char_class_type const &m, bool no)
{
this->has_posix_ = true;
if(no)
{
this->posix_no_.push_back(m);
}
else
{
this->posix_yes_ |= m;
}
}
///////////////////////////////////////////////////////////////////////////////
// test
template<typename ICase>
bool test(char_type ch, Traits const &tr, ICase) const
{
return this->complement_ !=
(this->base_type::test(ch, tr, ICase()) ||
(this->has_posix_ && this->test_posix(ch, tr)));
}
private:
///////////////////////////////////////////////////////////////////////////////
// not_posix_pred
struct not_posix_pred
{
char_type ch_;
Traits const *traits_ptr_;
bool operator ()(typename call_traits<char_class_type>::param_type m) const
{
return !this->traits_ptr_->isctype(this->ch_, m);
}
};
///////////////////////////////////////////////////////////////////////////////
// test_posix
bool test_posix(char_type ch, Traits const &tr) const
{
not_posix_pred const pred = {ch, &tr};
return tr.isctype(ch, this->posix_yes_)
|| any(this->posix_no_.begin(), this->posix_no_.end(), pred);
}
bool complement_;
bool has_posix_;
char_class_type posix_yes_;
std::vector<char_class_type> posix_no_;
};
///////////////////////////////////////////////////////////////////////////////
// helpers
template<typename Char, typename Traits>
inline void set_char(compound_charset<Traits> &chset, Char ch, Traits const &tr, bool icase)
{
chset.set_char(ch, tr, icase);
}
template<typename Char, typename Traits>
inline void set_range(compound_charset<Traits> &chset, Char from, Char to, Traits const &tr, bool icase)
{
chset.set_range(from, to, tr, icase);
}
template<typename Traits>
inline void set_class(compound_charset<Traits> &chset, typename Traits::char_class_type char_class, bool no, Traits const &)
{
chset.set_class(char_class, no);
}
}}} // namespace boost::xpressive::detail
#endif

View File

@@ -0,0 +1,102 @@
/*=============================================================================
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_XPRESSIVE_SPIRIT_RANGE_RUN_HPP_EAN_10_04_2005
#define BOOST_XPRESSIVE_SPIRIT_RANGE_RUN_HPP_EAN_10_04_2005
///////////////////////////////////////////////////////////////////////////////
#include <vector>
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace xpressive { namespace detail
{
///////////////////////////////////////////////////////////////////////////
//
// range class
//
// Implements a closed range of values. This class is used in
// the implementation of the range_run class.
//
// { Low level implementation detail }
// { Not to be confused with spirit::range }
//
///////////////////////////////////////////////////////////////////////////
template<typename Char>
struct range
{
range(Char first, Char last);
bool is_valid() const;
bool includes(Char v) const;
bool includes(range const &r) const;
bool overlaps(range const &r) const;
void merge(range const &r);
Char first_;
Char last_;
};
//////////////////////////////////
template<typename Char>
struct range_compare
{
bool operator()(range<Char> const &x, range<Char> const &y) const
{
return x.first_ < y.first_;
}
};
///////////////////////////////////////////////////////////////////////////
//
// range_run
//
// An implementation of a sparse bit (boolean) set. The set uses
// a sorted vector of disjoint ranges. This class implements the
// bare minimum essentials from which the full range of set
// operators can be implemented. The set is constructed from
// ranges. Internally, adjacent or overlapping ranges are
// coalesced.
//
// range_runs are very space-economical in situations where there
// are lots of ranges and a few individual disjoint values.
// Searching is O(log n) where n is the number of ranges.
//
// { Low level implementation detail }
//
///////////////////////////////////////////////////////////////////////////
template<typename Char>
struct range_run
{
typedef range<Char> range_type;
typedef std::vector<range_type> run_type;
typedef typename run_type::iterator iterator;
typedef typename run_type::const_iterator const_iterator;
void swap(range_run& rr);
bool empty() const;
bool test(Char v) const;
template<typename Traits>
bool test(Char v, Traits const &tr) const;
void set(range_type const &r);
void clear(range_type const &r);
void clear();
const_iterator begin() const;
const_iterator end() const;
private:
void merge(iterator iter, range_type const &r);
run_type run_;
};
}}} // namespace boost::xpressive::detail
#endif

View File

@@ -0,0 +1,235 @@
/*=============================================================================
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_XPRESSIVE_SPIRIT_RANGE_RUN_IPP
#define BOOST_XPRESSIVE_SPIRIT_RANGE_RUN_IPP
///////////////////////////////////////////////////////////////////////////////
#include <algorithm> // for std::lower_bound
#include <boost/limits.hpp>
#include <boost/assert.hpp>
#include <boost/xpressive/detail/utility/chset/range_run.hpp>
///////////////////////////////////////////////////////////////////////////////
namespace boost { namespace xpressive { namespace detail
{
///////////////////////////////////////////////////////////////////////
//
// range class implementation
//
///////////////////////////////////////////////////////////////////////
template<typename Char>
inline range<Char>::range(Char first, Char last)
: first_(first)
, last_(last)
{
}
//////////////////////////////////
template<typename Char>
inline bool range<Char>::is_valid() const
{
return this->first_ <= this->last_;
}
//////////////////////////////////
template<typename Char>
inline bool range<Char>::includes(range<Char> const &r) const
{
return (this->first_ <= r.first_) && (this->last_ >= r.last_);
}
//////////////////////////////////
template<typename Char>
inline bool range<Char>::includes(Char v) const
{
return (this->first_ <= v) && (this->last_ >= v);
}
//////////////////////////////////
template<typename Char>
inline bool range<Char>::overlaps(range<Char> const &r) const
{
Char decr_first = (std::min)(this->first_, Char(this->first_-1));
Char incr_last = (std::max)(this->last_, Char(this->last_+1));
return (decr_first <= r.last_) && (incr_last >= r.first_);
}
//////////////////////////////////
template<typename Char>
inline void range<Char>::merge(range<Char> const &r)
{
this->first_ = (std::min)(this->first_, r.first_);
this->last_ = (std::max)(this->last_, r.last_);
}
///////////////////////////////////////////////////////////////////////
//
// range_run class implementation
//
///////////////////////////////////////////////////////////////////////
template<typename Char>
inline bool range_run<Char>::empty() const
{
return this->run_.empty();
}
template<typename Char>
inline bool range_run<Char>::test(Char v) const
{
if(this->run_.empty())
{
return false;
}
const_iterator iter = std::lower_bound(
this->run_.begin()
, this->run_.end()
, range<Char>(v, v)
, range_compare<Char>()
);
return (iter != this->run_.end() && iter->includes(v))
|| (iter != this->run_.begin() && (--iter)->includes(v));
}
template<typename Char>
template<typename Traits>
inline bool range_run<Char>::test(Char v, Traits const &tr) const
{
const_iterator begin = this->run_.begin();
const_iterator end = this->run_.end();
for(; begin != end; ++begin)
{
if(tr.in_range_nocase(begin->first_, begin->last_, v))
{
return true;
}
}
return false;
}
//////////////////////////////////
template<typename Char>
inline void range_run<Char>::swap(range_run<Char> &rr)
{
this->run_.swap(rr.run_);
}
//////////////////////////////////
template<typename Char>
void range_run<Char>::merge(iterator iter, range<Char> const &r)
{
BOOST_ASSERT(iter != this->run_.end());
iter->merge(r);
iterator i = iter;
while(++i != this->run_.end() && iter->overlaps(*i))
{
iter->merge(*i);
}
this->run_.erase(++iter, i);
}
//////////////////////////////////
template<typename Char>
void range_run<Char>::set(range<Char> const &r)
{
BOOST_ASSERT(r.is_valid());
if(!this->run_.empty())
{
iterator iter = std::lower_bound(this->run_.begin(), this->run_.end(), r, range_compare<Char>());
if((iter != this->run_.end() && iter->includes(r)) ||
(iter != this->run_.begin() && (iter - 1)->includes(r)))
{
return;
}
else if(iter != this->run_.begin() && (iter - 1)->overlaps(r))
{
this->merge(--iter, r);
}
else if(iter != this->run_.end() && iter->overlaps(r))
{
this->merge(iter, r);
}
else
{
this->run_.insert(iter, r);
}
}
else
{
this->run_.push_back(r);
}
}
//////////////////////////////////
template<typename Char>
void range_run<Char>::clear(range<Char> const &r)
{
BOOST_ASSERT(r.is_valid());
if(!this->run_.empty())
{
iterator iter = std::lower_bound(this->run_.begin(), this->run_.end(), r, range_compare<Char>());
iterator left_iter;
if((iter != this->run_.begin()) &&
(left_iter = (iter - 1))->includes(r.first_))
{
if(left_iter->last_ > r.last_)
{
Char save_last = left_iter->last_;
left_iter->last_ = r.first_-1;
this->run_.insert(iter, range<Char>(r.last_+1, save_last));
return;
}
else
{
left_iter->last_ = r.first_-1;
}
}
iterator i = iter;
for(; i != this->run_.end() && r.includes(*i); ++i) {}
if(i != this->run_.end() && i->includes(r.last_))
{
i->first_ = r.last_+1;
}
this->run_.erase(iter, i);
}
}
//////////////////////////////////
template<typename Char>
inline void range_run<Char>::clear()
{
this->run_.clear();
}
//////////////////////////////////
template<typename Char>
inline typename range_run<Char>::const_iterator range_run<Char>::begin() const
{
return this->run_.begin();
}
//////////////////////////////////
template<typename Char>
inline typename range_run<Char>::const_iterator range_run<Char>::end() const
{
return this->run_.end();
}
}}} // namespace boost::xpressive::detail
#endif