Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55273 - in sandbox/SOC/2009/unicode: boost/detail boost/iterator boost/iterator/detail boost/range boost/unicode libs/unicode/doc libs/unicode/doc/src libs/unicode/doc/src/images libs/unicode/doc/src/images/callouts libs/unicode/example libs/unicode/src
From: loufoque_at_[hidden]
Date: 2009-07-30 14:45:03


Author: mgaunard
Date: 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
New Revision: 55273
URL: http://svn.boost.org/trac/boost/changeset/55273

Log:
Examples and various fixes
Added:
   sandbox/SOC/2009/unicode/boost/detail/
   sandbox/SOC/2009/unicode/boost/detail/unspecified.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/iterator/any_iterator.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/iterator/detail/
   sandbox/SOC/2009/unicode/boost/iterator/detail/any_iterator_abstract_base.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/iterator/detail/any_iterator_metafunctions.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/iterator/detail/any_iterator_wrapper.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/range/any_range.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/unicode/search.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/alert.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/blank.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/1.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/10.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/11.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/12.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/13.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/14.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/15.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/2.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/3.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/4.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/5.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/6.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/7.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/8.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/9.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/caution.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/draft.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/home.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/important.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/next.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/next_disabled.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/note.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/prev.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/prev_disabled.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/tip.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/toc-blank.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/toc-minus.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/toc-plus.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/up.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/up_disabled.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/warning.png (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/example/characters.cpp (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/example/compose.cpp (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/example/convert.cpp (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/example/search.cpp (contents, props changed)
   sandbox/SOC/2009/unicode/libs/unicode/example/source_input.cpp (contents, props changed)
Removed:
   sandbox/SOC/2009/unicode/libs/unicode/example/test.cpp
   sandbox/SOC/2009/unicode/libs/unicode/src/Jamfile.v2
Text files modified:
   sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator.hpp | 17 +++++++++++++++++
   sandbox/SOC/2009/unicode/boost/unicode/compose.hpp | 10 ++++++++--
   sandbox/SOC/2009/unicode/boost/unicode/graphemes.hpp | 20 ++++++++++++++------
   sandbox/SOC/2009/unicode/boost/unicode/static_utf.hpp | 6 ++++++
   sandbox/SOC/2009/unicode/boost/unicode/utf.hpp | 23 ++++++++++++-----------
   sandbox/SOC/2009/unicode/boost/unicode/utf_codecs.hpp | 30 +++++++++++++-----------------
   sandbox/SOC/2009/unicode/libs/unicode/doc/Jamfile.v2 | 3 ++-
   sandbox/SOC/2009/unicode/libs/unicode/doc/users_manual.qbk | 31 ++++++++++++++++++++++++++++---
   sandbox/SOC/2009/unicode/libs/unicode/example/Jamfile.v2 | 6 +++++-
   9 files changed, 105 insertions(+), 41 deletions(-)

Added: sandbox/SOC/2009/unicode/boost/detail/unspecified.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/detail/unspecified.hpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -0,0 +1,16 @@
+#ifndef BOOST_DETAIL_UNSPECIFIED_HPP
+#define BOOST_DETAIL_UNSPECIFIED_HPP
+
+namespace boost
+{
+ namespace detail
+ {
+ template<typename T>
+ struct unspecified
+ {
+ typedef T type;
+ };
+ }
+}
+
+#endif

Added: sandbox/SOC/2009/unicode/boost/iterator/any_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/iterator/any_iterator.hpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -0,0 +1,422 @@
+// (C) Copyright Thomas Becker 2005. Permission to copy, use, modify, sell and
+// distribute this software is granted provided this copyright notice appears
+// in all copies. This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+
+// Revision History
+// ================
+//
+// 27 Dec 2006 (Thomas Becker) Created
+
+#ifndef ANY_ITERATOR_01102007TMB_HPP
+#define ANY_ITERATOR_01102007TMB_HPP
+
+// Includes
+// ========
+
+#include "detail/any_iterator_abstract_base.hpp"
+#include "detail/any_iterator_wrapper.hpp"
+#include "detail/any_iterator_metafunctions.hpp"
+#include <boost/iterator/iterator_facade.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/static_assert.hpp>
+
+namespace boost
+{
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ // The any_iterator is modeled after the "type erasure pattern" as set
+ // forth in boost::any. The class names correspond as follows:
+ //
+ // boost::any ==> any_iterator
+ // boost::any::placeholder ==> any_iterator_abstract_base
+ // boost::any::holder ==> any_iterator_wrapper
+ //
+ template<
+ class Value,
+ class CategoryOrTraversal,
+ class Reference = Value&,
+ class Difference = std::ptrdiff_t
+ >
+ class any_iterator :
+ public boost::iterator_facade<
+ any_iterator<
+ Value,
+ CategoryOrTraversal,
+ Reference,
+ Difference
+ >,
+ Value,
+ CategoryOrTraversal,
+ Reference,
+ Difference
+ >
+ {
+
+ // We make every other any_iterator our friend. This is needed only for
+ // the conversion from non-const to const, but there should be no harm
+ // in being overly friendly here.
+ template<
+ class OtherValue,
+ class OtherCategoryOrTraversal,
+ class OtherReference,
+ class OtherDifference
+ >
+ friend class any_iterator;
+
+ public:
+ typedef typename boost::iterator_category_to_traversal<CategoryOrTraversal>::type Traversal;
+
+ private:
+
+ struct enabler{}; // a private type avoids misuse
+ struct disabler{}; // a private type avoids misuse
+
+ // The type-erasing abstract base class, that is, the type that the
+ // impl-pointer points to.
+ typedef
+ detail::any_iterator_abstract_base<
+ Value,
+ Traversal,
+ Reference,
+ Difference
+ > abstract_base_type;
+
+ typedef
+ boost::iterator_facade<
+ any_iterator<
+ Value,
+ CategoryOrTraversal,
+ Reference,
+ Difference
+ >,
+ Value,
+ CategoryOrTraversal,
+ Reference,
+ Difference
+ > super_type;
+
+ // The two types that this any_iterator type recognizes as const versions of
+ // itself.
+ typedef any_iterator<
+ typename boost::add_const<Value>::type,
+ CategoryOrTraversal,
+ typename detail::make_iterator_reference_const<Reference>::type,
+ Difference
+ > const_type_with_const_value_type;
+ //
+ typedef any_iterator<
+ typename boost::remove_const<Value>::type,
+ CategoryOrTraversal,
+ typename detail::make_iterator_reference_const<Reference>::type,
+ Difference
+ > const_type_with_non_const_value_type;
+
+ public:
+
+ any_iterator() : m_pointer_to_impl(NULL)
+ {}
+
+ any_iterator(any_iterator const & rhs) : super_type(rhs)
+ {
+ if( rhs.m_pointer_to_impl )
+ {
+ m_pointer_to_impl = rhs.m_pointer_to_impl->clone();
+ }
+ else
+ {
+ m_pointer_to_impl = NULL;
+ }
+ }
+
+ any_iterator& operator=(any_iterator const & rhs)
+ {
+ if(this != &rhs)
+ {
+ any_iterator tmp(rhs);
+ swap(tmp);
+ }
+
+ return *this;
+ }
+
+ // Constructor from wrapped iterator. The static assert defines the
+ // granularity of the type erasure.
+ //
+ // NOTE 1: If you want to make the constructor non-explicit, then you
+ // really must replace the static assert with an enable_if, or else
+ // metafunctions such as is_convertible will say the wrong thing.
+ // However, if you use enable_if here, you'll descend into the ugly
+ // mess described in the last section of my article at
+ // http://www.artima.com/cppsource/type_erasure.html.
+ //
+ // NOTE 2: If you remove the restriction that the wrapped iterator
+ // cannot be an any_iterator, you must ensure that the conversions from
+ // non-const to const any_iterators still work correctly. If you don't
+ // do anything, you will end up with wrapping instead of conversion.
+ //
+ template<class WrappedIterator>
+ explicit any_iterator(
+ WrappedIterator const & wrapped_iterator,
+ typename boost::disable_if<
+ detail::is_any_iterator<WrappedIterator>,
+ disabler
+ >::type = disabler()
+ )
+ {
+ //////////////////////////////////////////////////////////////////
+ //
+ // *** Message to Client ***
+ //
+ // If this static assert fires, you are trying to construct the any_iterator
+ // from a concrete iterator that is not suitable for the type erasure that
+ // the any_iterator provides.
+ //
+ BOOST_STATIC_ASSERT((detail::is_iterator_type_erasure_compatible<WrappedIterator, any_iterator>::type::value));
+
+ typedef
+ detail::any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ Traversal,
+ Reference,
+ Difference
+ > wrapper_type;
+
+ m_pointer_to_impl = wrapper_type::create(wrapped_iterator);
+ }
+
+ // Assignment from wrapped iterator. The enable_if condition defines
+ // the granularity of the type erasure.
+ //
+ // NOTE: If you remove the restriction that the wrapped iterator
+ // cannot be an any_iterator, you must ensure that the conversions from
+ // non-const to const any_iterators still work correctly. If you don't
+ // do anything, you will end up with wrapping instead of conversion.
+ template<class WrappedIterator>
+ typename boost::enable_if<
+ boost::mpl::and_<
+ detail::is_iterator_type_erasure_compatible<WrappedIterator, any_iterator>,
+ boost::mpl::not_<detail::is_any_iterator<WrappedIterator> >
+ >,
+ any_iterator
+ >::type &
+ operator=(WrappedIterator const & wrapped_iterator)
+ {
+ any_iterator tmp(wrapped_iterator);
+ swap(tmp);
+ return *this;
+ }
+
+ // Conversion from non-const to const any_iterator. There are two versions.
+ // This first one applies if the target has const value type.
+ operator const_type_with_const_value_type () const
+ {
+ const_type_with_const_value_type conversion_result;
+ if( m_pointer_to_impl )
+ {
+ conversion_result.m_pointer_to_impl = m_pointer_to_impl->make_const_clone_with_const_value_type();
+ }
+ return conversion_result;
+ }
+
+ // Conversion from non-const to const any_iterator. There are two versions.
+ // This second one applies if the target has non-const value type.
+ operator const_type_with_non_const_value_type () const
+ {
+ const_type_with_non_const_value_type conversion_result;
+ if( m_pointer_to_impl )
+ {
+ conversion_result.m_pointer_to_impl = m_pointer_to_impl->make_const_clone_with_non_const_value_type();
+ }
+ return conversion_result;
+ }
+
+ // Conversion to weaker traversal type
+ template<typename TargetTraversal>
+ operator any_iterator<
+ Value,
+ TargetTraversal,
+ Reference,
+ Difference
+ >
+ () const
+ {
+ //////////////////////////////////////////////////////////////////
+ //
+ // *** Message to Client ***
+ //
+ // If this static assert fires, you are trying to convert between two
+ // any_iterator types that are not suitable for conversion.
+ //
+ BOOST_STATIC_ASSERT((
+ boost::is_base_of<
+ typename boost::iterator_category_to_traversal<TargetTraversal>::type,
+ typename boost::iterator_category_to_traversal<CategoryOrTraversal>::type
+ >::type::value
+ ));
+
+ any_iterator<
+ Value,
+ TargetTraversal,
+ Reference,
+ Difference
+ > conversion_result;
+
+ if( m_pointer_to_impl )
+ {
+ typename boost::iterator_category_to_traversal<TargetTraversal>::type* funcSelector = NULL;
+ conversion_result.m_pointer_to_impl = make_traversal_converted_version(funcSelector);
+ }
+ return conversion_result;
+ }
+
+ ~any_iterator()
+ {
+ delete m_pointer_to_impl;
+ }
+
+ private:
+
+ friend class boost::iterator_core_access;
+
+ Reference dereference() const
+ {
+ return m_pointer_to_impl->dereference();
+ }
+
+ bool equal(any_iterator const & rhs) const
+ {
+ if( m_pointer_to_impl == rhs.m_pointer_to_impl )
+ {
+ return true;
+ }
+
+ if( m_pointer_to_impl == NULL || rhs.m_pointer_to_impl == NULL )
+ {
+ return false;
+ }
+
+ //////////////////////////////////////////////////////////////////
+ //
+ // *** Message to Client ***
+ //
+ // If the next line does not compile, you are trying to compare
+ // two iterators for equality whose categories do not allow that
+ // comparison.
+ return m_pointer_to_impl->equal(*(rhs.m_pointer_to_impl));
+ }
+
+ void increment()
+ {
+ m_pointer_to_impl->increment();
+ }
+
+ void decrement()
+ {
+ //////////////////////////////////////////////////////////////////
+ //
+ // *** Message to Client ***
+ //
+ // If the next line does not compile, you are trying to decrement
+ // an iterator whose category does not allow decrementing.
+ return m_pointer_to_impl->decrement();
+ }
+
+ void advance(Difference n)
+ {
+ //////////////////////////////////////////////////////////////////
+ //
+ // *** Message to Client ***
+ //
+ // If the next line does not compile, you are trying to use an
+ // operation that is defined only for random access iterators
+ // on an iterator that is not random access.
+ m_pointer_to_impl->advance(n);
+ }
+
+ Difference distance_to(any_iterator const & other) const
+ {
+ //////////////////////////////////////////////////////////////////
+ //
+ // *** Message to Client ***
+ //
+ // If the next line does not compile, you are trying to use an
+ // operation that is defined only for random access iterators
+ // on an iterator that is not random access.
+ return m_pointer_to_impl->distance_to(*(other.m_pointer_to_impl));
+ }
+
+ any_iterator& swap(any_iterator& other)
+ {
+ // NOTE: iterator_facade doesn't have a swap method, so no call
+ // to base class here.
+ std::swap(m_pointer_to_impl, other.m_pointer_to_impl);
+ return *this;
+ }
+
+ detail::any_iterator_abstract_base<
+ Value,
+ boost::incrementable_traversal_tag,
+ Reference,
+ Difference
+ >* make_traversal_converted_version(boost::incrementable_traversal_tag* funcSelector) const
+ {
+ return m_pointer_to_impl->make_incrementable_version();
+ }
+
+ detail::any_iterator_abstract_base<
+ Value,
+ boost::single_pass_traversal_tag,
+ Reference,
+ Difference
+ >* make_traversal_converted_version(boost::single_pass_traversal_tag* funcSelector) const
+ {
+ return m_pointer_to_impl->make_single_pass_version();
+ }
+
+ detail::any_iterator_abstract_base<
+ Value,
+ boost::forward_traversal_tag,
+ Reference,
+ Difference
+ >* make_traversal_converted_version(boost::forward_traversal_tag* funcSelector) const
+ {
+ return m_pointer_to_impl->make_forward_version();
+ }
+
+ detail::any_iterator_abstract_base<
+ Value,
+ boost::bidirectional_traversal_tag,
+ Reference,
+ Difference
+ >* make_traversal_converted_version(boost::bidirectional_traversal_tag* funcSelector) const
+ {
+ return m_pointer_to_impl->make_bidirectional_version();
+ }
+
+ abstract_base_type* m_pointer_to_impl;
+
+ };
+
+ // Metafunction that takes an iterator and returns an any_iterator with the same
+ // traits.
+ template<class iterator>
+ struct make_any_iterator_type
+ {
+ typedef
+ any_iterator<
+ typename boost::iterator_value<iterator>::type,
+ typename boost::iterator_category<iterator>::type,
+ typename boost::iterator_reference<iterator>::type,
+ typename boost::iterator_difference<iterator>::type
+ > type;
+ };
+
+} // end namespace IteratorTypeErasure
+
+#endif // ANY_ITERATOR_01102007TMB_HPP

Added: sandbox/SOC/2009/unicode/boost/iterator/detail/any_iterator_abstract_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/iterator/detail/any_iterator_abstract_base.hpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -0,0 +1,255 @@
+// (C) Copyright Thomas Becker 2005. Permission to copy, use, modify, sell and
+// distribute this software is granted provided this copyright notice appears
+// in all copies. This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+
+// Revision History
+// ================
+//
+// 27 Dec 2006 (Thomas Becker) Created
+
+#ifndef ANY_ITERATOR_ABSTRACT_BASE_01102007TMB_HPP
+#define ANY_ITERATOR_ABSTRACT_BASE_01102007TMB_HPP
+
+// Includes
+// ========
+
+#include "any_iterator_metafunctions.hpp"
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/type_traits/add_const.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+namespace boost
+{
+
+ namespace detail
+ {
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ // The partial specializations of any_iterator_abstract_base (which is
+ // the equivalent of boost::any::placeholder) mirror the hierarchy of
+ // boost's iterator traversal tags.
+ //
+ // The first four template arguments are as in boost::iterator_facade.
+ // The last template argument is the traversal tag of the most
+ // derived class of the current instantiation of the hierarchy. This
+ // is a slight variant of the CRTP where the derived class passes
+ // itself as a template argument to the base class(es). Here, it seemed
+ // more convenient to pass up just the traversal tag of the most
+ // derived class.
+ //
+ template<
+ class Value,
+ class Traversal,
+ class Reference,
+ class Difference,
+ class UsedAsBaseForTraversal = Traversal
+ >
+ class any_iterator_abstract_base;
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class Value,
+ class Reference,
+ class Difference,
+ class UsedAsBaseForTraversal
+ >
+ class any_iterator_abstract_base<
+ Value,
+ boost::incrementable_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ >
+ {
+
+ protected:
+ typedef any_iterator_abstract_base<
+ Value,
+ UsedAsBaseForTraversal,
+ Reference,
+ Difference
+ > most_derived_type;
+
+ typedef most_derived_type clone_result_type;
+
+ typedef any_iterator_abstract_base<
+ typename boost::add_const<Value>::type,
+ UsedAsBaseForTraversal,
+ typename make_iterator_reference_const<Reference>::type,
+ Difference
+ > const_clone_with_const_value_type_result_type;
+
+ typedef any_iterator_abstract_base<
+ typename boost::remove_const<Value>::type,
+ UsedAsBaseForTraversal,
+ typename make_iterator_reference_const<Reference>::type,
+ Difference
+ > const_clone_with_non_const_value_type_result_type;
+
+ public:
+
+ // Plain clone function for copy construction and assignment.
+ virtual clone_result_type * clone() const=0;
+
+ // Clone functions for conversion to a const iterator
+ virtual const_clone_with_const_value_type_result_type * make_const_clone_with_const_value_type() const=0;
+ virtual const_clone_with_non_const_value_type_result_type * make_const_clone_with_non_const_value_type() const=0;
+
+ // gcc 3.4.2 does not like pure virtual declaration with inline definition,
+ // so I make the destructor non-pure just to spite them.
+ virtual ~any_iterator_abstract_base()
+ {}
+
+ virtual Reference dereference() const=0;
+ virtual void increment() = 0;
+
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class Value,
+ class Reference,
+ class Difference,
+ class UsedAsBaseForTraversal
+ >
+ class any_iterator_abstract_base<
+ Value,
+ boost::single_pass_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ > : public any_iterator_abstract_base<
+ Value,
+ boost::incrementable_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ >
+ {
+
+ public:
+
+ // gcc 3.4.2 insists on qualification of most_derived_type.
+ virtual bool equal(typename any_iterator_abstract_base::most_derived_type const &) const = 0;
+
+ virtual any_iterator_abstract_base<
+ Value,
+ boost::incrementable_traversal_tag,
+ Reference,
+ Difference
+ >* make_incrementable_version() const=0;
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class Value,
+ class Reference,
+ class Difference,
+ class UsedAsBaseForTraversal
+ >
+ class any_iterator_abstract_base<
+ Value,
+ boost::forward_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ > : public any_iterator_abstract_base<
+ Value,
+ boost::single_pass_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ >
+ {
+ public:
+ virtual any_iterator_abstract_base<
+ Value,
+ boost::single_pass_traversal_tag,
+ Reference,
+ Difference
+ >* make_single_pass_version() const=0;
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class Value,
+ class Reference,
+ class Difference,
+ class UsedAsBaseForTraversal
+ >
+ class any_iterator_abstract_base<
+ Value,
+ boost::bidirectional_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ > : public any_iterator_abstract_base<
+ Value,
+ boost::forward_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ >
+ {
+
+ public:
+
+ virtual void decrement() = 0;
+
+ virtual any_iterator_abstract_base<
+ Value,
+ boost::forward_traversal_tag,
+ Reference,
+ Difference
+ >* make_forward_version() const=0;
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class Value,
+ class Reference,
+ class Difference,
+ class UsedAsBaseForTraversal
+ >
+ class any_iterator_abstract_base<
+ Value,
+ boost::random_access_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ > : public any_iterator_abstract_base<
+ Value,
+ boost::bidirectional_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ >
+ {
+
+ public:
+
+ virtual void advance(Difference) = 0;
+
+ // gcc 3.4.2 insists on qualification of most_derived_type.
+ virtual Difference distance_to(typename any_iterator_abstract_base::most_derived_type const &) const= 0;
+
+ virtual any_iterator_abstract_base<
+ Value,
+ boost::bidirectional_traversal_tag,
+ Reference,
+ Difference
+ >* make_bidirectional_version() const=0;
+ };
+
+ } // end namespace detail
+
+} // end namespace IteratorTypeErasure
+
+#endif // ANY_ITERATOR_ABSTRACT_BASE_01102007TMB_HPP

Added: sandbox/SOC/2009/unicode/boost/iterator/detail/any_iterator_metafunctions.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/iterator/detail/any_iterator_metafunctions.hpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -0,0 +1,363 @@
+// (C) Copyright Thomas Becker 2005. Permission to copy, use, modify, sell and
+// distribute this software is granted provided this copyright notice appears
+// in all copies. This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+
+// File Name
+// =========
+//
+// metafunctions.h
+
+// Description
+// ===========
+//
+// Metafunctions for any_iterator
+
+#ifndef ANY_ITERATOR_METAFUNCTIONS_01102007TMB_HPP
+#define ANY_ITERATOR_METAFUNCTIONS_01102007TMB_HPP
+
+// Revision History
+// ================
+//
+// 27 Dec 2006 (Thomas Becker) Created
+
+// Includes
+// ========
+#include <boost/iterator/iterator_categories.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/is_base_of.hpp>
+#include <boost/type_traits/is_convertible.hpp>
+#include <boost/type_traits/is_reference.hpp>
+#include <boost/type_traits/is_pointer.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/mpl/not.hpp>
+
+namespace boost
+{
+
+ template<
+ class Value,
+ class Traversal,
+ class Reference,
+ class Difference
+ >
+ class any_iterator;
+
+ namespace detail
+ {
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<typename T>
+ struct remove_reference_and_const
+ {
+ typedef typename boost::remove_const<
+ typename boost::remove_reference<
+ typename boost::remove_const<
+ T
+ >::type
+ >::type
+ >::type type;
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<typename IteratorReference>
+ struct make_iterator_reference_const
+ {
+ typedef typename boost::mpl::if_<
+ typename boost::is_reference<IteratorReference>::type,
+ typename boost::remove_const<
+ typename boost::remove_reference<
+ typename boost::remove_const<
+ IteratorReference
+ >::type
+ >::type
+ >::type const &,
+ typename boost::remove_const<
+ typename boost::remove_reference<
+ typename boost::remove_const<
+ IteratorReference
+ >::type
+ >::type
+ >::type const
+ >::type type;
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class WrappedIterator,
+ class AnyIterator
+ >
+ struct value_types_erasure_compatible
+ {
+ // Really, we just want WrappedIterator's value_type to convert to
+ // AnyIterator's value_type. But many real world output iterators
+ // define their value_type as void. Therefore, we simply ignore
+ // the value type for output iterators. That's fine because for
+ // output iterators, the relevant type erasure information is all
+ // in the reference type.
+
+ typedef typename boost::mpl::or_<
+ boost::is_same<
+ typename boost::iterator_category<WrappedIterator>::type,
+ std::output_iterator_tag
+ >,
+
+ // Really, we just want WrappedIterator's value_type to convert to
+ // AnyIterator's value_type. But we need to work around a flaw in
+ // boost::is_convertible. boost::is_convertible<X, Y>::value is
+ // false whenever X and Y are abstract base classes (even when X
+ // and Y are the same). This will be fixed in C++ concepts.
+ boost::mpl::or_<
+ boost::is_same<
+ typename boost::iterator_value<WrappedIterator>::type,
+ typename boost::iterator_value<AnyIterator>::type
+ >,
+ boost::is_base_of<
+ typename boost::iterator_value<AnyIterator>::type,
+ typename boost::iterator_value<WrappedIterator>::type
+ >,
+ boost::is_convertible<
+ typename boost::iterator_value<WrappedIterator>::type,
+ typename boost::iterator_value<AnyIterator>::type
+ >
+ >
+ > type;
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class WrappedIterator,
+ class AnyIterator
+ >
+ struct reference_types_erasure_compatible_1
+ {
+ typedef typename boost::is_convertible<
+ typename boost::iterator_reference<WrappedIterator>::type,
+ typename boost::iterator_reference<AnyIterator>::type
+ >::type type;
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class WrappedIterator,
+ class AnyIterator
+ >
+ struct reference_types_erasure_compatible_2
+ {
+ typedef typename boost::mpl::if_<
+ boost::is_reference<
+ typename boost::iterator_reference<AnyIterator>::type
+ >,
+ boost::is_reference<
+ typename boost::iterator_reference<WrappedIterator>::type
+ >,
+ boost::mpl::bool_<true>
+ >::type type;
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class WrappedIterator,
+ class AnyIterator
+ >
+ struct reference_types_erasure_compatible_3
+ {
+
+ typedef typename boost::mpl::if_<
+ boost::mpl::and_<
+ boost::is_reference<
+ typename boost::iterator_reference<AnyIterator>::type
+ >,
+ boost::is_reference<
+ typename boost::iterator_reference<WrappedIterator>::type
+ >
+ >,
+ boost::mpl::or_<
+ boost::is_same<
+ typename remove_reference_and_const<
+ typename boost::iterator_reference<AnyIterator>::type
+ >::type,
+ typename remove_reference_and_const<
+ typename boost::iterator_reference<WrappedIterator>::type
+ >::type
+ >,
+ boost::is_base_of<
+ typename remove_reference_and_const<
+ typename boost::iterator_reference<AnyIterator>::type
+ >::type,
+ typename remove_reference_and_const<
+ typename boost::iterator_reference<WrappedIterator>::type
+ >::type
+ >
+ >,
+ boost::mpl::bool_<true>
+ >::type type;
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class WrappedIterator,
+ class AnyIterator
+ >
+ struct reference_types_erasure_compatible
+ {
+ // Output iterators are weird. Many real world output iterators
+ // define their reference type as void. In the world of boost
+ // iterators, that's terribly wrong, because in that world, an
+ // iterator's reference type is always the result type of
+ // operator* (and that makes very good sense, too). Therefore,
+ // when WrappedIterator is an output iterator, we use
+ // WrappedIterator& for WrappedIterator's reference type,
+ // because that's the real, true reference type. Moreover,
+ // we just require that WrappedIterator& convert to AnyIterator's
+ // reference type. The other subtleties are not relevant.
+
+ typedef typename boost::mpl::if_<
+ boost::is_same<
+ typename boost::iterator_category<WrappedIterator>::type,
+ std::output_iterator_tag
+ >,
+ boost::is_convertible<
+ WrappedIterator&,
+ typename boost::iterator_reference<AnyIterator>::type
+ >,
+ boost::mpl::and_<
+
+ // WrappedIterator's reference type must convert to AnyIterator's reference type.
+ typename reference_types_erasure_compatible_1<WrappedIterator, AnyIterator>::type,
+
+ // If AnyIterator's reference type is a reference, then the
+ // same must be true for WrappedIterator's reference type.
+ typename reference_types_erasure_compatible_2<WrappedIterator, AnyIterator>::type,
+
+ // If AnyIterator's reference type and WrappedIterator's
+ // reference type are both references, then one of the
+ // following must hold:
+ //
+ // 1) AnyIterator's reference type and WrappedIterator's
+ // reference type are the same.
+ //
+ // 2) AnyIterator's reference type is a base class of WrappedIterator's
+ // reference type.
+ //
+ typename reference_types_erasure_compatible_3<WrappedIterator, AnyIterator>::type
+ >
+ >::type type;
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class WrappedIterator,
+ class AnyIterator
+ >
+ struct difference_types_erasure_compatible
+ {
+
+ // Difference type matters only for random access iterators.
+
+ typedef typename boost::mpl::or_<
+ boost::mpl::not_<
+ boost::is_same<
+ // Do not use boost::iterator_traversal<AnyIterator>::type here,
+ // as it does not equal the traversal tag.
+ typename AnyIterator::Traversal,
+ boost::random_access_traversal_tag
+ >
+ >,
+ boost::mpl::and_<
+ boost::is_convertible<
+ typename boost::iterator_difference<WrappedIterator>::type,
+ typename boost::iterator_difference<AnyIterator>::type
+ >,
+ boost::is_convertible<
+ typename boost::iterator_difference<AnyIterator>::type,
+ typename boost::iterator_difference<WrappedIterator>::type
+ >
+ >
+ > type;
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class WrappedIterator,
+ class AnyIterator
+ >
+ struct traversal_types_erasure_compatible
+ {
+ typedef typename boost::mpl::or_<
+ boost::is_same<
+ // Do not use boost::iterator_traversal<AnyIterator>::type here,
+ // as it does not equal the traversal tag.
+ typename AnyIterator::Traversal,
+ typename boost::iterator_traversal<WrappedIterator>::type
+ >,
+ boost::is_base_of<
+ // Do not use boost::iterator_traversal<AnyIterator>::type here,
+ // as it does not equal the traversal tag.
+ typename AnyIterator::Traversal,
+ typename boost::iterator_traversal<WrappedIterator>::type
+ >
+ > type;
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class WrappedIterator,
+ class AnyIterator
+ >
+ struct is_iterator_type_erasure_compatible :
+ public boost::mpl::bool_<
+ boost::mpl::and_<
+ value_types_erasure_compatible<WrappedIterator, AnyIterator>,
+ reference_types_erasure_compatible<WrappedIterator, AnyIterator>,
+ difference_types_erasure_compatible<WrappedIterator, AnyIterator>,
+ traversal_types_erasure_compatible<WrappedIterator, AnyIterator>
+ >::value
+ >
+ {
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<class SomeIterator>
+ struct is_any_iterator : public boost::mpl::bool_<false>
+ {
+ };
+ //
+ template<
+ class Value,
+ class Traversal,
+ class Reference,
+ class Difference
+ >
+ struct is_any_iterator<
+ any_iterator<
+ Value,
+ Traversal,
+ Reference,
+ Difference
+ >
+ > : public boost::mpl::bool_<true>
+ {
+ };
+
+ } // end namespace detail
+
+} // end namespace IteratorTypeErasure
+
+#endif // ANY_ITERATOR_METAFUNCTIONS_01102007TMB_HPP

Added: sandbox/SOC/2009/unicode/boost/iterator/detail/any_iterator_wrapper.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/iterator/detail/any_iterator_wrapper.hpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -0,0 +1,440 @@
+// (C) Copyright Thomas Becker 2005. Permission to copy, use, modify, sell and
+// distribute this software is granted provided this copyright notice appears
+// in all copies. This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+
+// Revision History
+// ================
+//
+// 27 Dec 2006 (Thomas Becker) Created
+
+#ifndef ANY_ITERATOR_WRAPPER_01102007TMB_HPP
+#define ANY_ITERATOR_WRAPPER_01102007TMB_HPP
+
+// Includes
+// ========
+
+#include "any_iterator_abstract_base.hpp"
+#include "any_iterator_metafunctions.hpp"
+#include <boost/type_traits/add_const.hpp>
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/cast.hpp>
+
+namespace boost
+{
+
+ namespace detail
+ {
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ // The partial specializations of any_iterator_wrapper (which is the
+ // the equivalent of boost::any::holder) mirror the hierarchy of
+ // boost's iterator traversal tags.
+ //
+ // The first four template arguments are as in boost::iterator_facade.
+ // The last template argument is the traversal tag of the most
+ // derived class of the current instantiation of the hierarchy. This
+ // is a slight variant of the CRTP where the derived class passes
+ // itself as a template argument to the base class(es). Here, it seemed
+ // more convenient to pass up just the traversal tag of the most
+ // derived class.
+ //
+ template<
+ class WrappedIterator,
+ class Value,
+ class Traversal,
+ class Reference,
+ class Difference,
+ class UsedAsBaseForTraversal = Traversal
+ >
+ class any_iterator_wrapper;
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class WrappedIterator,
+ class Value,
+ class Reference,
+ class Difference,
+ class UsedAsBaseForTraversal
+ >
+ class any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::incrementable_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ > : public any_iterator_abstract_base<
+ Value,
+ UsedAsBaseForTraversal,
+ Reference,
+ Difference
+ >
+ {
+
+ protected:
+ typedef any_iterator_abstract_base<Value, UsedAsBaseForTraversal, Reference, Difference> abstract_base_type;
+
+ private:
+ typedef typename abstract_base_type::clone_result_type clone_result_type;
+ typedef typename abstract_base_type::const_clone_with_const_value_type_result_type const_clone_with_const_value_type_result_type;
+ typedef typename abstract_base_type::const_clone_with_non_const_value_type_result_type const_clone_with_non_const_value_type_result_type;
+
+ typedef any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ UsedAsBaseForTraversal,
+ Reference,
+ Difference
+ > clone_type;
+
+ typedef any_iterator_wrapper<
+ WrappedIterator,
+ typename boost::add_const<Value>::type,
+ UsedAsBaseForTraversal,
+ typename make_iterator_reference_const<Reference>::type,
+ Difference
+ > const_clone_type_with_const_value_type;
+
+ typedef any_iterator_wrapper<
+ WrappedIterator,
+ typename boost::remove_const<Value>::type,
+ UsedAsBaseForTraversal,
+ typename make_iterator_reference_const<Reference>::type,
+ Difference
+ > const_clone_type_with_non_const_value_type;
+
+ public:
+
+ any_iterator_wrapper()
+ {}
+
+ any_iterator_wrapper(WrappedIterator wrapped_iterator) :
+ m_wrapped_iterator(wrapped_iterator)
+ {}
+
+ static abstract_base_type* create(WrappedIterator wrapped_iterator)
+ {
+ return new clone_type(wrapped_iterator);
+ }
+
+ // Plain clone function for copy construction and assignment.
+ virtual clone_result_type * clone() const
+ {
+ return new clone_type(m_wrapped_iterator);
+ }
+
+ // Clone functions for conversion to a const iterator
+ virtual const_clone_with_const_value_type_result_type* make_const_clone_with_const_value_type() const
+ {
+ return new const_clone_type_with_const_value_type(m_wrapped_iterator);
+ }
+ //
+ virtual const_clone_with_non_const_value_type_result_type* make_const_clone_with_non_const_value_type() const
+ {
+ return new const_clone_type_with_non_const_value_type(m_wrapped_iterator);
+ }
+
+ virtual Reference dereference() const
+ {
+ // This const cast is needed for output iterators. Is this perhaps an oversight
+ // in iterator_facade?
+ return *const_cast<any_iterator_wrapper*>(this)->m_wrapped_iterator;
+ }
+
+ virtual void increment()
+ {
+ ++m_wrapped_iterator;
+ }
+
+ protected:
+
+ WrappedIterator& get_wrapped_iterator()
+ {
+ return m_wrapped_iterator;
+ }
+
+ WrappedIterator const & get_wrapped_iterator() const
+ {
+ return m_wrapped_iterator;
+ }
+
+ private:
+
+ WrappedIterator m_wrapped_iterator;
+
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class WrappedIterator,
+ class Value,
+ class Reference,
+ class Difference,
+ class UsedAsBaseForTraversal
+ >
+ class any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::single_pass_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ > : public any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::incrementable_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ >
+ {
+
+ public:
+
+ typedef
+ any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::incrementable_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ > super_type;
+
+ any_iterator_wrapper()
+ {}
+
+ any_iterator_wrapper(WrappedIterator wrapped_iterator) : super_type(wrapped_iterator)
+ {}
+
+ // gcc 3.4.2 insists on qualification of abstract_base_type.
+ virtual bool equal(typename any_iterator_wrapper::abstract_base_type const & rhs) const
+ {
+ return this->get_wrapped_iterator() == boost::polymorphic_downcast<any_iterator_wrapper const *>(&rhs)->get_wrapped_iterator();
+ }
+
+ any_iterator_abstract_base<
+ Value,
+ boost::incrementable_traversal_tag,
+ Reference,
+ Difference
+ >* make_incrementable_version() const
+ {
+ return new any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::incrementable_traversal_tag,
+ Reference,
+ Difference
+ >(this->get_wrapped_iterator());
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class WrappedIterator,
+ class Value,
+ class Reference,
+ class Difference,
+ class UsedAsBaseForTraversal
+ >
+ class any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::forward_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ > : public any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::single_pass_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ >
+ {
+
+ public:
+
+ typedef
+ any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::single_pass_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ > super_type;
+
+ any_iterator_wrapper()
+ {}
+
+ any_iterator_wrapper(WrappedIterator wrapped_iterator) : super_type(wrapped_iterator)
+ {}
+
+ any_iterator_abstract_base<
+ Value,
+ boost::single_pass_traversal_tag,
+ Reference,
+ Difference
+ >* make_single_pass_version() const
+ {
+ return new any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::single_pass_traversal_tag,
+ Reference,
+ Difference
+ >(this->get_wrapped_iterator());
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class WrappedIterator,
+ class Value,
+ class Reference,
+ class Difference,
+ class UsedAsBaseForTraversal
+ >
+ class any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::bidirectional_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ > : public any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::forward_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ >
+ {
+
+ public:
+
+ typedef
+ any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::forward_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ > super_type;
+
+ any_iterator_wrapper()
+ {}
+
+ any_iterator_wrapper(WrappedIterator wrapped_iterator) : super_type(wrapped_iterator)
+ {}
+
+ virtual void decrement()
+ {
+ --(this->get_wrapped_iterator());
+ }
+
+ any_iterator_abstract_base<
+ Value,
+ boost::forward_traversal_tag,
+ Reference,
+ Difference
+ >* make_forward_version() const
+ {
+ return new any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::forward_traversal_tag,
+ Reference,
+ Difference
+ >(this->get_wrapped_iterator());
+ }
+ };
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ template<
+ class WrappedIterator,
+ class Value,
+ class Reference,
+ class Difference,
+ class UsedAsBaseForTraversal
+ >
+ class any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::random_access_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ > : public any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::bidirectional_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ >
+ {
+
+ public:
+
+ typedef
+ any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::bidirectional_traversal_tag,
+ Reference,
+ Difference,
+ UsedAsBaseForTraversal
+ > super_type;
+
+ any_iterator_wrapper()
+ {}
+
+ any_iterator_wrapper(WrappedIterator wrapped_iterator) : super_type(wrapped_iterator)
+ {}
+
+ virtual void advance(Difference n)
+ {
+ this->get_wrapped_iterator() += n;
+ }
+
+ // gcc 3.4.2 insists on qualification of abstract_base_type.
+ virtual Difference distance_to(typename any_iterator_wrapper::abstract_base_type const & other) const
+ {
+ return boost::polymorphic_downcast<any_iterator_wrapper const *>(&other)->get_wrapped_iterator() - this->get_wrapped_iterator();
+ }
+
+ any_iterator_abstract_base<
+ Value,
+ boost::bidirectional_traversal_tag,
+ Reference,
+ Difference
+ >* make_bidirectional_version() const
+ {
+ return new any_iterator_wrapper<
+ WrappedIterator,
+ Value,
+ boost::bidirectional_traversal_tag,
+ Reference,
+ Difference
+ >(this->get_wrapped_iterator());
+ }
+ };
+
+ } // end namespace detail
+
+} // end namespace IteratorTypeErasure
+
+#endif // ANY_ITERATOR_WRAPPER_01102007TMB_HPP

Modified: sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator.hpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -10,6 +10,7 @@
 
 #include <boost/utility/enable_if.hpp>
 #include <boost/mpl/has_xxx.hpp>
+#include <boost/mpl/int.hpp>
 
 namespace boost
 {
@@ -123,6 +124,22 @@
         return one_many_pipe<OneManyPipe>(p);
 }
 
+/** Model of \c OneManyPipe that casts its input to its template
+ * parameter and writes it to its output. */
+template<typename T>
+struct cast_pipe
+{
+ typedef T output_type;
+ typedef mpl::int_<1> max_output;
+
+ template<typename U, typename Out>
+ Out operator()(U in, Out out)
+ {
+ *out++ = static_cast<output_type>(in);
+ return out;
+ }
+};
+
 /** Iterator adapter that wraps a range to make it appear like a converted
  * one, by converting it step-by-step as it is advanced. */
 template<typename It, typename Pipe>

Added: sandbox/SOC/2009/unicode/boost/range/any_range.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/range/any_range.hpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -0,0 +1,35 @@
+#ifndef BOOST_RANGE_ANY_RANGE_HPP
+#define BOOST_RANGE_ANY_RANGE_HPP
+
+#include <boost/range/iterator_range.hpp>
+#include <boost/iterator/any_iterator.hpp>
+
+namespace boost
+{
+
+template<
+ typename Value,
+ typename CategoryOrTraversal,
+ typename Reference = Value&,
+ typename Difference = std::ptrdiff_t
+>
+struct any_range : iterator_range< any_iterator<Value, CategoryOrTraversal, Reference, Difference> >
+{
+ template<typename T>
+ any_range(const T& t) : iterator_range< any_iterator<Value, CategoryOrTraversal, Reference, Difference> >(t)
+ {
+ }
+};
+
+template<typename Value, typename Reference = const Value, typename Difference = std::ptrdiff_t>
+struct lazy_range : any_range<Value, bidirectional_traversal_tag, Reference, Difference>
+{
+ template<typename T>
+ lazy_range(const T& t) : any_range<Value, bidirectional_traversal_tag, Reference, Difference>(t)
+ {
+ }
+};
+
+} // namespace boost
+
+#endif

Modified: sandbox/SOC/2009/unicode/boost/unicode/compose.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/unicode/compose.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/unicode/compose.hpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -5,16 +5,22 @@
 #include <boost/unicode/hangul.hpp>
 
 #include <boost/integer/static_pow.hpp>
+#include <climits>
 
 namespace boost
 {
 namespace unicode
 {
+
+#define BOOST_UNICODE_OPTION(o) (boost::static_pow<2, (o)>::value)
+#ifdef BOOST_UNICODE_DOXYGEN_INVOKED
+#undef BOOST_UNICODE_OPTION
+#endif
 
 /** Model of \c OneManyPipe that decomposes a code point, i.e. it
  * converts a code point into a sequence of code points.
- * It applies UCD decomposition that match \c mask as well as the Hangul decompositions. */
-template<int mask = static_pow<2, ucd::decomposition_type::canonical>::value>
+ * It applies UCD decompositions that match \c mask as well as the Hangul decompositions. */
+template<unsigned mask = BOOST_UNICODE_OPTION(ucd::decomposition_type::canonical)>
 struct decomposer
 {
     template<typename Out>

Modified: sandbox/SOC/2009/unicode/boost/unicode/graphemes.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/unicode/graphemes.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/unicode/graphemes.hpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -3,6 +3,7 @@
 
 #include <boost/unicode/ucd/properties.hpp>
 #include <boost/utility.hpp>
+#include <boost/detail/unspecified.hpp>
 
 #include <boost/iterator/consumer_iterator.hpp>
 
@@ -37,12 +38,12 @@
 /** Adapts the range of code points \c range into a range of ranges of code points,
  * each subrange being a grapheme cluster. */
 template<typename Range>
-iterator_range<
+iterator_range<typename boost::detail::unspecified<
     consumer_iterator<
         typename range_iterator<const Range>::type,
         boundary_consumer<unicode::grapheme_boundary>
>
->
+>::type>
 grapheme_bounded(const Range& range)
 {
     return consumed(range, make_boundary_consumer(unicode::grapheme_boundary()));
@@ -50,10 +51,10 @@
 
 /** INTERNAL ONLY */
 #define BOOST_UNICODE_GRAPHEME_BOUNDED_DEF(Name) \
-/** Adapts the range of X \c range into a range of ranges of X,
- * each subrange being a grapheme cluster. */ \
+/** Adapts the range of Name units \c range into a range of ranges of
+Name units, each subrange being a grapheme cluster. */ \
 template<typename Range> \
-iterator_range< \
+iterator_range<typename boost::detail::unspecified< \
     consumer_iterator< \
         typename range_iterator<const Range>::type, \
         piped_consumer< \
@@ -61,7 +62,7 @@
             boundary_consumer<unicode::grapheme_boundary> \
> \
> \
-> \
+>::type> \
 Name##_grapheme_bounded(const Range& range) \
 { \
     return consumed( \
@@ -72,6 +73,13 @@
         ) \
     ); \
 } \
+ \
+/** Model of \c BoundaryChecker that tells whether a position lies on a
+grapheme cluster boundary within a range of Name units. */ \
+typedef multi_boundary< \
+ Name##_boundary, Name##_decoder, \
+ grapheme_boundary \
+> Name##_grapheme_boundary; \
 
 BOOST_UNICODE_GRAPHEME_BOUNDED_DEF(u16)
 BOOST_UNICODE_GRAPHEME_BOUNDED_DEF(u8)

Added: sandbox/SOC/2009/unicode/boost/unicode/search.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/unicode/search.hpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -0,0 +1,191 @@
+#ifndef BOOST_UNICODE_SEARCH_HPP
+#define BOOST_UNICODE_SEARCH_HPP
+
+#include <boost/range.hpp>
+#include <boost/algorithm/string/compare.hpp>
+
+
+namespace boost
+{
+
+namespace algorithm
+{
+
+template<typename F, typename B>
+struct boundary_finder
+{
+ boundary_finder(F f_, B b_) : f(f_), b(b_)
+ {
+ }
+
+ template<typename Iterator>
+ iterator_range<Iterator> operator()(Iterator begin, Iterator end) const
+ {
+ iterator_range<Iterator> range;
+ Iterator curr_begin = begin;
+ for(;;)
+ {
+ range = f(curr_begin, end);
+ if(
+ empty(range)
+ || ((range.begin() == begin || b(begin, end, range.begin()))
+ && (range.end() == end || b(begin, end, range.end())))
+ )
+ return range;
+
+ curr_begin = range.begin();
+ ++curr_begin;
+ }
+ }
+
+private:
+ mutable F f;
+ mutable B b;
+};
+
+template<typename F, typename B>
+boundary_finder<F, B> make_boundary_finder(F f, B b)
+{
+ return boundary_finder<F, B>(f, b);
+}
+
+} // namespace algorithm
+
+namespace unicode
+{
+
+template<typename Match, typename Comp = is_equal>
+struct simple_finder
+{
+ simple_finder(const Match& match_, const Comp& comp_ = Comp()) : match(match_), comp(comp_)
+ {
+ }
+
+ template<typename Iterator>
+ iterator_range<Iterator> ltr(Iterator begin, Iterator end)
+ {
+ typedef typename range_iterator<const Match>::type Iterator_match;
+
+ for(Iterator it = begin; it != end; ++it)
+ {
+ Iterator it_curr = it;
+ Iterator_match it_match = boost::begin(match);
+ for(; it_match != boost::end(match) && it_curr != end; ++it_match, ++it_curr)
+ {
+ if(!comp(*it_match, *it_curr))
+ break;
+ }
+
+ if(it_match == boost::end(match))
+ return make_iterator_range(it, it_curr);
+ }
+ return make_iterator_range(end, end);
+ }
+
+ template<typename Iterator>
+ iterator_range<Iterator> rtl(Iterator begin, Iterator end)
+ {
+ typedef typename range_iterator<const Match>::type Iterator_match;
+
+ for(Iterator it = end; ; --it)
+ {
+ Iterator it_curr = it;
+ Iterator_match it_match = boost::end(match);
+ for(; ; --it_match, --it_curr)
+ {
+ if(!comp(*it_match, *it_curr))
+ break;
+
+ if(it_match == boost::begin(match) || it_curr == begin)
+ break;
+ }
+
+ if(it_match == boost::begin(match))
+ return make_iterator_range(it_curr, it);
+
+ if(it == begin)
+ break;
+ }
+ return make_iterator_range(begin, begin);
+ }
+
+private:
+ const Match& match;
+ Comp comp;
+};
+
+template<typename Match, typename Comp>
+simple_finder<Match, Comp> make_simple_finder(const Match& match, Comp comp = Comp())
+{
+ return simple_finder<Match, Comp>(match, comp);
+}
+
+template<typename Match>
+simple_finder<Match> make_simple_finder(const Match& match)
+{
+ return simple_finder<Match>(match);
+}
+
+template<typename F, typename B>
+struct boundary_finder
+{
+ boundary_finder(F f_, B b_) : f(f_), b(b_)
+ {
+ }
+
+ template<typename Iterator>
+ iterator_range<Iterator> ltr(Iterator begin, Iterator end)
+ {
+ iterator_range<Iterator> range;
+ Iterator curr_begin = begin;
+ for(;;)
+ {
+ range = f.ltr(curr_begin, end);
+ if(
+ empty(range)
+ || ((range.begin() == begin || b(begin, end, range.begin()))
+ && (range.end() == end || b(begin, end, range.end())))
+ )
+ return range;
+
+ curr_begin = range.begin();
+ ++curr_begin;
+ }
+ }
+
+ template<typename Iterator>
+ iterator_range<Iterator> rtl(Iterator begin, Iterator end)
+ {
+ iterator_range<Iterator> range;
+ Iterator curr_end = end;
+ for(;;)
+ {
+ range = f.rtl(begin, curr_end);
+ if(
+ empty(range)
+ || ((range.begin() == begin || b(begin, end, range.begin()))
+ && (range.end() == end || b(begin, end, range.end())))
+ )
+ return range;
+
+ curr_end = range.end();
+ --curr_end;
+ }
+ }
+
+private:
+ F f;
+ B b;
+};
+
+template<typename F, typename B>
+boundary_finder<F, B> make_boundary_finder(F f, B b)
+{
+ return boundary_finder<F, B>(f, b);
+}
+
+} // namespace unicode
+
+} // namespace boost
+
+#endif

Modified: sandbox/SOC/2009/unicode/boost/unicode/static_utf.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/unicode/static_utf.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/unicode/static_utf.hpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -18,6 +18,12 @@
 {
 };
 
+template<typename I>
+struct static_u16_encoder_type
+ : static_u16_encoder<I::value>
+{
+};
+
 template<typename S1, typename S2>
 struct concat
   : mpl::fold<

Modified: sandbox/SOC/2009/unicode/boost/unicode/utf.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/unicode/utf.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/unicode/utf.hpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -5,6 +5,8 @@
 #include <boost/iterator/pipe_iterator.hpp>
 #include <boost/iterator/consumer_iterator.hpp>
 
+#include <boost/detail/unspecified.hpp>
+
 namespace boost
 {
 namespace unicode
@@ -28,12 +30,12 @@
    that wraps the range \c range and converts it step-by-step as
    the range is advanced */ \
 template<typename Range> \
-iterator_range< \
+iterator_range<typename boost::detail::unspecified< \
     pipe_iterator< \
         typename range_iterator<const Range>::type, \
         one_many_pipe<unicode::Name##_encoder> \
> \
-> \
+>::type> \
 Name##_encoded(const Range& range) \
 { \
     return piped(range, make_one_many_pipe(unicode::Name##_encoder()));\
@@ -42,10 +44,10 @@
 /** Lazily evalutes unicode::Name##_encoder by returning an output
   iterator that wraps \c out and converts every pushed element. */ \
 template<typename OutputIterator> \
-pipe_output_iterator< \
+typename boost::detail::unspecified<pipe_output_iterator< \
     OutputIterator, \
     unicode::Name##_encoder \
-> Name##_encoded_out(OutputIterator out) \
+> >::type Name##_encoded_out(OutputIterator out) \
 { \
         return piped_output(out, unicode::Name##_encoder()); \
 } \
@@ -68,26 +70,26 @@
    that wraps the range \c range and converts it step-by-step as
    the range is advanced */ \
 template<typename Range> \
-iterator_range< \
+iterator_range<typename boost::detail::unspecified< \
     pipe_iterator< \
         typename range_iterator<const Range>::type, \
         unicode::Name##_decoder \
> \
-> \
+>::type> \
 Name##_decoded(const Range& range) \
 { \
     return piped(range, unicode::Name##_decoder()); \
 } \
                                                                        \
-/** Adapts the range of X \c range into a range of ranges of X,
- * each subrange being a decoded unit. */ \
+/** Adapts the range of Name units \c range into a range of ranges of
+Name units, each subrange being a decoded unit. */ \
 template<typename Range> \
-iterator_range< \
+iterator_range<typename boost::detail::unspecified< \
     consumer_iterator< \
         typename range_iterator<const Range>::type, \
         pipe_consumer<unicode::Name##_decoder> \
> \
-> Name##_bounded(const Range& range) \
+>::type> Name##_bounded(const Range& range) \
 { \
     return consumed( \
         range, \
@@ -103,7 +105,6 @@
 
 BOOST_UNICODE_DECODER_DEF(utf)
 
-typedef cast_pipe<char> latin1_encoder;
 BOOST_UNICODE_ENCODER_DEF(latin1);
 
 } // namespace unicode

Modified: sandbox/SOC/2009/unicode/boost/unicode/utf_codecs.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/unicode/utf_codecs.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/unicode/utf_codecs.hpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -17,6 +17,8 @@
 #include <boost/mpl/and.hpp>
 #include <boost/mpl/bool.hpp>
 
+#include <boost/detail/unspecified.hpp>
+
 namespace boost
 {
 namespace unicode
@@ -388,22 +390,6 @@
     }
 };
 
-/** Model of \c OneManyPipe that casts its input to its template
- * parameter and writes it to its output. */
-template<typename T>
-struct cast_pipe
-{
- typedef T output_type;
- typedef mpl::int_<1> max_output;
-
- template<typename U, typename Out>
- Out operator()(U in, Out out)
- {
- *out++ = static_cast<output_type>(in);
- return out;
- }
-};
-
 namespace detail
 {
 
@@ -441,7 +427,8 @@
 {
     typedef char32 output_type;
     typedef mpl::int_<1> max_output;
-
+
+#ifndef BOOST_UNICODE_DOXYGEN_INVOKED
 private:
     template<typename Iterator, typename Enable = void>
     struct decoder
@@ -478,6 +465,7 @@
     {
         typedef u8_decoder type;
     };
+#endif
 
 public:
     template<typename In, typename Out>
@@ -499,6 +487,7 @@
  * \c u8_boundary depending on the value type of the input range. */
 struct utf_boundary
 {
+#ifndef BOOST_UNICODE_DOXYGEN_INVOKED
     template<typename In>
     typename enable_if<
         detail::is_u32<
@@ -530,12 +519,19 @@
>,
         bool
>::type
+#else
+ bool
+#endif
     operator()(In begin, In end, In pos)
     {
         return u8_boundary()(begin, end, pos);
     }
 };
 
+/** Model of \c OneManyPipe that converts from UTF-32 to ISO-8859-1
+ * alias latin-1. */
+typedef boost::detail::unspecified< cast_pipe<char> >::type latin1_encoder;
+
 } // namespace unicode
 
 } // namespace boost

Modified: sandbox/SOC/2009/unicode/libs/unicode/doc/Jamfile.v2
==============================================================================
--- sandbox/SOC/2009/unicode/libs/unicode/doc/Jamfile.v2 (original)
+++ sandbox/SOC/2009/unicode/libs/unicode/doc/Jamfile.v2 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -31,7 +31,8 @@
         ../../../boost/cuchar.hpp
         :
         <doxygen:param>EXTRACT_ALL=YES
- <doxygen:param>"PREDEFINED=\"BOOST_UNICODE_DOXYGEN_INVOKED\""
+ <doxygen:param>"PREDEFINED=\"BOOST_UNICODE_DOXYGEN_INVOKED\" \\
+ \"BOOST_UNICODE_DECL= \""
         <doxygen:param>HIDE_UNDOC_MEMBERS=NO
         <doxygen:param>EXTRACT_PRIVATE=NO
         <doxygen:param>ENABLE_PREPROCESSING=YES

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/alert.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/blank.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/1.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/10.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/11.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/12.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/13.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/14.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/15.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/2.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/3.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/4.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/5.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/6.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/7.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/8.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/callouts/9.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/caution.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/draft.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/home.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/important.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/next.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/next_disabled.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/note.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/prev.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/prev_disabled.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/tip.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/toc-blank.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/toc-minus.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/toc-plus.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/up.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/up_disabled.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2009/unicode/libs/unicode/doc/src/images/warning.png
==============================================================================
Binary file. No diff available.

Modified: sandbox/SOC/2009/unicode/libs/unicode/doc/users_manual.qbk
==============================================================================
--- sandbox/SOC/2009/unicode/libs/unicode/doc/users_manual.qbk (original)
+++ sandbox/SOC/2009/unicode/libs/unicode/doc/users_manual.qbk 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -411,6 +411,11 @@
 Then, the =boost::mpl::c_str= meta-function may be used to convert
 any compile-time string into a zero-terminated equivalent.
 
+[heading Example]
+
+See the [link unicode.examples.source_input source_input] example for
+demonstrations.
+
 [endsect]
 
 [section Unicode String type]
@@ -422,9 +427,29 @@
 
 [section Examples]
 
-[section test]
-[import ../example/test.cpp]
-[file]
+[section convert]
+[import ../example/convert.cpp]
+[convert]
+[endsect]
+
+[section characters]
+[import ../example/characters.cpp]
+[characters]
+[endsect]
+
+[section compose]
+[import ../example/compose.cpp]
+[compose]
+[endsect]
+
+[section search]
+[import ../example/search.cpp]
+[search]
+[endsect]
+
+[section source_input]
+[import ../example/source_input.cpp]
+[source_input]
 [endsect]
 
 [endsect]

Modified: sandbox/SOC/2009/unicode/libs/unicode/example/Jamfile.v2
==============================================================================
--- sandbox/SOC/2009/unicode/libs/unicode/example/Jamfile.v2 (original)
+++ sandbox/SOC/2009/unicode/libs/unicode/example/Jamfile.v2 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -17,4 +17,8 @@
                 <link>shared:<define>BOOST_UNICODE_DYN_LINK=1
     ;
 
-exe test : test.cpp ;
+exe convert : convert.cpp ;
+exe characters : characters.cpp ;
+exe compose : compose.cpp ;
+exe search : search.cpp ;
+exe source_input : source_input.cpp ;

Added: sandbox/SOC/2009/unicode/libs/unicode/example/characters.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/libs/unicode/example/characters.cpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -0,0 +1,41 @@
+//[ characters
+/*`
+This example shows the difference between code units, code points and
+graphemes, the different levels at which to approach the concept of
+character.
+*/
+#include <boost/range/algorithm.hpp>
+#include <boost/range/as_literal.hpp>
+#include <boost/foreach.hpp>
+
+#include <boost/unicode/utf.hpp>
+#include <boost/unicode/graphemes.hpp>
+
+#include <iostream>
+
+namespace unicode = boost::unicode;
+
+int main()
+{
+ char foo_[] = "foo\r\n\xc4\x93\xcc\x81 \xe1\xb8\x97";
+
+ // We don't use foo_ directly because we don't want the terminating 0 to be part of the range
+ boost::iterator_range<char*> foo = boost::as_literal(foo_);
+
+ std::cout << "Code units: " << boost::distance(foo) << std::endl;
+ std::cout << "Code points: " << boost::distance(unicode::u8_bounded(foo)) << std::endl; /*< We could also have used `unicode::u8_decoded(foo)` here. >*/
+ std::cout << "Graphemes: " << boost::distance(unicode::u8_grapheme_bounded(foo)) << std::endl; /*< We could also have used `unicode::grapheme_bounded(unicode::u8_decoded(foo))` here. >*/
+
+ std::cout << std::endl;
+ std::cout << "Code points boundaries:" << std::endl; /*< Take into account your terminal may be interpreting the carriage return when viewing the output and thus visually produce strange results. >*/
+ BOOST_FOREACH(boost::iterator_range<char*> cp, unicode::u8_bounded(foo)) /*< In case the type of `cp` is too difficult to deduce, you could use `BOOST_FOREACH_AUTO` if your platform supports it or type erasure with `boost::lazy_range<char>` if you don't mind the overhead. >*/
+ std::cout << '(' << cp << ')';
+ std::cout << std::endl;
+
+ std::cout << std::endl;
+ std::cout << "Graphemes boundaries:" << std::endl;
+ BOOST_FOREACH(boost::iterator_range<char*> grapheme, unicode::u8_grapheme_bounded(foo))
+ std::cout << '(' << grapheme << ')';
+ std::cout << std::endl;
+}
+//]

Added: sandbox/SOC/2009/unicode/libs/unicode/example/compose.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/libs/unicode/example/compose.cpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -0,0 +1,34 @@
+//[ compose
+#include <boost/unicode/compose.hpp>
+#include <iostream>
+#include <iterator>
+
+namespace unicode = boost::unicode;
+namespace ucd = unicode::ucd;
+
+int main()
+{
+ boost::char32 cp = 0x1E17;
+
+ std::cout << "Decomposition of U+01E17 within the UCD: ";
+ for(const boost::char32* p = ucd::get_decomposition(cp); *p; ++p)
+ std::cout << "0x" << std::hex << *p << ' ';
+ std::cout << std::endl;
+ std::cout << "Decomposition type: " << as_string(ucd::get_decomposition_type(cp)) << std::endl;
+ std::cout << std::endl;
+
+ unicode::decomposer<> canon_decomp;
+ unicode::decomposer<UINT_MAX> compat_decomp;
+
+ std::cout << "Canonical decomposition: ";
+ canon_decomp(cp, std::ostream_iterator<boost::char32>(std::cout, " "));
+ std::cout << std::endl << std::endl;
+
+ std::cout << "Canonical decomposition of U+00A8: ";
+ canon_decomp(0xA8, std::ostream_iterator<boost::char32>(std::cout, " "));
+ std::cout << std::endl;
+ std::cout << "Compatibility decomposition of U+00A8: ";
+ compat_decomp(0xA8, std::ostream_iterator<boost::char32>(std::cout, " "));
+ std::cout << std::endl;
+}
+//]

Added: sandbox/SOC/2009/unicode/libs/unicode/example/convert.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/libs/unicode/example/convert.cpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -0,0 +1,54 @@
+//[ convert
+/*`
+This example shows the possible ways to convert between UTF
+encodings, by converting a UTF-x range into UTF-8 and printing it.
+*/
+#include <boost/unicode/utf.hpp>
+#include <boost/foreach.hpp>
+#include <vector>
+#include <string>
+#include <iostream>
+#include <iterator>
+
+namespace unicode = boost::unicode;
+
+int main()
+{
+ wchar_t foo[] = L"hello \u00E9 world";
+ std::vector<boost::char32> bar;
+ std::string baz;
+
+//` Decoding and encoding eager, using two buffers:
+ unicode::utf_decode(foo, std::back_inserter(bar));
+ unicode::u8_encode(bar, std::back_inserter(baz));
+ std::cout << baz << std::endl;
+
+ bar.clear();
+ baz.clear();
+
+//` Decoding and encoding eager, using one buffer and a stream iterator:
+ unicode::utf_decode(foo, std::back_inserter(bar));
+ unicode::u8_encode(bar, std::ostream_iterator<char>(std::cout));
+ std::cout << std::endl;
+
+//` Decoding eager, stream iterator lazily encoded:
+ unicode::utf_decode(foo,
+ unicode::u8_encoded_out(
+ std::ostream_iterator<char>(std::cout)
+ )
+ );
+ std::cout << std::endl;
+
+//` Decoding is lazy, encoding is eager, using one buffer:
+ unicode::u8_encode(unicode::utf_decoded(foo), std::back_inserter(baz));
+ std::cout << baz << std::endl;
+
+//` Decoding is lazy, encoding is eager, using stream iterators:
+ unicode::u8_encode(unicode::utf_decoded(foo), std::ostream_iterator<char>(std::cout));
+ std::cout << std::endl;
+
+//` Fully lazy (recommended unless you need to store the result in a specific container):
+ std::cout << unicode::u8_encoded(unicode::utf_decoded(foo)) << std::endl;
+
+}
+//]

Added: sandbox/SOC/2009/unicode/libs/unicode/example/search.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/libs/unicode/example/search.cpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -0,0 +1,50 @@
+//[ search
+/*`
+Example in development.
+*/
+
+#include <boost/algorithm/string.hpp>
+#include <boost/unicode/search.hpp>
+
+#include <boost/foreach.hpp>
+#include <boost/foreach_auto.hpp>
+#include <iostream>
+
+#include <boost/unicode/graphemes.hpp>
+#include <boost/unicode/utf.hpp>
+
+namespace unicode = boost::unicode;
+
+int main()
+{
+ char foo[] = "foo\xcc\x82" "foo";
+ //BOOST_AUTO(foo, unicode::utf_grapheme_bounded(foo_));
+
+ char search[] = "foo";
+
+ //BOOST_AUTO(s, unicode::utf_grapheme_bounded(boost::as_literal(search)));
+ BOOST_AUTO(s, boost::as_literal(search));
+
+ // Boost.StringAlgo
+ BOOST_AUTO(finder,
+ /*boost::algorithm::make_boundary_finder(*/
+ boost::algorithm::first_finder(s)/*,
+ unicode::utf_grapheme_boundary()
+ )*/
+ );
+
+ BOOST_AUTO(f, unicode::make_boundary_finder(
+ unicode::make_simple_finder(s),
+ unicode::utf_grapheme_boundary()
+ ));
+
+ BOOST_AUTO(range, f.ltr(boost::begin(foo), boost::end(foo)));
+ //BOOST_AUTO(range, boost::algorithm::find(foo, finder));
+
+ std::cout << "[" << std::distance(boost::begin(foo), range.begin()) << ", " << std::distance(boost::begin(foo), range.end()) << "] ";
+
+ BOOST_FOREACH_AUTO(r, range)
+ std::cout << r;
+ std::cout << std::endl;
+}
+//]

Added: sandbox/SOC/2009/unicode/libs/unicode/example/source_input.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/libs/unicode/example/source_input.cpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
@@ -0,0 +1,87 @@
+//[ source_input
+/*`
+This example shows how to input some non-ASCII unicode
+characters into source files in different means, following the
+[link unicode.unicode_in_source_files.portability_guidelines portability
+guidelines], and then how to convert them to displayable UTF-8.
+
+The following strings are considered:
+
+* $ U+00A2 U+20AC U+024B62
+* hello U+00E9 world
+*/
+
+#include <boost/unicode/string_cp.hpp>
+
+#include <boost/unicode/utf.hpp>
+#include <boost/unicode/static_utf.hpp>
+#include <iostream>
+
+namespace mpl = boost::mpl;
+namespace unicode = boost::unicode;
+
+//` Direct UTF-8:
+char direct_utf8_1[] = "$¢€𤭢";
+char direct_utf8_2[] = "hello é world";
+
+//` UTF-8 as escape sequences:
+char escape_utf8_1[] = "$\xC2\xA2\xE2\x82\xAC\xF0\xA4\xAD\xA2";
+char escape_utf8_2[] = "hello \xC3\xA9 world";
+
+//` Probably UTF-X (either 16 or 32) as Unicode escape sequences:
+wchar_t utfx_1[] = L"$\u00A2\u20AC\U00024B62";
+wchar_t utfx_2[] = L"hello \u00E9 world";
+
+//` Compile-time direct UTF-8:
+typedef mpl::string<'$', '¢', '€', '𤭢'> static_direct_utf8_1;
+typedef mpl::string<'hell', 'o ', 'é', ' wor', 'ld'> static_direct_utf8_2;
+
+//` Compile-time UTF-8 with Unicode code points:
+typedef mpl::string<'$', unicode::string_cp<0xA2>::value, unicode::string_cp<0x20AC>::value, unicode::string_cp<0x24B62>::value> static_escape_utf8_1;
+typedef mpl::string<'hell', 'o ', unicode::string_cp<0xE9>::value, ' wor', 'ld'> static_escape_utf8_2;
+
+//` Compile-time UTF-16:
+typedef mpl::u16string<'$', 0xA2, 0x20AC, 0xD852, 0xDF62> static_utf16_1;
+typedef mpl::u16string<'h', 'e', 'l', 'l', 'o', ' ', 0xE9, ' ', 'w', 'o', 'r', 'l', 'd'> static_utf16_2;
+
+//` Compile-time UTF-32:
+typedef mpl::u32string<'$', 0xA2, 0x20AC, 0x24B64> static_utf32_1;
+typedef mpl::u32string<'h', 'e', 'l', 'l', 'o', ' ', 0xE9, ' ', 'w', 'o', 'r', 'l', 'd'> static_utf32_2;
+
+//` Let's display everything as UTF-8:
+int main()
+{
+//` For strings that are already in UTF-8, nothing to do:
+ std::cout << direct_utf8_1 << std::endl;
+ std::cout << direct_utf8_2 << std::endl;
+ std::cout << escape_utf8_1 << std::endl;
+ std::cout << escape_utf8_2 << std::endl;
+
+/*`
+Wide strings are either UTF-16 or UTF-32, we convert them to UTF-32
+then back to UTF-8:
+*/
+ std::cout << unicode::u8_encoded(unicode::utf_decoded(utfx_1)) << std::endl;
+ std::cout << unicode::u8_encoded(unicode::utf_decoded(utfx_2)) << std::endl;
+
+/*`
+Compile-time UTF-8 strings just need to be converted to runtime ones:
+*/
+ std::cout << mpl::c_str<static_direct_utf8_1>::value << std::endl;
+ std::cout << mpl::c_str<static_direct_utf8_2>::value << std::endl;
+ std::cout << mpl::c_str<static_escape_utf8_1>::value << std::endl;
+ std::cout << mpl::c_str<static_escape_utf8_2>::value << std::endl;
+
+/*`
+Compile-time decoding of UTF-16 is unsupported at the moment, so we
+cannot convert `static_utf16_1` and `static_utf16_2` to displayable
+UTF-8.
+
+Compile-time UTF-32 can be converted at compile-time to UTF-8 then
+converted to runtime strings:
+*/
+ std::cout << mpl::c_str<unicode::static_u8_encode<static_utf32_1>::type>::value << std::endl;
+ std::cout << mpl::c_str<unicode::static_u8_encode<static_utf32_2>::type>::value << std::endl;
+}
+
+//]

Deleted: sandbox/SOC/2009/unicode/libs/unicode/example/test.cpp
==============================================================================
--- sandbox/SOC/2009/unicode/libs/unicode/example/test.cpp 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
+++ (empty file)
@@ -1,118 +0,0 @@
-//[ file
-#include <iostream>
-
-#include <boost/foreach.hpp>
-#include <boost/foreach_auto.hpp>
-
-#include <boost/range/adaptors.hpp>
-#include <boost/range/algorithm.hpp>
-
-#include <boost/unicode/utf.hpp>
-#include <boost/unicode/ucd/properties.hpp>
-#include <boost/unicode/graphemes.hpp>
-#include <boost/unicode/compose.hpp>
-
-#include <boost/unicode/string_cp.hpp>
-
-int main()
-{
- namespace unicode = boost::unicode;
- namespace ucd = boost::unicode::ucd;
- using namespace boost;
-
- std::vector<boost::char32> v;
-
- /*v.push_back(122);
- v.push_back(27700);
- v.push_back(119070);
- v.push_back(123);*/
-
- v.push_back(1);
- v.push_back(0xE9);
- v.push_back(3);
-
-
- /*v.push_back(0x7a);
- v.push_back(0x6c34);
- v.push_back(0xd834);
- v.push_back(0xdd1e);
- v.push_back(0x7b);*/
-
-
- BOOST_FOREACH(char cp, make_reversed_range(unicode::u8_encoded(v)))
- std::cout << std::hex << (int)(unsigned char)cp << std::endl;
-
- std::vector<char> v2;
- copy(v, unicode::u8_encoded_out(std::back_inserter(v2)));
-
- BOOST_FOREACH(char32 cp, unicode::utf_decoded(v2))
- std::cout << std::hex << cp << std::endl;
-
- std::cout << std::endl;
-
- BOOST_AUTO(range, unicode::utf_bounded( unicode::u8_encoded(v) ) );
- BOOST_FOREACH_AUTO(code_points, range)
- {
- BOOST_FOREACH_AUTO(cu, code_points)
- std::cout << ' ' << std::hex << (int)(unsigned char)cu;
-
- std::cout << ',';
- }
-
- std::cout << "\n";
-
- char foo[] = "eoaéôn";
- BOOST_FOREACH_AUTO(subrange, unicode::utf_bounded(foo))
- {
- BOOST_FOREACH(unsigned char c, subrange)
- std::cout << c;
-
- std::cout << ' ';
- }
- std::cout << std::endl;
-
- //std::cout << "\n" << boost::unicode::ucd::get_name(0xE9) << std::endl;
- std::cout << boost::unicode::ucd::as_string(boost::unicode::ucd::get_block(0xE9)) << std::endl;
-
- boost::char32 grapheme_test[] = {
- 'f', 'o', 'o', '\r', '\n', 0x113, 0x301, ' ', 0x1e17
- };
-
- BOOST_AUTO(grapheme_utf8_test, unicode::u8_encoded(grapheme_test));
-
- BOOST_FOREACH_AUTO(grapheme, unicode::utf_grapheme_bounded(grapheme_utf8_test))
- {
- std::cout << "(";
- BOOST_FOREACH(unsigned char c, grapheme)
- std::cout << c;
- std::cout << ")";
- }
- std::cout << std::endl << std::endl;
-
- for(const boost::char32* p = ucd::get_decomposition(0x1e17); *p; ++p)
- std::cout << "0x" << std::hex << *p << ' ';
- std::cout << std::endl;
-
- unicode::decomposer<> decomp;
- decomp(0x1e17, std::ostream_iterator<char32>(std::cout, " "));
- std::cout << std::endl << std::endl;
-
- unicode::decomposer<> decomp2;
- decomp2(0xa8, std::ostream_iterator<char32>(std::cout, " "));
- std::cout << std::endl;
- unicode::decomposer<static_pow<2, ucd::decomposition_type::compat>::value> decomp3;
- decomp3(0xa8, std::ostream_iterator<char32>(std::cout, " "));
- std::cout << std::endl;
-
- wchar_t baz[] = L"foo\u00E9";
- std::cout << unicode::u8_encoded(unicode::utf_decoded(baz)) << std::endl;
-
- std::cout << mpl::c_str<
- mpl::string<'foo ', unicode::string_cp<0xe9>::value, ' bar'>
- >::value << std::endl;
-
- std::cout << unicode::latin1_encoded(unicode::utf_decoded(mpl::c_str<
- mpl::u16string<'f', 'o', 'o', ' ', 0xe9, ' ', 'b', 'a', 'r'>
- >::value)) << std::endl;
-}
-//]

Deleted: sandbox/SOC/2009/unicode/libs/unicode/src/Jamfile.v2
==============================================================================
--- sandbox/SOC/2009/unicode/libs/unicode/src/Jamfile.v2 2009-07-29 19:56:22 EDT (Wed, 29 Jul 2009)
+++ (empty file)
@@ -1,20 +0,0 @@
-#==============================================================================
-# Copyright (c) 2009 Mathias Gaunard
-#
-# 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)
-#==============================================================================
-
-project
- : requirements
- <include>../../..
- <include>$(BOOST_ROOT)
- ;
-
-lib boost-unicode
- :
- unicode_properties.cpp
- unicode_blocks.cpp
- unicode_graphemes.cpp
- ucd/uni_ucd_interface_impl_data.cpp ;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk