add boost on mac

This commit is contained in:
Bassem Girgis
2019-08-10 16:38:17 -05:00
parent 861b918727
commit be945cb63b
14105 changed files with 2714968 additions and 0 deletions

View File

@@ -0,0 +1,249 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
Copyright (c) 2001-2009 Daniel Nuffer
http://spirit.sourceforge.net/
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_SPIRIT_BASIC_CHSET_APRIL_17_2008
#define BOOST_SPIRIT_BASIC_CHSET_APRIL_17_2008
#if defined(_MSC_VER)
#pragma once
#endif
///////////////////////////////////////////////////////////////////////////////
#include <bitset>
#include <climits>
#include <boost/spirit/home/support/char_set/range_run.hpp>
namespace boost { namespace spirit { namespace support { 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_)
: rr(arg_.rr) {}
bool
test(Char v) const
{
return rr.test(v);
}
void
set(Char from, Char to)
{
rr.set(range<Char>(from, to));
}
void
set(Char c)
{
rr.set(range<Char>(c, c));
}
void
clear(Char from, Char to)
{
rr.clear(range<Char>(from, to));
}
void
clear(Char c)
{
rr.clear(range<Char>(c, c));
}
void
clear()
{
rr.clear();
}
void
inverse()
{
basic_chset inv;
inv.set(
(std::numeric_limits<Char>::min)(),
(std::numeric_limits<Char>::max)()
);
inv -= *this;
swap(inv);
}
void
swap(basic_chset& x)
{
rr.swap(x.rr);
}
basic_chset&
operator|=(basic_chset const& x)
{
typedef typename range_run<Char>::const_iterator const_iterator;
for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter)
rr.set(*iter);
return *this;
}
basic_chset&
operator&=(basic_chset const& x)
{
basic_chset inv;
inv.set(
(std::numeric_limits<Char>::min)(),
(std::numeric_limits<Char>::max)()
);
inv -= x;
*this -= inv;
return *this;
}
basic_chset&
operator-=(basic_chset const& x)
{
typedef typename range_run<Char>::const_iterator const_iterator;
for (const_iterator iter = x.rr.begin(); iter != x.rr.end(); ++iter)
rr.clear(*iter);
return *this;
}
basic_chset&
operator^=(basic_chset const& x)
{
basic_chset bma = x;
bma -= *this;
*this -= x;
*this |= bma;
return *this;
}
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_)
: bset(arg_.bset) {}
bool
test(Char v) const
{
return bset.test((unsigned char)v);
}
void
set(Char from, Char to)
{
for (int i = from; i <= to; ++i)
bset.set((unsigned char)i);
}
void
set(Char c)
{
bset.set((unsigned char)c);
}
void
clear(Char from, Char to)
{
for (int i = from; i <= to; ++i)
bset.reset((unsigned char)i);
}
void
clear(Char c)
{
bset.reset((unsigned char)c);
}
void
clear()
{
bset.reset();
}
void
inverse()
{
bset.flip();
}
void
swap(basic_chset_8bit& x)
{
std::swap(bset, x.bset);
}
basic_chset_8bit&
operator|=(basic_chset_8bit const& x)
{
bset |= x.bset;
return *this;
}
basic_chset_8bit&
operator&=(basic_chset_8bit const& x)
{
bset &= x.bset;
return *this;
}
basic_chset_8bit&
operator-=(basic_chset_8bit const& x)
{
bset &= ~x.bset;
return *this;
}
basic_chset_8bit&
operator^=(basic_chset_8bit const& x)
{
bset ^= x.bset;
return *this;
}
private: std::bitset<256> bset;
};
/////////////////////////////////
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 // #if (CHAR_BIT == 8)
}}}}
#endif

View File

@@ -0,0 +1,32 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
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)
==============================================================================*/
#if !defined(BOOST_SPIRIT_RANGE_MAY_16_2006_0720_PM)
#define BOOST_SPIRIT_RANGE_MAY_16_2006_0720_PM
#if defined(_MSC_VER)
#pragma once
#endif
namespace boost { namespace spirit { namespace support { namespace detail
{
///////////////////////////////////////////////////////////////////////////
// A closed range (first, last)
///////////////////////////////////////////////////////////////////////////
template <typename T>
struct range
{
typedef T value_type;
range() : first(), last() {}
range(T first_, T last_) : first(first_), last(last_) {}
T first;
T last;
};
}}}}
#endif

View File

@@ -0,0 +1,98 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
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)
==============================================================================*/
#if !defined(BOOST_SPIRIT_RANGE_FUNCTIONS_MAY_16_2006_0720_PM)
#define BOOST_SPIRIT_RANGE_FUNCTIONS_MAY_16_2006_0720_PM
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/integer_traits.hpp>
namespace boost { namespace spirit { namespace support { namespace detail
{
template <typename Range>
inline bool
is_valid(Range const& range)
{
// test for valid ranges
return range.first <= range.last;
}
template <typename Range>
inline bool
includes(Range const& range, Range const& other)
{
// see if two ranges intersect
return (range.first <= other.first) && (range.last >= other.last);
}
template <typename Range>
inline bool
includes(Range const& range, typename Range::value_type val)
{
// see if val is in range
return (range.first <= val) && (range.last >= val);
}
template <typename Range>
inline bool
can_merge(Range const& range, Range const& other)
{
// see if a 'range' overlaps, or is adjacent to
// another range 'other', so we can merge them
typedef typename Range::value_type value_type;
typedef integer_traits<value_type> integer_traits;
value_type decr_first =
range.first == integer_traits::const_min
? range.first : range.first-1;
value_type incr_last =
range.last == integer_traits::const_max
? range.last : range.last+1;
return (decr_first <= other.last) && (incr_last >= other.first);
}
template <typename Range>
inline void
merge(Range& result, Range const& other)
{
// merge two ranges
if (result.first > other.first)
result.first = other.first;
if (result.last < other.last)
result.last = other.last;
}
template <typename Range>
struct range_compare
{
// compare functor with a value or another range
typedef typename Range::value_type value_type;
bool operator()(Range const& x, const value_type y) const
{
return x.first < y;
}
bool operator()(value_type const x, Range const& y) const
{
return x < y.first;
}
bool operator()(Range const& x, Range const& y) const
{
return x.first < y.first;
}
};
}}}}
#endif

