Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53330 - in sandbox/SOC/2009/unicode: . boost boost/introspection boost/iterator boost/unicode libs/unicode/example libs/unicode/src
From: loufoque_at_[hidden]
Date: 2009-05-27 19:13:33


Author: mgaunard
Date: 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
New Revision: 53330
URL: http://svn.boost.org/trac/boost/changeset/53330

Log:
renaming of pack to pipe + bounded buffer optimization using introspection
Added:
   sandbox/SOC/2009/unicode/boost/cuchar.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/introspection/
   sandbox/SOC/2009/unicode/boost/introspection/has_member_data.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/introspection/has_member_function.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/introspection/traits.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator.hpp (contents, props changed)
      - copied, changed from r52858, /sandbox/SOC/2009/unicode/boost/iterator/pack_iterator.hpp
   sandbox/SOC/2009/unicode/boost/unicode/unicode_proprieties.hpp (contents, props changed)
   sandbox/SOC/2009/unicode/boost/unicode/utf_conversion.hpp (contents, props changed)
      - copied, changed from r52858, /sandbox/SOC/2009/unicode/boost/unicode/unicode_iterator.hpp
Removed:
   sandbox/SOC/2009/unicode/boost/iterator/pack_iterator.hpp
   sandbox/SOC/2009/unicode/boost/unicode/unicode_iterator.hpp
Text files modified:
   sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator.hpp | 245 +++++++++++++++++++++++++++++----------
   sandbox/SOC/2009/unicode/boost/unicode/utf_conversion.hpp | 231 +++++++++++++++++--------------------
   sandbox/SOC/2009/unicode/libs/unicode/example/Jamfile.v2 | 1
   sandbox/SOC/2009/unicode/libs/unicode/example/test.cpp | 8
   sandbox/SOC/2009/unicode/libs/unicode/src/Jamfile.v2 | 1
   sandbox/SOC/2009/unicode/libs/unicode/src/src.cpp | 2
   sandbox/SOC/2009/unicode/project-root.jam | 3
   7 files changed, 295 insertions(+), 196 deletions(-)

Added: sandbox/SOC/2009/unicode/boost/cuchar.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/cuchar.hpp 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
@@ -0,0 +1,22 @@
+#ifndef BOOST_CUCHAR_HPP
+#define BOOST_CUCHAR_HPP
+
+#include <boost/cstdint.hpp>
+
+namespace boost
+{
+#ifdef BOOST_NO_CHAR16_T
+ typedef boost::uint_least16_t char16;
+#else
+ typedef char16_t char16;
+#endif
+
+#ifdef BOOST_NO_CHAR32_T
+ typedef boost::uint_least32_t char32;
+#else
+ typedef char32_t char32;
+#endif
+
+} // namespace boost
+
+#endif

Added: sandbox/SOC/2009/unicode/boost/introspection/has_member_data.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/introspection/has_member_data.hpp 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
@@ -0,0 +1,54 @@
+#ifndef __BOOS_INTROSPECTION__HAS_MEMBER_DATA_HPP__INCLUDED
+#define __BOOS_INTROSPECTION__HAS_MEMBER_DATA_HPP__INCLUDED
+
+#include <boost/mpl/bool.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/introspection/traits.hpp>
+
+////////////////////////////////////////////////////////////////////////////////
+// Generate a traits class that detect if a given type X has a member data
+// named Name of type Type. This class can only detects public member data or
+// member data that have been explicitly registered as 'traits visible' by the
+// BOOST_INTROSPECTION_SUPPORT macro.
+////////////////////////////////////////////////////////////////////////////////
+#define BOOST_HAS_MEMBER_DATA(Type,Name) \
+ template<class T> struct BOOST_PP_CAT(has_member_data_,Name) \
+ { \
+ typedef char NotFound; \
+ struct Found { char x[2]; }; \
+ \
+ template< class X, Type X::*> struct member {}; \
+ \
+ template<class X> static Found test(member<X,&X::Name>*); \
+ template<class X> static NotFound test( ... ); \
+ \
+ static const bool value = (sizeof(Found) == sizeof(test<T>(0))); \
+ typedef mpl::bool_<value> type; \
+ }; \
+/**/
+
+#define BOOST_HAS_STATIC_MEMBER_DATA(Type,Name) \
+ template<class T> struct BOOST_PP_CAT(has_static_member_data_,Name) \
+ { \
+ typedef char NotFound; \
+ struct Found { char x[2]; }; \
+ \
+ template< class X, Type*> struct member {}; \
+ \
+ template<class X> static Found test(member<X,&X::Name>*); \
+ template<class X> static NotFound test( ... ); \
+ \
+ static const bool value = (sizeof(Found) == sizeof(test<T>(0))); \
+ typedef mpl::bool_<value> type; \
+ }; \
+/**/
+
+////////////////////////////////////////////////////////////////////////////////
+// Used in a class, make the member data Name visible by the boost::introspection
+// traits class.
+////////////////////////////////////////////////////////////////////////////////
+#define BOOST_INTROSPECTION_SUPPORT(Class,Name) \
+friend class BOOST_PP_CAT(has_member_data_,Name)<Class>\
+/**/
+
+#endif

Added: sandbox/SOC/2009/unicode/boost/introspection/has_member_function.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/introspection/has_member_function.hpp 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
@@ -0,0 +1,71 @@
+#ifndef __BOOS_INTROSPECTION__HAS_MEMBER_FUNCTION_HPP__INCLUDED
+#define __BOOS_INTROSPECTION__HAS_MEMBER_FUNCTION_HPP__INCLUDED
+
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/or.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/introspection/traits.hpp>
+
+////////////////////////////////////////////////////////////////////////////////
+// Generate a traits class that detect if a given type X has a non-const member
+// function named Name with a given signature Sig.
+////////////////////////////////////////////////////////////////////////////////
+#define BOOST_HAS_NON_CONST_MEMBER_FUNCTION(Name,Sig) \
+ template<class T> \
+ struct BOOST_PP_CAT(has_non_const_member_function_,Name) \
+ { \
+ typedef char NotFound; \
+ struct Found { char x[2]; }; \
+ \
+ template< class X \
+ , typename build_member_type<X,Sig>::type \
+ > struct member {}; \
+ \
+ template<class X> static Found test(member<X,&X::Name>*); \
+ template<class X> static NotFound test( ... ); \
+ \
+ static const bool value = (sizeof(Found) == sizeof(test<T>(0))); \
+ typedef mpl::bool_<value> type; \
+ }; \
+/**/
+
+////////////////////////////////////////////////////////////////////////////////
+// Generate a traits class that detect if a given type X has a const member
+// function named Name with a given signature Sig.
+////////////////////////////////////////////////////////////////////////////////
+#define BOOST_HAS_CONST_MEMBER_FUNCTION(Name,Sig) \
+ \
+ template<class T> \
+ struct BOOST_PP_CAT(has_const_member_function_,Name) \
+ { \
+ typedef char NotFound; \
+ struct Found { char x[2]; }; \
+ \
+ template< class X \
+ , typename build_const_member_type<X,Sig>::type \
+ > struct member {}; \
+ \
+ template<class X> static Found test(member<X,&X::Name>*); \
+ template<class X> static NotFound test( ... ); \
+ \
+ static const bool value = (sizeof(Found) == sizeof(test<T>(0))); \
+ typedef mpl::bool_<value> type; \
+ }; \
+/**/
+
+////////////////////////////////////////////////////////////////////////////////
+// Generate a traits class that detect if a given type X has a member function
+// named Name with a given signature Sig which is either const or non-const
+////////////////////////////////////////////////////////////////////////////////
+#define BOOST_HAS_MEMBER_FUNCTION(Name,Sig) \
+BOOST_HAS_CONST_MEMBER_FUNCTION(Name,Sig) \
+BOOST_HAS_NON_CONST_MEMBER_FUNCTION(Name,Sig) \
+ \
+ template<class T> \
+ struct BOOST_PP_CAT(has_member_function_,Name) : \
+ mpl::or_< BOOST_PP_CAT(has_const_member_function_,Name)<T> \
+ , BOOST_PP_CAT(has_non_const_member_function_,Name)<T> \
+ > {}; \
+ \
+/**/
+#endif

Added: sandbox/SOC/2009/unicode/boost/introspection/traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/introspection/traits.hpp 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
@@ -0,0 +1,50 @@
+#ifndef __BOOS_INTROSPECTION__TRAITS_HPP__INCLUDED
+#define __BOOS_INTROSPECTION__TRAITS_HPP__INCLUDED
+
+#include <boost/function_types/result_type.hpp>
+#include <boost/function_types/parameter_types.hpp>
+#include <boost/function_types/member_function_pointer.hpp>
+#include <boost/function_types/property_tags.hpp>
+
+namespace boost
+{
+ namespace introspection
+ {
+ ////////////////////////////////////////////////////////////////////////////
+ // Build a MPL sequence correspondign to the components of a member function
+ // type of class X with signature similar to Prototype.
+ // E.g :
+ // function_to_member<foo, void(int,long)>::type => <void,foo*,int,long>
+ //
+ ////////////////////////////////////////////////////////////////////////////
+ template<class X, class Prototype> struct function_to_member
+ {
+ typedef typename function_types::result_type<Prototype>::type result;
+ typedef typename function_types::parameter_types<Prototype>::type args;
+ typedef typename mpl::push_front<args,X*>::type base;
+ typedef typename mpl::push_front<base,result>::type type;
+ };
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Turn a class and a function type into a member function pointer with the
+ // same signature.
+ ////////////////////////////////////////////////////////////////////////////
+ template<class X, class Prototype> struct build_member_type
+ {
+ typedef typename function_to_member<X,Prototype>::type root;
+ typedef typename function_types::member_function_pointer<root>::type type;
+ };
+
+ ////////////////////////////////////////////////////////////////////////////
+ // Turn a class and a function type into a const member function pointer
+ // with the same signature.
+ ////////////////////////////////////////////////////////////////////////////
+ template<class X, class Prototype> struct build_const_member_type
+ {
+ typedef typename function_to_member<X,Prototype>::type root;
+ typedef typename function_types::member_function_pointer<root,function_types::const_qualified>::type type;
+ };
+ }
+}
+
+#endif

Deleted: sandbox/SOC/2009/unicode/boost/iterator/pack_iterator.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/iterator/pack_iterator.hpp 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
+++ (empty file)
@@ -1,167 +0,0 @@
-#ifndef BOOST_PACK_ITERATOR_HPP
-#define BOOST_BACK_ITERATOR_HPP
-
-#include <boost/iterator/iterator_facade.hpp>
-#include <iterator>
-#include <vector>
-#include <utility>
-#include <boost/range.hpp>
-
-#include <iostream>
-
-namespace boost
-{
-
-template<typename P>
-struct packer
-{
- packer(P p_) : p(p_)
- {
- }
-
- typedef typename P::output_type output_type;
-
- template<typename Range, typename It>
- std::pair<
- typename boost::range_iterator<Range>::type,
- It
- >
- left(const Range& in, It out)
- {
- assert(!boost::empty(in));
-
- p(*boost::begin(in), out);
- return std::make_pair(++boost::begin(in), out);
- }
-
- template<typename Range, typename OutputIterator>
- std::pair<
- typename boost::range_iterator<Range>::type,
- OutputIterator
- >
- right(const Range& in, OutputIterator out)
- {
- assert(!boost::empty(in));
-
- p(*--boost::end(in), out);
- return std::make_pair(--boost::end(in), out);
- }
-
-private:
- P p;
-};
-
-template<typename P>
-packer<P> make_packer(P p)
-{
- return packer<P>(p);
-}
-
-template<typename It, typename Packer>
-struct pack_iterator
- : boost::iterator_facade<
- pack_iterator<It, Packer>,
- typename Packer::output_type,
- std::bidirectional_iterator_tag,
- const typename Packer::output_type
- >
-{
- typedef boost::iterator_facade<
- pack_iterator<It, Packer>,
- typename Packer::output_type,
- std::bidirectional_iterator_tag,
- const typename Packer::output_type
- > base_type;
-
- pack_iterator(It begin_, It pos_, It end_, Packer p_) : pos(pos_), begin(begin_), end(end_), index(0), p(p_)
- {
- if(pos != end)
- next_pos = p.left(std::make_pair(pos, end), std::back_inserter(values)).first;
- }
-
- It base() const
- {
- return pos;
- }
-
-private:
- typedef typename Packer::output_type T;
-
- friend class boost::iterator_core_access;
-
- typename base_type::reference dereference() const
- {
- return values[index];
- }
-
- void increment()
- {
- if(index != values.size()-1)
- {
- index++;
- }
- else
- {
- values.clear();
-
- pos = next_pos;
- if(pos != end)
- next_pos = p.left(std::make_pair(pos, end), std::back_inserter(values)).first;
- index = 0;
- }
- }
-
- void decrement()
- {
- if(index != 0)
- {
- index--;
- }
- else
- {
- values.clear();
-
- next_pos = pos;
- pos = p.right(std::make_pair(begin, pos), std::back_inserter(values)).first;
- index = values.size()-1;
- }
- }
-
- bool equal(const pack_iterator& other) const
- {
- return pos == other.pos && index == other.index;
- }
-
- It pos;
- It next_pos;
-
- It begin;
- It end;
- size_t index;
-
- Packer p;
-
- std::vector<T> values;
-};
-
-template<typename It, typename P>
-pack_iterator<It, P> make_pack_iterator(It begin, It pos, It end, P p)
-{
- return pack_iterator<It, P>(begin, pos, end, p);
-}
-
-template<typename Range, typename P>
-std::pair<
- pack_iterator<typename boost::range_iterator<const Range>::type, P>,
- pack_iterator<typename boost::range_iterator<const Range>::type, P>
-> make_pack_range(const Range& range, P p)
-{
- return std::make_pair(
- make_pack_iterator(boost::begin(range), boost::begin(range), boost::end(range), p),
- make_pack_iterator(boost::begin(range), boost::end(range), boost::end(range), p)
- );
-}
-
-} // namespace boost
-
-#endif

Copied: sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator.hpp (from r52858, /sandbox/SOC/2009/unicode/boost/iterator/pack_iterator.hpp)
==============================================================================
--- /sandbox/SOC/2009/unicode/boost/iterator/pack_iterator.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/iterator/pipe_iterator.hpp 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
@@ -1,82 +1,144 @@
-#ifndef BOOST_PACK_ITERATOR_HPP
-#define BOOST_BACK_ITERATOR_HPP
+#ifndef BOOST_PIPE_ITERATOR_HPP
+#define BOOST_PIPE_ITERATOR_HPP
 
 #include <boost/iterator/iterator_facade.hpp>
 #include <iterator>
 #include <vector>
 #include <utility>
+
 #include <boost/range.hpp>
+#include <boost/assert.hpp>
 
-#include <iostream>
+#include <boost/introspection/has_member_data.hpp>
+#include <boost/utility/enable_if.hpp>
 
 namespace boost
 {
+namespace detail
+{
+ BOOST_HAS_STATIC_MEMBER_DATA(const int, max_output)
+
+ template<typename P, typename Enable = void>
+ struct pipe_output_storage;
+
+ template<typename P>
+ struct pipe_output_storage<P, typename ::boost::disable_if< has_static_member_data_max_output<P> >::type>
+ {
+private:
+ typedef std::vector<typename P::output_type> Values;
+public:
+ typedef std::back_insert_iterator<Values> output_iterator;
+
+ const typename P::output_value& operator[](size_t i) const
+ {
+ return values[i];
+ }
+
+ size_t last_index() const
+ {
+ return values.size() - 1;
+ }
+
+ output_iterator out()
+ {
+ values.clear();
+ return std::back_inserter(values);
+ }
+
+ void update(output_iterator)
+ {
+ }
+
+ private:
+ Values values;
+ };
+
+ template<typename P>
+ struct pipe_output_storage<P, typename boost::enable_if< has_static_member_data_max_output<P> >::type>
+ {
+private:
+ typedef typename P::output_type Value;
+public:
+ typedef Value* output_iterator;
+
+ const Value& operator[](size_t i) const
+ {
+ return values[i];
+ }
+
+ size_t last_index() const
+ {
+ return last;
+ }
+
+ output_iterator out()
+ {
+ return values;
+ }
+
+ void update(output_iterator u)
+ {
+ last = u - values - 1;
+ }
+
+ private:
+ Value values[P::max_output];
+ size_t last;
+ };
+}
 
 template<typename P>
-struct packer
+struct one_many_pipe : P
 {
- packer(P p_) : p(p_)
+ one_many_pipe(P p_) : P(p_)
         {
         }
         
- typedef typename P::output_type output_type;
-
- template<typename Range, typename It>
- std::pair<
- typename boost::range_iterator<Range>::type,
- It
- >
- left(const Range& in, It out)
+ template<typename In, typename Out>
+ std::pair<In, Out>
+ ltr(In begin, In end, Out out)
         {
- assert(!boost::empty(in));
+ BOOST_ASSERT(begin != end);
                 
- p(*boost::begin(in), out);
- return std::make_pair(++boost::begin(in), out);
+ out = (*this)(*begin, out);
+ return std::make_pair(++begin, out);
         }
         
- template<typename Range, typename OutputIterator>
- std::pair<
- typename boost::range_iterator<Range>::type,
- OutputIterator
- >
- right(const Range& in, OutputIterator out)
+ template<typename In, typename Out>
+ std::pair<In, Out>
+ rtl(In begin, In end, Out out)
         {
- assert(!boost::empty(in));
+ BOOST_ASSERT(begin != end);
                 
- p(*--boost::end(in), out);
- return std::make_pair(--boost::end(in), out);
+ out = (*this)(*--end, out);
+ return std::make_pair(end, out);
         }
-
-private:
- P p;
 };
 
 template<typename P>
-packer<P> make_packer(P p)
+one_many_pipe<P> make_one_many_pipe(P p)
 {
- return packer<P>(p);
+ return one_many_pipe<P>(p);
 }
 
-template<typename It, typename Packer>
-struct pack_iterator
+template<typename It, typename Pipe>
+struct pipe_iterator
         : boost::iterator_facade<
- pack_iterator<It, Packer>,
- typename Packer::output_type,
+ pipe_iterator<It, Pipe>,
+ typename Pipe::output_type,
                 std::bidirectional_iterator_tag,
- const typename Packer::output_type
+ const typename Pipe::output_type
>
 {
- typedef boost::iterator_facade<
- pack_iterator<It, Packer>,
- typename Packer::output_type,
- std::bidirectional_iterator_tag,
- const typename Packer::output_type
- > base_type;
-
- pack_iterator(It begin_, It pos_, It end_, Packer p_) : pos(pos_), begin(begin_), end(end_), index(0), p(p_)
+ pipe_iterator(It begin_, It pos_, It end_, Pipe p_) : pos(pos_), begin(begin_), end(end_), index(0), p(p_)
         {
- if(pos != end)
- next_pos = p.left(std::make_pair(pos, end), std::back_inserter(values)).first;
+ if(pos != end)
+ {
+ std::pair<It, typename detail::pipe_output_storage<Pipe>::output_iterator> pair =
+ p.ltr(pos, end, values.out());
+ next_pos = pair.first;
+ values.update(pair.second);
+ }
         }
         
         It base() const
@@ -85,28 +147,31 @@
         }
         
 private:
- typedef typename Packer::output_type T;
+ typedef typename Pipe::output_type T;
 
         friend class boost::iterator_core_access;
 
- typename base_type::reference dereference() const
+ T dereference() const
         {
                 return values[index];
         }
         
         void increment()
         {
- if(index != values.size()-1)
+ if(index != values.last_index())
                 {
                         index++;
                 }
                 else
- {
- values.clear();
-
+ {
                         pos = next_pos;
                         if(pos != end)
- next_pos = p.left(std::make_pair(pos, end), std::back_inserter(values)).first;
+ {
+ std::pair<It, typename detail::pipe_output_storage<Pipe>::output_iterator> pair =
+ p.ltr(pos, end, values.out());
+ next_pos = pair.first;
+ values.update(pair.second);
+ }
                         index = 0;
                 }
         }
@@ -118,16 +183,19 @@
                         index--;
                 }
                 else
- {
- values.clear();
-
+ {
                         next_pos = pos;
- pos = p.right(std::make_pair(begin, pos), std::back_inserter(values)).first;
- index = values.size()-1;
+
+ std::pair<It, typename detail::pipe_output_storage<Pipe>::output_iterator> pair =
+ p.rtl(begin, pos, values.out());
+ pos = pair.first;
+ values.update(pair.second);
+
+ index = values.last_index();
                 }
         }
         
- bool equal(const pack_iterator& other) const
+ bool equal(const pipe_iterator& other) const
         {
                 return pos == other.pos && index == other.index;
         }
@@ -139,29 +207,72 @@
         It end;
         size_t index;
         
- Packer p;
+ Pipe p;
         
- std::vector<T> values;
+ detail::pipe_output_storage<Pipe> values;
 };
 
 template<typename It, typename P>
