summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-02-13 10:13:40 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-02-13 10:37:59 (GMT)
commit6872dd34f88b08568a4784fe46373a0af0b69165 (patch)
treed14eddb94afbfedb045510ba2d455d110d19b71f /3rdParty/Boost/src/boost/algorithm/string/detail
parentb734b6a5986703b6b10ea548c93af11f9df771bf (diff)
downloadswift-6872dd34f88b08568a4784fe46373a0af0b69165.zip
swift-6872dd34f88b08568a4784fe46373a0af0b69165.tar.bz2
Use boost string algorithms.
Diffstat (limited to '3rdParty/Boost/src/boost/algorithm/string/detail')
-rw-r--r--3rdParty/Boost/src/boost/algorithm/string/detail/classification.hpp353
-rw-r--r--3rdParty/Boost/src/boost/algorithm/string/detail/find_iterator.hpp87
-rw-r--r--3rdParty/Boost/src/boost/algorithm/string/detail/predicate.hpp77
-rw-r--r--3rdParty/Boost/src/boost/algorithm/string/detail/trim.hpp95
4 files changed, 612 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/algorithm/string/detail/classification.hpp b/3rdParty/Boost/src/boost/algorithm/string/detail/classification.hpp
new file mode 100644
index 0000000..fb43955
--- /dev/null
+++ b/3rdParty/Boost/src/boost/algorithm/string/detail/classification.hpp
@@ -0,0 +1,353 @@
+// Boost string_algo library classification.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_CLASSIFICATION_DETAIL_HPP
+#define BOOST_STRING_CLASSIFICATION_DETAIL_HPP
+
+#include <boost/algorithm/string/config.hpp>
+#include <algorithm>
+#include <functional>
+#include <locale>
+
+#include <boost/range/begin.hpp>
+#include <boost/range/end.hpp>
+
+#include <boost/algorithm/string/predicate_facade.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+namespace boost {
+ namespace algorithm {
+ namespace detail {
+
+// classification functors -----------------------------------------------//
+
+ // is_classified functor
+ struct is_classifiedF :
+ public predicate_facade<is_classifiedF>
+ {
+ // Boost.ResultOf support
+ typedef bool result_type;
+
+ // Constructor from a locale
+ is_classifiedF(std::ctype_base::mask Type, std::locale const & Loc = std::locale()) :
+ m_Type(Type), m_Locale(Loc) {}
+ // Operation
+ template<typename CharT>
+ bool operator()( CharT Ch ) const
+ {
+ return std::use_facet< std::ctype<CharT> >(m_Locale).is( m_Type, Ch );
+ }
+
+ #if defined(__BORLANDC__) && (__BORLANDC__ >= 0x560) && (__BORLANDC__ <= 0x582) && !defined(_USE_OLD_RW_STL)
+ template<>
+ bool operator()( char const Ch ) const
+ {
+ return std::use_facet< std::ctype<char> >(m_Locale).is( m_Type, Ch );
+ }
+ #endif
+
+ private:
+ std::ctype_base::mask m_Type;
+ std::locale m_Locale;
+ };
+
+
+ // is_any_of functor
+ /*
+ returns true if the value is from the specified set
+ */
+ template<typename CharT>
+ struct is_any_ofF :
+ public predicate_facade<is_any_ofF<CharT> >
+ {
+ private:
+ // set cannot operate on const value-type
+ typedef typename ::boost::remove_const<CharT>::type set_value_type;
+
+ public:
+ // Boost.ResultOf support
+ typedef bool result_type;
+
+ // Constructor
+ template<typename RangeT>
+ is_any_ofF( const RangeT& Range ) : m_Size(0)
+ {
+ // Prepare storage
+ m_Storage.m_dynSet=0;
+
+ std::size_t Size=::boost::distance(Range);
+ m_Size=Size;
+ set_value_type* Storage=0;
+
+ if(use_fixed_storage(m_Size))
+ {
+ // Use fixed storage
+ Storage=&m_Storage.m_fixSet[0];
+ }
+ else
+ {
+ // Use dynamic storage
+ m_Storage.m_dynSet=new set_value_type[m_Size];
+ Storage=m_Storage.m_dynSet;
+ }
+
+ // Use fixed storage
+ ::std::copy(::boost::begin(Range), ::boost::end(Range), Storage);
+ ::std::sort(Storage, Storage+m_Size);
+ }
+
+ // Copy constructor
+ is_any_ofF(const is_any_ofF& Other) : m_Size(Other.m_Size)
+ {
+ // Prepare storage
+ m_Storage.m_dynSet=0;
+ const set_value_type* SrcStorage=0;
+ set_value_type* DestStorage=0;
+
+ if(use_fixed_storage(m_Size))
+ {
+ // Use fixed storage
+ DestStorage=&m_Storage.m_fixSet[0];
+ SrcStorage=&Other.m_Storage.m_fixSet[0];
+ }
+ else
+ {
+ // Use dynamic storage
+ m_Storage.m_dynSet=new set_value_type[m_Size];
+ DestStorage=m_Storage.m_dynSet;
+ SrcStorage=Other.m_Storage.m_dynSet;
+ }
+
+ // Use fixed storage
+ ::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size);
+ }
+
+ // Destructor
+ ~is_any_ofF()
+ {
+ if(!use_fixed_storage(m_Size) && m_Storage.m_dynSet!=0)
+ {
+ delete [] m_Storage.m_dynSet;
+ }
+ }
+
+ // Assignment
+ is_any_ofF& operator=(const is_any_ofF& Other)
+ {
+ // Handle self assignment
+ if(this==&Other) return *this;
+
+ // Prepare storage
+ const set_value_type* SrcStorage;
+ set_value_type* DestStorage;
+
+ if(use_fixed_storage(Other.m_Size))
+ {
+ // Use fixed storage
+ DestStorage=&m_Storage.m_fixSet[0];
+ SrcStorage=&Other.m_Storage.m_fixSet[0];
+
+ // Delete old storage if was present
+ if(!use_fixed_storage(m_Size) && m_Storage.m_dynSet!=0)
+ {
+ delete [] m_Storage.m_dynSet;
+ }
+
+ // Set new size
+ m_Size=Other.m_Size;
+ }
+ else
+ {
+ // Other uses dynamic storage
+ SrcStorage=Other.m_Storage.m_dynSet;
+
+ // Check what kind of storage are we using right now
+ if(use_fixed_storage(m_Size))
+ {
+ // Using fixed storage, allocate new
+ set_value_type* pTemp=new set_value_type[Other.m_Size];
+ DestStorage=pTemp;
+ m_Storage.m_dynSet=pTemp;
+ m_Size=Other.m_Size;
+ }
+ else
+ {
+ // Using dynamic storage, check if can reuse
+ if(m_Storage.m_dynSet!=0 && m_Size>=Other.m_Size && m_Size<Other.m_Size*2)
+ {
+ // Reuse the current storage
+ DestStorage=m_Storage.m_dynSet;
+ m_Size=Other.m_Size;
+ }
+ else
+ {
+ // Allocate the new one
+ set_value_type* pTemp=new set_value_type[Other.m_Size];
+ DestStorage=pTemp;
+
+ // Delete old storage if necessary
+ if(m_Storage.m_dynSet!=0)
+ {
+ delete [] m_Storage.m_dynSet;
+ }
+ // Store the new storage
+ m_Storage.m_dynSet=pTemp;
+ // Set new size
+ m_Size=Other.m_Size;
+ }
+ }
+ }
+
+ // Copy the data
+ ::memcpy(DestStorage, SrcStorage, sizeof(set_value_type)*m_Size);
+
+ return *this;
+ }
+
+ // Operation
+ template<typename Char2T>
+ bool operator()( Char2T Ch ) const
+ {
+ const set_value_type* Storage=
+ (use_fixed_storage(m_Size))
+ ? &m_Storage.m_fixSet[0]
+ : m_Storage.m_dynSet;
+
+ return ::std::binary_search(Storage, Storage+m_Size, Ch);
+ }
+ private:
+ // check if the size is eligible for fixed storage
+ static bool use_fixed_storage(std::size_t size)
+ {
+ return size<=sizeof(set_value_type*)*2;
+ }
+
+
+ private:
+ // storage
+ // The actual used storage is selected on the type
+ union
+ {
+ set_value_type* m_dynSet;
+ set_value_type m_fixSet[sizeof(set_value_type*)*2];
+ }
+ m_Storage;
+
+ // storage size
+ ::std::size_t m_Size;
+ };
+
+ // is_from_range functor
+ /*
+ returns true if the value is from the specified range.
+ (i.e. x>=From && x>=To)
+ */
+ template<typename CharT>
+ struct is_from_rangeF :
+ public predicate_facade< is_from_rangeF<CharT> >
+ {
+ // Boost.ResultOf support
+ typedef bool result_type;
+
+ // Constructor
+ is_from_rangeF( CharT From, CharT To ) : m_From(From), m_To(To) {}
+
+ // Operation
+ template<typename Char2T>
+ bool operator()( Char2T Ch ) const
+ {
+ return ( m_From <= Ch ) && ( Ch <= m_To );
+ }
+
+ private:
+ CharT m_From;
+ CharT m_To;
+ };
+
+ // class_and composition predicate
+ template<typename Pred1T, typename Pred2T>
+ struct pred_andF :
+ public predicate_facade< pred_andF<Pred1T,Pred2T> >
+ {
+ public:
+
+ // Boost.ResultOf support
+ typedef bool result_type;
+
+ // Constructor
+ pred_andF( Pred1T Pred1, Pred2T Pred2 ) :
+ m_Pred1(Pred1), m_Pred2(Pred2) {}
+
+ // Operation
+ template<typename CharT>
+ bool operator()( CharT Ch ) const
+ {
+ return m_Pred1(Ch) && m_Pred2(Ch);
+ }
+
+ private:
+ Pred1T m_Pred1;
+ Pred2T m_Pred2;
+ };
+
+ // class_or composition predicate
+ template<typename Pred1T, typename Pred2T>
+ struct pred_orF :
+ public predicate_facade< pred_orF<Pred1T,Pred2T> >
+ {
+ public:
+ // Boost.ResultOf support
+ typedef bool result_type;
+
+ // Constructor
+ pred_orF( Pred1T Pred1, Pred2T Pred2 ) :
+ m_Pred1(Pred1), m_Pred2(Pred2) {}
+
+ // Operation
+ template<typename CharT>
+ bool operator()( CharT Ch ) const
+ {
+ return m_Pred1(Ch) || m_Pred2(Ch);
+ }
+
+ private:
+ Pred1T m_Pred1;
+ Pred2T m_Pred2;
+ };
+
+ // class_not composition predicate
+ template< typename PredT >
+ struct pred_notF :
+ public predicate_facade< pred_notF<PredT> >
+ {
+ public:
+ // Boost.ResultOf support
+ typedef bool result_type;
+
+ // Constructor
+ pred_notF( PredT Pred ) : m_Pred(Pred) {}
+
+ // Operation
+ template<typename CharT>
+ bool operator()( CharT Ch ) const
+ {
+ return !m_Pred(Ch);
+ }
+
+ private:
+ PredT m_Pred;
+ };
+
+ } // namespace detail
+ } // namespace algorithm
+} // namespace boost
+
+
+#endif // BOOST_STRING_CLASSIFICATION_DETAIL_HPP
diff --git a/3rdParty/Boost/src/boost/algorithm/string/detail/find_iterator.hpp b/3rdParty/Boost/src/boost/algorithm/string/detail/find_iterator.hpp
new file mode 100644
index 0000000..c76993a
--- /dev/null
+++ b/3rdParty/Boost/src/boost/algorithm/string/detail/find_iterator.hpp
@@ -0,0 +1,87 @@
+// Boost string_algo library find_iterator.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
+#define BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
+
+#include <boost/algorithm/string/config.hpp>
+#include <boost/range/iterator_range.hpp>
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/function.hpp>
+
+namespace boost {
+ namespace algorithm {
+ namespace detail {
+
+// find_iterator base -----------------------------------------------//
+
+ // Find iterator base
+ template<typename IteratorT>
+ class find_iterator_base
+ {
+ protected:
+ // typedefs
+ typedef IteratorT input_iterator_type;
+ typedef iterator_range<IteratorT> match_type;
+ typedef function2<
+ match_type,
+ input_iterator_type,
+ input_iterator_type> finder_type;
+
+ protected:
+ // Protected construction/destruction
+
+ // Default constructor
+ find_iterator_base() {};
+ // Copy construction
+ find_iterator_base( const find_iterator_base& Other ) :
+ m_Finder(Other.m_Finder) {}
+
+ // Constructor
+ template<typename FinderT>
+ find_iterator_base( FinderT Finder, int ) :
+ m_Finder(Finder) {}
+
+ // Destructor
+ ~find_iterator_base() {}
+
+ // Find operation
+ match_type do_find(
+ input_iterator_type Begin,
+ input_iterator_type End ) const
+ {
+ if (!m_Finder.empty())
+ {
+ return m_Finder(Begin,End);
+ }
+ else
+ {
+ return match_type(End,End);
+ }
+ }
+
+ // Check
+ bool is_null() const
+ {
+ return m_Finder.empty();
+ }
+
+ private:
+ // Finder
+ finder_type m_Finder;
+ };
+
+ } // namespace detail
+ } // namespace algorithm
+} // namespace boost
+
+
+#endif // BOOST_STRING_FIND_ITERATOR_DETAIL_HPP
diff --git a/3rdParty/Boost/src/boost/algorithm/string/detail/predicate.hpp b/3rdParty/Boost/src/boost/algorithm/string/detail/predicate.hpp
new file mode 100644
index 0000000..5acf3cc
--- /dev/null
+++ b/3rdParty/Boost/src/boost/algorithm/string/detail/predicate.hpp
@@ -0,0 +1,77 @@
+// Boost string_algo library predicate.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_PREDICATE_DETAIL_HPP
+#define BOOST_STRING_PREDICATE_DETAIL_HPP
+
+#include <iterator>
+#include <boost/algorithm/string/find.hpp>
+
+namespace boost {
+ namespace algorithm {
+ namespace detail {
+
+// ends_with predicate implementation ----------------------------------//
+
+ template<
+ typename ForwardIterator1T,
+ typename ForwardIterator2T,
+ typename PredicateT>
+ inline bool ends_with_iter_select(
+ ForwardIterator1T Begin,
+ ForwardIterator1T End,
+ ForwardIterator2T SubBegin,
+ ForwardIterator2T SubEnd,
+ PredicateT Comp,
+ std::bidirectional_iterator_tag)
+ {
+ ForwardIterator1T it=End;
+ ForwardIterator2T pit=SubEnd;
+ for(;it!=Begin && pit!=SubBegin;)
+ {
+ if( !(Comp(*(--it),*(--pit))) )
+ return false;
+ }
+
+ return pit==SubBegin;
+ }
+
+ template<
+ typename ForwardIterator1T,
+ typename ForwardIterator2T,
+ typename PredicateT>
+ inline bool ends_with_iter_select(
+ ForwardIterator1T Begin,
+ ForwardIterator1T End,
+ ForwardIterator2T SubBegin,
+ ForwardIterator2T SubEnd,
+ PredicateT Comp,
+ std::forward_iterator_tag)
+ {
+ if ( SubBegin==SubEnd )
+ {
+ // empty subsequence check
+ return true;
+ }
+
+ iterator_range<ForwardIterator1T> Result
+ =last_finder(
+ ::boost::make_iterator_range(SubBegin, SubEnd),
+ Comp)(Begin, End);
+
+ return !Result.empty() && Result.end()==End;
+ }
+
+ } // namespace detail
+ } // namespace algorithm
+} // namespace boost
+
+
+#endif // BOOST_STRING_PREDICATE_DETAIL_HPP
diff --git a/3rdParty/Boost/src/boost/algorithm/string/detail/trim.hpp b/3rdParty/Boost/src/boost/algorithm/string/detail/trim.hpp
new file mode 100644
index 0000000..1233e49
--- /dev/null
+++ b/3rdParty/Boost/src/boost/algorithm/string/detail/trim.hpp
@@ -0,0 +1,95 @@
+// Boost string_algo library trim.hpp header file ---------------------------//
+
+// Copyright Pavol Droba 2002-2003.
+//
+// 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)
+
+// See http://www.boost.org/ for updates, documentation, and revision history.
+
+#ifndef BOOST_STRING_TRIM_DETAIL_HPP
+#define BOOST_STRING_TRIM_DETAIL_HPP
+
+#include <boost/algorithm/string/config.hpp>
+#include <boost/detail/iterator.hpp>
+
+namespace boost {
+ namespace algorithm {
+ namespace detail {
+
+// trim iterator helper -----------------------------------------------//
+
+ template< typename ForwardIteratorT, typename PredicateT >
+ inline ForwardIteratorT trim_end_iter_select(
+ ForwardIteratorT InBegin,
+ ForwardIteratorT InEnd,
+ PredicateT IsSpace,
+ std::forward_iterator_tag )
+ {
+ ForwardIteratorT TrimIt=InBegin;
+
+ for( ForwardIteratorT It=InBegin; It!=InEnd; ++It )
+ {
+ if ( !IsSpace(*It) )
+ {
+ TrimIt=It;
+ ++TrimIt;
+ }
+ }
+
+ return TrimIt;
+ }
+
+ template< typename ForwardIteratorT, typename PredicateT >
+ inline ForwardIteratorT trim_end_iter_select(
+ ForwardIteratorT InBegin,
+ ForwardIteratorT InEnd,
+ PredicateT IsSpace,
+ std::bidirectional_iterator_tag )
+ {
+ for( ForwardIteratorT It=InEnd; It!=InBegin; )
+ {
+ if ( !IsSpace(*(--It)) )
+ return ++It;
+ }
+
+ return InBegin;
+ }
+ // Search for first non matching character from the beginning of the sequence
+ template< typename ForwardIteratorT, typename PredicateT >
+ inline ForwardIteratorT trim_begin(
+ ForwardIteratorT InBegin,
+ ForwardIteratorT InEnd,
+ PredicateT IsSpace )
+ {
+ ForwardIteratorT It=InBegin;
+ for(; It!=InEnd; ++It )
+ {
+ if (!IsSpace(*It))
+ return It;
+ }
+
+ return It;
+ }
+
+ // Search for first non matching character from the end of the sequence
+ template< typename ForwardIteratorT, typename PredicateT >
+ inline ForwardIteratorT trim_end(
+ ForwardIteratorT InBegin,
+ ForwardIteratorT InEnd,
+ PredicateT IsSpace )
+ {
+ typedef BOOST_STRING_TYPENAME boost::detail::
+ iterator_traits<ForwardIteratorT>::iterator_category category;
+
+ return ::boost::algorithm::detail::trim_end_iter_select( InBegin, InEnd, IsSpace, category() );
+ }
+
+
+ } // namespace detail
+ } // namespace algorithm
+} // namespace boost
+
+
+#endif // BOOST_STRING_TRIM_DETAIL_HPP