View File

@@ -0,0 +1,56 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
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)
==============================================================================*/
#if !defined(BOOST_SPIRIT_RANGE_RUN_MAY_16_2006_0801_PM)
#define BOOST_SPIRIT_RANGE_RUN_MAY_16_2006_0801_PM
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/spirit/home/support/char_set/range.hpp>
#include <vector>
namespace boost { namespace spirit { namespace support { namespace detail
{
///////////////////////////////////////////////////////////////////////////
// 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 interface }
///////////////////////////////////////////////////////////////////////////
template <typename Char>
class range_run
{
public:
typedef range<Char> range_type;
typedef std::vector<range_type> storage_type;
void swap(range_run& other);
bool test(Char v) const;
void set(range_type const& range);
void clear(range_type const& range);
void clear();
private:
storage_type run;
};
}}}}
#include <boost/spirit/home/support/char_set/range_run_impl.hpp>
#endif

View File

@@ -0,0 +1,185 @@
/*=============================================================================
Copyright (c) 2001-2011 Joel de Guzman
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)
==============================================================================*/
#if !defined(BOOST_SPIRIT_RANGE_RUN_MAY_16_2006_0807_PM)
#define BOOST_SPIRIT_RANGE_RUN_MAY_16_2006_0807_PM
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/spirit/home/support/char_set/range_functions.hpp>
#include <boost/assert.hpp>
#include <algorithm>
namespace boost { namespace spirit { namespace support { namespace detail
{
template <typename Run, typename Iterator, typename Range>
inline bool
try_merge(Run& run, Iterator iter, Range const& range)
{
// if *iter intersects with, or is adjacent to, 'range'...
if (can_merge(*iter, range))
{
// merge range and *iter
merge(*iter, range);
// collapse all subsequent ranges that can merge with *iter:
Iterator i = iter+1;
// 1. skip subsequent ranges completely included in *iter
while (i != run.end() && i->last <= iter->last)
++i;
// 2. collapse next range if adjacent or overlapping with *iter
if (i != run.end() && i->first-1 <= iter->last)
{
iter->last = i->last;
++i;
}
// erase all ranges that were collapsed
run.erase(iter+1, i);
return true;
}
return false;
}
template <typename Char>
inline bool
range_run<Char>::test(Char val) const
{
if (run.empty())
return false;
// search the ranges for one that potentially includes val
typename storage_type::const_iterator iter =
std::upper_bound(
run.begin(), run.end(), val,
range_compare<range_type>()
);
// return true if *(iter-1) includes val
return iter != run.begin() && includes(*(--iter), val);
}
template <typename Char>
inline void
range_run<Char>::swap(range_run& other)
{
run.swap(other.run);
}
template <typename Char>
void
range_run<Char>::set(range_type const& range)
{
BOOST_ASSERT(is_valid(range));
if (run.empty())
{
// the vector is empty, insert 'range'
run.push_back(range);
return;
}
// search the ranges for one that potentially includes 'range'
typename storage_type::iterator iter =
std::upper_bound(
run.begin(), run.end(), range,
range_compare<range_type>()
);
if (iter != run.begin())
{
// if *(iter-1) includes 'range', return early
if (includes(*(iter-1), range))
{
return;
}
// if *(iter-1) can merge with 'range', merge them and return
if (try_merge(run, iter-1, range))
{
return;
}
}
// if *iter can merge with with 'range', merge them
if (iter == run.end() || !try_merge(run, iter, range))
{
// no overlap, insert 'range'
run.insert(iter, range);
}
}
template <typename Char>
void
range_run<Char>::clear(range_type const& range)
{
BOOST_ASSERT(is_valid(range));
if (!run.empty())
{
// search the ranges for one that potentially includes 'range'
typename storage_type::iterator iter =
std::upper_bound(
run.begin(), run.end(), range,
range_compare<range_type>()
);
// 'range' starts with or after another range:
if (iter != run.begin())
{
typename storage_type::iterator const left_iter = iter-1;
// 'range' starts after '*left_iter':
if (left_iter->first < range.first)
{
// if 'range' is completely included inside '*left_iter':
// need to break it apart into two ranges (punch a hole),
if (left_iter->last > range.last)
{
Char save_last = left_iter->last;
left_iter->last = range.first-1;
run.insert(iter, range_type(range.last+1, save_last));
return;
}
// if 'range' contains 'left_iter->last':
// truncate '*left_iter' (clip its right)
else if (left_iter->last >= range.first)
{
left_iter->last = range.first-1;
}
}
// 'range' has the same left bound as '*left_iter': it
// must be removed or truncated by the code below
else
{
iter = left_iter;
}
}
// remove or truncate subsequent ranges that overlap with 'range':
typename storage_type::iterator i = iter;
// 1. skip subsequent ranges completely included in 'range'
while (i != run.end() && i->last <= range.last)
++i;
// 2. clip left of next range if overlapping with 'range'
if (i != run.end() && i->first <= range.last)
i->first = range.last+1;
// erase all ranges that 'range' contained
run.erase(iter, i);
}
}
template <typename Char>
inline void
range_run<Char>::clear()
{
run.clear();
}
}}}}
#endif