-pack_iterator<It, P> make_pack_iterator(It begin, It pos, It end, P p)
+pipe_iterator<It, P> make_pipe_iterator(It begin, It pos, It end, P p)
 {
- return pack_iterator<It, P>(begin, pos, end, p);
+ return pipe_iterator<It, P>(begin, pos, end, p);
 }
 
 template<typename Range, typename P>
 std::pair<
- pack_iterator<typename boost::range_iterator<const Range>::type, P>,
- pack_iterator<typename boost::range_iterator<const Range>::type, P>
-> make_pack_range(const Range& range, P p)
+ pipe_iterator<typename boost::range_iterator<const Range>::type, P>,
+ pipe_iterator<typename boost::range_iterator<const Range>::type, P>
+> make_pipe_range(const Range& range, P p)
 {
         return std::make_pair(
- make_pack_iterator(boost::begin(range), boost::begin(range), boost::end(range), p),
- make_pack_iterator(boost::begin(range), boost::end(range), boost::end(range), p)
+ make_pipe_iterator(boost::begin(range), boost::begin(range), boost::end(range), p),
+ make_pipe_iterator(boost::begin(range), boost::end(range), boost::end(range), p)
         );
 }
 
+template<typename It, typename Pipe>
+struct pipe_output_iterator
+{
+ pipe_output_iterator(It pos_, Pipe p_) : pos(pos_), p(p_)
+ {
+ }
+
+ It base() const
+ {
+ return pos;
+ }
+
+ pipe_output_iterator& operator*() const
+ {
+ return const_cast<pipe_output_iterator&>(*this);
+ }
+
+ pipe_output_iterator& operator++()
+ {
+ return *this;
+ }
+
+ pipe_output_iterator& operator++(int)
+ {
+ return *this;
+ }
+
+ void operator=(typename Pipe::output_type val) const
+ {
+ pos = p.ltr(&val, &val + 1, pos).second;
+ }
+
+private:
+ It pos;
+ Pipe p;
+};
+
+template<typename OutputIterator, typename P>
+pipe_output_iterator<OutputIterator, P> make_pipe_output_iterator(OutputIterator out, P p)
+{
+ return pipe_output_iterator<OutputIterator, P>(out, p);
+}
+
 } // namespace boost
 
 #endif

Deleted: sandbox/SOC/2009/unicode/boost/unicode/unicode_iterator.hpp
==============================================================================
--- sandbox/SOC/2009/unicode/boost/unicode/unicode_iterator.hpp 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
+++ (empty file)
@@ -1,371 +0,0 @@
-#ifndef BOOST_UNICODE_ITERATOR_HPP
-#define BOOST_UNICODE_ITERATOR_HPP
-
-#include <boost/cstdint.hpp>
-#include <boost/assert.hpp>
-#include <boost/static_assert.hpp>
-#include <boost/throw_exception.hpp>
-#include <stdexcept>
-#ifndef BOOST_NO_STD_LOCALE
-#include <sstream>
-#include <ios>
-#endif
-#include <limits.h> // CHAR_BIT
-
-#include <boost/iterator/pack_iterator.hpp>
-
-namespace boost
-{
-
-namespace detail
-{
-
-static const ::boost::uint16_t high_surrogate_base = 0xD7C0u;
-static const ::boost::uint16_t low_surrogate_base = 0xDC00u;
-static const ::boost::uint32_t ten_bit_mask = 0x3FFu;
-
-inline bool is_high_surrogate(::boost::uint16_t v)
-{
- return (v & 0xFC00u) == 0xd800u;
-}
-inline bool is_low_surrogate(::boost::uint16_t v)
-{
- return (v & 0xFC00u) == 0xdc00u;
-}
-template <class T>
-inline bool is_surrogate(T v)
-{
- return (v & 0xF800u) == 0xd800;
-}
-
-inline unsigned utf8_byte_count(boost::uint8_t c)
-{
- // if the most significant bit with a zero in it is in position
- // 8-N then there are N bytes in this UTF-8 sequence:
- boost::uint8_t mask = 0x80u;
- unsigned result = 0;
- while(c & mask)
- {
- ++result;
- mask >>= 1;
- }
- return (result == 0) ? 1 : ((result > 4) ? 4 : result);
-}
-
-inline unsigned utf8_trailing_byte_count(boost::uint8_t c)
-{
- return utf8_byte_count(c) - 1;
-}
-
-inline void invalid_code_point(::boost::uint32_t val)
-{
-#ifndef BOOST_NO_STD_LOCALE
- std::stringstream ss;
- ss << "Invalid UTF-32 code point U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-16 sequence";
- std::out_of_range e(ss.str());
-#else
- std::out_of_range e("Invalid UTF-32 code point encountered while trying to encode UTF-16 sequence");
-#endif
- boost::throw_exception(e);
-}
-
-template<typename Range>
-inline void invalid_utf_sequence(const Range& r)
-{
-#ifndef BOOST_NO_STD_LOCALE
- std::stringstream ss;
- ss << "Invalid UTF sequence " << std::showbase << std::hex;
- for(typename boost::range_iterator<const Range>::type it = boost::begin(r); it != boost::end(r); ++it)
- ss << *it << " ";
- ss << "encountered while trying to decode UTF-32 sequence";
- std::out_of_range e(ss.str());
-#else
- std::out_of_range e("Invalid UTF sequence encountered while trying to decode UTF-32 sequence");
-#endif
- boost::throw_exception(e);
-}
-
-struct u16_packer
-{
- typedef boost::uint16_t output_type;
-
- template<typename OutputIterator>
- OutputIterator operator()(boost::uint32_t v, OutputIterator out)
- {
- if(v >= 0x10000u)
- {
- if(v > 0x10FFFFu)
- detail::invalid_code_point(v);
-
- // split into two surrogates:
- output_type hi = static_cast<output_type>(v >> 10) + detail::high_surrogate_base;
- output_type lo = static_cast<output_type>(v & detail::ten_bit_mask) + detail::low_surrogate_base;
-
- BOOST_ASSERT(detail::is_high_surrogate(hi));
- BOOST_ASSERT(detail::is_low_surrogate(lo));
-
- *out++ = hi;
- *out++ = lo;
- }
- else
- {
- // 16-bit code point:
- output_type cp = static_cast<output_type>(v);
-
- // value must not be a surrogate:
- if(detail::is_surrogate(cp))
- detail::invalid_code_point(v);
-
- *out++ = cp;
- }
-
- return out;
- }
-};
-
-struct u16_unpacker
-{
- typedef boost::uint32_t output_type;
-
- template<typename Range, typename It>
- std::pair<
- typename boost::range_iterator<Range>::type,
- It
- >
- left(const Range& in, It out)
- {
- assert(!boost::empty(in));
-
- typename boost::range_iterator<const Range>::type it(boost::begin(in));
-
- boost::uint32_t value = *it;
-
- if(detail::is_high_surrogate(value))
- {
- if(++it == boost::end(in))
- detail::invalid_utf_sequence(in);
-
- // precondition; next value must have be a low-surrogate:
- boost::uint16_t lo = *it;
- if(!detail::is_low_surrogate(lo))
- detail::invalid_code_point(lo);
-
- value = code_point(value, lo);
- }
- // postcondition; result must not be a surrogate:
- if(detail::is_surrogate(value))
- detail::invalid_code_point(static_cast<boost::uint16_t>(value));
-
- *out++ = value;
-
- return std::make_pair(++it, out);
- }
-
- template<typename Range, typename OutputIterator>
- std::pair<
- typename boost::range_iterator<Range>::type,
- OutputIterator
- >
- right(const Range& in, OutputIterator out)
- {
- assert(!boost::empty(in));
-
- typename boost::range_iterator<const Range>::type it = --boost::end(in);
-
- boost::uint32_t value = *it;
-
- if(detail::is_low_surrogate(value))
- {
- if(it == boost::begin(in))
- invalid_utf_sequence(in);
- --it;
-
- boost::uint16_t hi = *it;
- if(!detail::is_high_surrogate(hi))
- invalid_code_point(hi);
-
- value = code_point(hi, value);
- }
- // postcondition; result must not be a surrogate:
- if(detail::is_surrogate(value))
- invalid_code_point(static_cast<boost::uint16_t>(value));
-
- *out++ = value;
-
- return std::make_pair(it, out);
- }
-
-private:
- boost::uint32_t code_point(boost::uint16_t hi, boost::uint16_t lo)
- {
- return ((hi - detail::high_surrogate_base) << 10)
- | (static_cast<boost::uint32_t>(static_cast<boost::uint16_t>(lo)) & detail::ten_bit_mask);
- }
-};
-
-struct u8_packer
-{
- typedef boost::uint8_t output_type;
-
- template<typename OutputIterator>
- OutputIterator operator()(boost::uint32_t c, OutputIterator out)
- {
- if(c > 0x10FFFFu)
- detail::invalid_code_point(c);
-
- if(c < 0x80u)
- {
- *out++ = static_cast<unsigned char>(c);
- }
- else if(c < 0x800u)
- {
- *out++ = static_cast<unsigned char>(0xC0u + (c >> 6));
- *out++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
- }
- else if(c < 0x10000u)
- {
- *out++ = static_cast<unsigned char>(0xE0u + (c >> 12));
- *out++ = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu));
- *out++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
- }
- else
- {
- *out++ = static_cast<unsigned char>(0xF0u + (c >> 18));
- *out++ = static_cast<unsigned char>(0x80u + ((c >> 12) & 0x3Fu));
- *out++ = static_cast<unsigned char>(0x80u + ((c >> 6) & 0x3Fu));
- *out++ = static_cast<unsigned char>(0x80u + (c & 0x3Fu));
- }
-
- return out;
- }
-};
-
-struct u8_unpacker
-{
- typedef boost::uint32_t output_type;
-
- template<typename Range, typename It>
- std::pair<
- typename boost::range_iterator<Range>::type,
- It
- >
- left(const Range& in, It out)
- {
- assert(!boost::empty(in));
-
- typename boost::range_iterator<const Range>::type it(boost::begin(in));
-
- boost::uint32_t value = *it;
-
- if((value & 0xC0u) == 0x80u)
- detail::invalid_utf_sequence(in);
-
- // see how many extra byts we have:
- unsigned extra = detail::utf8_trailing_byte_count(value);
- // extract the extra bits, 6 from each extra byte:
-
- for(unsigned c = 0; c < extra; ++c)
- {
- if(++it == boost::end(in))
- detail::invalid_utf_sequence(in);
-
- value <<= 6;
- value += static_cast<boost::uint8_t>(*it) & 0x3Fu;
- }
-
- // we now need to remove a few of the leftmost bits, but how many depends
- // upon how many extra bytes we've extracted:
- static const boost::uint32_t masks[4] =
- {
- 0x7Fu,
- 0x7FFu,
- 0xFFFFu,
- 0x1FFFFFu,
- };
- value &= masks[extra];
-
- // check the result:
- if(value > static_cast<boost::uint32_t>(0x10FFFFu))
- invalid_utf_sequence(in);
-
- *out++ = value;
-
- return std::make_pair(++it, out);
- }
-
- template<typename Range, typename OutputIterator>
- std::pair<
- typename boost::range_iterator<Range>::type,
- OutputIterator
- >
- right(const Range& in, OutputIterator out)
- {
- assert(!boost::empty(in));
-
- typename boost::range_iterator<const Range>::type it = --boost::end(in);
-
- boost::uint32_t value = *it;
-
- // Keep backtracking until we don't have a trailing character:
- unsigned count = 0;
- while((*it & 0xC0u) == 0x80u)
- {
- if(count >= 4 || it == boost::begin(in))
- invalid_utf_sequence(in);
-
- --it;
- ++count;
- }
-
- // now check that the sequence was valid:
- if(count != detail::utf8_trailing_byte_count(value))
- invalid_utf_sequence(in);
-
- out = left(std::make_pair(it, boost::end(in)), out).second;
- return std::make_pair(it, out);
- }
-};
-
-} // namespace detail
-
-template<typename Range>
-std::pair<
- pack_iterator<typename boost::range_iterator<const Range>::type, packer<detail::u16_packer> >,
- pack_iterator<typename boost::range_iterator<const Range>::type, packer<detail::u16_packer> >
-> make_u32_to_u16_range(const Range& range)
-{
- return make_pack_range(range, make_packer(detail::u16_packer()));
-}
-
-template<typename Range>
-std::pair<
- pack_iterator<typename boost::range_iterator<const Range>::type, detail::u16_unpacker>,
- pack_iterator<typename boost::range_iterator<const Range>::type, detail::u16_unpacker>
-> make_u16_to_u32_range(const Range& range)
-{
- return make_pack_range(range, detail::u16_unpacker());
-}
-
-template<typename Range>
-std::pair<
- pack_iterator<typename boost::range_iterator<const Range>::type, packer<detail::u8_packer> >,
- pack_iterator<typename boost::range_iterator<const Range>::type, packer<detail::u8_packer> >
-> make_u32_to_u8_range(const Range& range)
-{
- return make_pack_range(range, make_packer(detail::u8_packer()));
-}
-
-template<typename Range>
-std::pair<
- pack_iterator<typename boost::range_iterator<const Range>::type, detail::u8_unpacker>,
- pack_iterator<typename boost::range_iterator<const Range>::type, detail::u8_unpacker>
-> make_u8_to_u32_range(const Range& range)
-{
- return make_pack_range(range, detail::u8_unpacker());
-}
-
-//TODO: output iterators
-
-} // namespace boost
-
-#endif

Added: sandbox/SOC/2009/unicode/boost/unicode/unicode_proprieties.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2009/unicode/boost/unicode/unicode_proprieties.hpp 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
@@ -0,0 +1,29 @@
+#ifndef BOOST_UNICODE_PROPRIETIES
+#define BOOST_UNICODE_PROPRIETIES
+
+#include <boost/cuchar.hpp>
+
+namespace boost
+{
+namespace unicode
+{
+
+inline bool is_high_surrogate(char32 v)
+{
+ return (v & 0xFC00u) == 0xd800u;
+}
+
+inline bool is_low_surrogate(char32 v)
+{
+ return (v & 0xFC00u) == 0xdc00u;
+}
+
+inline bool is_surrogate(char32 v)
+{
+ return (v & 0xF800u) == 0xd800;
+}
+
+} // namespace unicode
+} // namespace boost
+
+#endif

Copied: sandbox/SOC/2009/unicode/boost/unicode/utf_conversion.hpp (from r52858, /sandbox/SOC/2009/unicode/boost/unicode/unicode_iterator.hpp)
==============================================================================
--- /sandbox/SOC/2009/unicode/boost/unicode/unicode_iterator.hpp (original)
+++ sandbox/SOC/2009/unicode/boost/unicode/utf_conversion.hpp 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
@@ -1,48 +1,32 @@
-#ifndef BOOST_UNICODE_ITERATOR_HPP
-#define BOOST_UNICODE_ITERATOR_HPP
+#ifndef BOOST_UTF_CONVERSION_HPP
+#define BOOST_UTF_CONVERSION_HPP
 
-#include <boost/cstdint.hpp>
 #include <boost/assert.hpp>
-#include <boost/static_assert.hpp>
 #include <boost/throw_exception.hpp>
 #include <stdexcept>
 #ifndef BOOST_NO_STD_LOCALE
 #include <sstream>
 #include <ios>
 #endif
-#include <limits.h> // CHAR_BIT
 
-#include <boost/iterator/pack_iterator.hpp>
+#include <boost/iterator/pipe_iterator.hpp>
+#include <boost/unicode/unicode_proprieties.hpp>
 
 namespace boost
 {
 
 namespace detail
 {
-
-static const ::boost::uint16_t high_surrogate_base = 0xD7C0u;
-static const ::boost::uint16_t low_surrogate_base = 0xDC00u;
-static const ::boost::uint32_t ten_bit_mask = 0x3FFu;
-
-inline bool is_high_surrogate(::boost::uint16_t v)
-{
- return (v & 0xFC00u) == 0xd800u;
-}
-inline bool is_low_surrogate(::boost::uint16_t v)
-{
- return (v & 0xFC00u) == 0xdc00u;
-}
-template <class T>
-inline bool is_surrogate(T v)
-{
- return (v & 0xF800u) == 0xd800;
-}
+
+static const char16 high_surrogate_base = 0xD7C0u;
+static const char16 low_surrogate_base = 0xDC00u;
+static const char32 ten_bit_mask = 0x3FFu;
 
-inline unsigned utf8_byte_count(boost::uint8_t c)
+inline unsigned utf8_byte_count(uint8_t c)
 {
    // if the most significant bit with a zero in it is in position
    // 8-N then there are N bytes in this UTF-8 sequence:
- boost::uint8_t mask = 0x80u;
+ uint8_t mask = 0x80u;
    unsigned result = 0;
    while(c & mask)
    {
@@ -52,45 +36,46 @@
    return (result == 0) ? 1 : ((result > 4) ? 4 : result);
 }
 
-inline unsigned utf8_trailing_byte_count(boost::uint8_t c)
+inline unsigned utf8_trailing_byte_count(uint8_t c)
 {
    return utf8_byte_count(c) - 1;
 }
 
-inline void invalid_code_point(::boost::uint32_t val)
+inline void invalid_code_point(char32 val)
 {
 #ifndef BOOST_NO_STD_LOCALE
         std::stringstream ss;
- ss << "Invalid UTF-32 code point U+" << std::showbase << std::hex << val << " encountered while trying to encode UTF-16 sequence";
+ ss << "Invalid UTF-32 code point U+" << std::showbase << std::hex << (uint_least32_t)val << " encountered while trying to encode UTF-16 sequence";
         std::out_of_range e(ss.str());
 #else
         std::out_of_range e("Invalid UTF-32 code point encountered while trying to encode UTF-16 sequence");
 #endif
- boost::throw_exception(e);
+ throw_exception(e);
 }
 
-template<typename Range>
-inline void invalid_utf_sequence(const Range& r)
+template<typename Iterator>
+inline void invalid_utf_sequence(Iterator begin, Iterator end)
 {
 #ifndef BOOST_NO_STD_LOCALE
         std::stringstream ss;
         ss << "Invalid UTF sequence " << std::showbase << std::hex;
- for(typename boost::range_iterator<const Range>::type it = boost::begin(r); it != boost::end(r); ++it)
+ for(Iterator it = begin; it != end; ++it)
                 ss << *it << " ";
         ss << "encountered while trying to decode UTF-32 sequence";
         std::out_of_range e(ss.str());
 #else
         std::out_of_range e("Invalid UTF sequence encountered while trying to decode UTF-32 sequence");
 #endif
- boost::throw_exception(e);
+ throw_exception(e);
 }
 
 struct u16_packer
 {
- typedef boost::uint16_t output_type;
+ typedef char16 output_type;
+ static const int max_output = 2;
         
         template<typename OutputIterator>
- OutputIterator operator()(boost::uint32_t v, OutputIterator out)
+ OutputIterator operator()(char32 v, OutputIterator out)
         {
                 if(v >= 0x10000u)
                 {
@@ -101,8 +86,8 @@
                         output_type hi = static_cast<output_type>(v >> 10) + detail::high_surrogate_base;
                         output_type lo = static_cast<output_type>(v & detail::ten_bit_mask) + detail::low_surrogate_base;
                         
- BOOST_ASSERT(detail::is_high_surrogate(hi));
- BOOST_ASSERT(detail::is_low_surrogate(lo));
+ BOOST_ASSERT(unicode::is_high_surrogate(hi));
+ BOOST_ASSERT(unicode::is_low_surrogate(lo));
                         
                         *out++ = hi;
                         *out++ = lo;
@@ -113,7 +98,7 @@
                         output_type cp = static_cast<output_type>(v);
 
                         // value must not be a surrogate:
- if(detail::is_surrogate(cp))
+ if(unicode::is_surrogate(cp))
                                 detail::invalid_code_point(v);
                                 
                         *out++ = cp;
@@ -125,70 +110,63 @@
 
 struct u16_unpacker
 {
- typedef boost::uint32_t output_type;
+ typedef char32 output_type;
+ static const int max_output = 1;
         
- template<typename Range, typename It>
- std::pair<
- typename boost::range_iterator<Range>::type,
- It
- >
- left(const Range& in, It out)
+ template<typename In, typename Out>
+ std::pair<In, Out>
+ ltr(In begin, In end, Out out)
         {
- assert(!boost::empty(in));
-
- typename boost::range_iterator<const Range>::type it(boost::begin(in));
+ BOOST_ASSERT(begin != end);
                 
- boost::uint32_t value = *it;
+ In it = begin;
+ char32 value = *it;
                 
- if(detail::is_high_surrogate(value))
+ if(unicode::is_high_surrogate(value))
                 {
- if(++it == boost::end(in))
- detail::invalid_utf_sequence(in);
+ if(++it == end)
+ detail::invalid_utf_sequence(begin, end);
                         
                         // precondition; next value must have be a low-surrogate:
- boost::uint16_t lo = *it;
- if(!detail::is_low_surrogate(lo))
+ char16 lo = *it;
+ if(!unicode::is_low_surrogate(lo))
                     detail::invalid_code_point(lo);
                                 
                  value = code_point(value, lo);
               }
               // postcondition; result must not be a surrogate:
- if(detail::is_surrogate(value))
- detail::invalid_code_point(static_cast<boost::uint16_t>(value));
+ if(unicode::is_surrogate(value))
+ detail::invalid_code_point(static_cast<char16>(value));
                 
                 *out++ = value;
                                 
                 return std::make_pair(++it, out);
         }
         
- template<typename Range, typename OutputIterator>
- std::pair<
- typename boost::range_iterator<Range>::type,
- OutputIterator
- >
- right(const Range& in, OutputIterator out)
+ template<typename In, typename Out>
+ std::pair<In, Out>
+ rtl(In begin, In end, Out out)
         {
- assert(!boost::empty(in));
+ BOOST_ASSERT(begin != end);
                 
- typename boost::range_iterator<const Range>::type it = --boost::end(in);
+ In it = --end;
+ char32 value = *it;
                 
- boost::uint32_t value = *it;
-
- if(detail::is_low_surrogate(value))
+ if(unicode::is_low_surrogate(value))
                 {
- if(it == boost::begin(in))
- invalid_utf_sequence(in);
+ if(it == begin)
+ invalid_utf_sequence(begin, end);
                         --it;
                         
- boost::uint16_t hi = *it;
- if(!detail::is_high_surrogate(hi))
+ char16 hi = *it;
+ if(!unicode::is_high_surrogate(hi))
                     invalid_code_point(hi);
                         
                         value = code_point(hi, value);
               }
               // postcondition; result must not be a surrogate:
- if(detail::is_surrogate(value))
- invalid_code_point(static_cast<boost::uint16_t>(value));
+ if(unicode::is_surrogate(value))
+ invalid_code_point(static_cast<char16>(value));
                         
                 *out++ = value;
                 
@@ -196,19 +174,20 @@
         }
         
 private:
- boost::uint32_t code_point(boost::uint16_t hi, boost::uint16_t lo)
+ char32 code_point(char16 hi, char16 lo)
         {
                 return ((hi - detail::high_surrogate_base) << 10)
- | (static_cast<boost::uint32_t>(static_cast<boost::uint16_t>(lo)) & detail::ten_bit_mask);
+ | (static_cast<char32>(static_cast<char16>(lo)) & detail::ten_bit_mask);
         }
 };
 
 struct u8_packer
 {
- typedef boost::uint8_t output_type;
+ typedef char output_type;
+ static const int max_output = 4;
         
         template<typename OutputIterator>
- OutputIterator operator()(boost::uint32_t c, OutputIterator out)
+ OutputIterator operator()(char32 c, OutputIterator out)
         {
                 if(c > 0x10FFFFu)
                         detail::invalid_code_point(c);
@@ -242,40 +221,36 @@
 
 struct u8_unpacker
 {
- typedef boost::uint32_t output_type;
+ typedef char32 output_type;
+ static const int max_output = 1;
         
- template<typename Range, typename It>
- std::pair<
- typename boost::range_iterator<Range>::type,
- It
- >
- left(const Range& in, It out)
+ template<typename In, typename Out>
+ std::pair<In, Out>
+ ltr(In begin, In end, Out out)
         {
- assert(!boost::empty(in));
-
- typename boost::range_iterator<const Range>::type it(boost::begin(in));
+ BOOST_ASSERT(begin != end);
                 
- boost::uint32_t value = *it;
+ In it = begin;
+ char32 value = *it;
                 
                 if((value & 0xC0u) == 0x80u)
- detail::invalid_utf_sequence(in);
+ detail::invalid_utf_sequence(begin, end);
                         
                 // see how many extra byts we have:
                 unsigned extra = detail::utf8_trailing_byte_count(value);
                 // extract the extra bits, 6 from each extra byte:
-
                 for(unsigned c = 0; c < extra; ++c)
                 {
- if(++it == boost::end(in))
- detail::invalid_utf_sequence(in);
+ if(++it == end)
+ detail::invalid_utf_sequence(begin, end);
                         
                         value <<= 6;
- value += static_cast<boost::uint8_t>(*it) & 0x3Fu;
+ value += static_cast<unsigned char>(*it) & 0x3Fu;
                 }
                 
                 // we now need to remove a few of the leftmost bits, but how many depends
                 // upon how many extra bytes we've extracted:
- static const boost::uint32_t masks[4] =
+ static const char32 masks[4] =
                 {
                         0x7Fu,
                         0x7FFu,
@@ -285,33 +260,29 @@
                 value &= masks[extra];
                 
                 // check the result:
- if(value > static_cast<boost::uint32_t>(0x10FFFFu))
- invalid_utf_sequence(in);
+ if(value > static_cast<char32>(0x10FFFFu))
+ invalid_utf_sequence(begin, end);
                 
                 *out++ = value;
                                 
                 return std::make_pair(++it, out);
         }
         
- template<typename Range, typename OutputIterator>
- std::pair<
- typename boost::range_iterator<Range>::type,
- OutputIterator
- >
- right(const Range& in, OutputIterator out)
+ template<typename In, typename Out>
+ std::pair<In, Out>
+ rtl(In begin, In end, Out out)
         {
- assert(!boost::empty(in));
+ BOOST_ASSERT(begin != end);
                 
- typename boost::range_iterator<const Range>::type it = --boost::end(in);
-
- boost::uint32_t value = *it;
+ In it = --end;
+ char32 value = *it;
                 
                 // Keep backtracking until we don't have a trailing character:
                 unsigned count = 0;
                 while((*it & 0xC0u) == 0x80u)
                 {
- if(count >= 4 || it == boost::begin(in))
- invalid_utf_sequence(in);
+ if(count >= 4 || it == begin)
+ invalid_utf_sequence(begin, end);
                                 
                         --it;
                         ++count;
@@ -319,9 +290,9 @@
 
                 // now check that the sequence was valid:
                 if(count != detail::utf8_trailing_byte_count(value))
- invalid_utf_sequence(in);
+ invalid_utf_sequence(begin, end);
                 
- out = left(std::make_pair(it, boost::end(in)), out).second;
+ out = ltr(it, end, out).second;
                 return std::make_pair(it, out);
         }
 };
@@ -330,41 +301,53 @@
 
 template<typename Range>
 std::pair<
- pack_iterator<typename boost::range_iterator<const Range>::type, packer<detail::u16_packer> >,
- pack_iterator<typename boost::range_iterator<const Range>::type, packer<detail::u16_packer> >
+ pipe_iterator<typename range_iterator<const Range>::type, one_many_pipe<detail::u16_packer> >,
+ pipe_iterator<typename range_iterator<const Range>::type, one_many_pipe<detail::u16_packer> >
> make_u32_to_u16_range(const Range& range)
 {
- return make_pack_range(range, make_packer(detail::u16_packer()));
+ return make_pipe_range(range, make_one_many_pipe(detail::u16_packer()));
 }
 
 template<typename Range>
 std::pair<
- pack_iterator<typename boost::range_iterator<const Range>::type, detail::u16_unpacker>,
- pack_iterator<typename boost::range_iterator<const Range>::type, detail::u16_unpacker>
+ pipe_iterator<typename range_iterator<const Range>::type, detail::u16_unpacker>,
+ pipe_iterator<typename range_iterator<const Range>::type, detail::u16_unpacker>
> make_u16_to_u32_range(const Range& range)
 {
- return make_pack_range(range, detail::u16_unpacker());
+ return make_pipe_range(range, detail::u16_unpacker());
 }
 
 template<typename Range>
 std::pair<
- pack_iterator<typename boost::range_iterator<const Range>::type, packer<detail::u8_packer> >,
- pack_iterator<typename boost::range_iterator<const Range>::type, packer<detail::u8_packer> >
+ pipe_iterator<typename range_iterator<const Range>::type, one_many_pipe<detail::u8_packer> >,
+ pipe_iterator<typename range_iterator<const Range>::type, one_many_pipe<detail::u8_packer> >
> make_u32_to_u8_range(const Range& range)
 {
- return make_pack_range(range, make_packer(detail::u8_packer()));
+ return make_pipe_range(range, make_one_many_pipe(detail::u8_packer()));
 }
 
 template<typename Range>
 std::pair<
- pack_iterator<typename boost::range_iterator<const Range>::type, detail::u8_unpacker>,
- pack_iterator<typename boost::range_iterator<const Range>::type, detail::u8_unpacker>
+ pipe_iterator<typename range_iterator<const Range>::type, detail::u8_unpacker>,
+ pipe_iterator<typename range_iterator<const Range>::type, detail::u8_unpacker>
> make_u8_to_u32_range(const Range& range)
 {
- return make_pack_range(range, detail::u8_unpacker());
+ return make_pipe_range(range, detail::u8_unpacker());
 }
 
-//TODO: output iterators
+template<typename OutputIterator>
+pipe_output_iterator<OutputIterator, one_many_pipe<detail::u8_packer> >
+make_u8_output_iterator(OutputIterator out)
+{
+ return make_pipe_output_iterator(out, make_one_many_pipe(detail::u8_packer()));
+}
+
+template<typename OutputIterator>
+pipe_output_iterator<OutputIterator, one_many_pipe<detail::u16_packer> >
+make_u16_output_iterator(OutputIterator out)
+{
+ return make_pipe_output_iterator(out, make_one_many_pipe(detail::u16_packer()));
+}
 
 } // namespace boost
 

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-05-27 19:13:31 EDT (Wed, 27 May 2009)
@@ -9,6 +9,7 @@
 project
     : requirements
       <include>../../..
+ <include>$(BOOST_ROOT)
       <library>../src//boost-unicode
     ;
 

Modified: sandbox/SOC/2009/unicode/libs/unicode/example/test.cpp
==============================================================================
--- sandbox/SOC/2009/unicode/libs/unicode/example/test.cpp (original)
+++ sandbox/SOC/2009/unicode/libs/unicode/example/test.cpp 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
@@ -1,6 +1,6 @@
 #include <iostream>
 #include <boost/foreach.hpp>
-#include <boost/unicode/unicode_iterator.hpp>
+#include <boost/unicode/utf_conversion.hpp>
 
 template<typename Range>
 std::pair<
@@ -16,7 +16,7 @@
 
 int main()
 {
- std::vector<boost::uint32_t> v;
+ std::vector<boost::char32> v;
         
         /*v.push_back(122);
         v.push_back(27700);
@@ -35,6 +35,6 @@
         v.push_back(0x7b);*/
         
         
- BOOST_FOREACH(uint32_t cp, boost::make_u8_to_u32_range(v))
- std::cout << std::hex << cp << std::endl;
+ BOOST_FOREACH(char cp, make_reverse_range(boost::make_u32_to_u8_range(v)))
+ std::cout << std::hex << (int)(unsigned char)cp << std::endl;
 }

Modified: sandbox/SOC/2009/unicode/libs/unicode/src/Jamfile.v2
==============================================================================
--- sandbox/SOC/2009/unicode/libs/unicode/src/Jamfile.v2 (original)
+++ sandbox/SOC/2009/unicode/libs/unicode/src/Jamfile.v2 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
@@ -9,6 +9,7 @@
 project
     : requirements
       <include>../../..
+ <include>$(BOOST_ROOT)
     ;
 
 lib boost-unicode : src.cpp ;

Modified: sandbox/SOC/2009/unicode/libs/unicode/src/src.cpp
==============================================================================
--- sandbox/SOC/2009/unicode/libs/unicode/src/src.cpp (original)
+++ sandbox/SOC/2009/unicode/libs/unicode/src/src.cpp 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
@@ -1 +1 @@
-#include <boost/unicode/unicode_iterator.hpp>
+#include <boost/unicode/utf_conversion.hpp>

Modified: sandbox/SOC/2009/unicode/project-root.jam
==============================================================================
--- sandbox/SOC/2009/unicode/project-root.jam (original)
+++ sandbox/SOC/2009/unicode/project-root.jam 2009-05-27 19:13:31 EDT (Wed, 27 May 2009)
@@ -6,5 +6,8 @@
 # http://www.boost.org/LICENSE_1_0.txt)
 #==============================================================================
 
+import os ;
+constant BOOST_ROOT : [ os.environ BOOST_ROOT ] ;
+
 build-project libs/unicode/doc ;
 build-project libs/unicode/example ;


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