$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r71778 - in sandbox/coerce: boost/coerce boost/coerce/detail libs/coerce/example
From: vexocide_at_[hidden]
Date: 2011-05-07 09:54:52
Author: vexocide
Date: 2011-05-07 09:54:50 EDT (Sat, 07 May 2011)
New Revision: 71778
URL: http://svn.boost.org/trac/boost/changeset/71778
Log:
Refactored the domains implementation
Added:
   sandbox/coerce/boost/coerce/detail/backend.hpp   (contents, props changed)
   sandbox/coerce/boost/coerce/detail/karma.hpp
      - copied, changed from r71773, /sandbox/coerce/boost/coerce/karma.hpp
   sandbox/coerce/boost/coerce/detail/qi.hpp
      - copied, changed from r71773, /sandbox/coerce/boost/coerce/qi.hpp
Removed:
   sandbox/coerce/boost/coerce/domain.hpp
   sandbox/coerce/boost/coerce/karma.hpp
   sandbox/coerce/boost/coerce/qi.hpp
Text files modified: 
   sandbox/coerce/boost/coerce/coerce.hpp          |    16 ++++++----------                        
   sandbox/coerce/boost/coerce/detail/karma.hpp    |    15 +++++++--------                         
   sandbox/coerce/boost/coerce/detail/qi.hpp       |    15 +++++++--------                         
   sandbox/coerce/libs/coerce/example/Jamfile.v2   |     3 +++                                     
   sandbox/coerce/libs/coerce/example/coerce.cpp   |     1 -                                       
   sandbox/coerce/libs/coerce/example/optional.cpp |     1 -                                       
   6 files changed, 23 insertions(+), 28 deletions(-)
Modified: sandbox/coerce/boost/coerce/coerce.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/coerce.hpp	(original)
+++ sandbox/coerce/boost/coerce/coerce.hpp	2011-05-07 09:54:50 EDT (Sat, 07 May 2011)
@@ -11,23 +11,19 @@
 #pragma once
 #endif
 
-#include <boost/coerce/domain.hpp>
-#include <boost/coerce/karma.hpp>
-#include <boost/coerce/qi.hpp>
+#include <boost/coerce/detail/backend.hpp>
 
 #include <typeinfo>  // for std::bad_cast
 
 namespace boost { namespace coerce {
 
-    namespace detail {
+    namespace traits {
 
         template <typename Target, typename Source, typename Enable = void>
         struct as
-            : traits::as<
-                typename traits::domain<Target, Source>::type, Target, Source
-            > { };
+            : detail::backend<Target, Source>::type { };
 
-    }  // namespace detail
+    }  // namespace traits
 
     class bad_cast
         : public std::bad_cast { };
@@ -37,7 +33,7 @@
     as(Source const & source) {
         Target target;
 
-        bool result = detail::as<
+        bool result = traits::as<
                 Target, Source
             >::call(target, source);
 
@@ -56,7 +52,7 @@
     ) {
         Target target;
 
-        bool result = detail::as<
+        bool result = traits::as<
                 Target, Source
             >::call(target, source);
 
Added: sandbox/coerce/boost/coerce/detail/backend.hpp
==============================================================================
--- (empty file)
+++ sandbox/coerce/boost/coerce/detail/backend.hpp	2011-05-07 09:54:50 EDT (Sat, 07 May 2011)
@@ -0,0 +1,48 @@
+//              Copyright Jeroen Habraken 2011.
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file ../../../LICENSE_1_0.txt or copy at
+//          http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_COERCE_DETAIL_BACKEND_HPP
+#define BOOST_COERCE_DETAIL_BACKEND_HPP
+
+#ifdef _MSC_VER
+#pragma once
+#endif
+
+#include <boost/coerce/detail/karma.hpp>
+#include <boost/coerce/detail/push_back.hpp>
+#include <boost/coerce/detail/qi.hpp>
+
+#include <boost/mpl/bool.hpp>
+#include <boost/range/has_range_iterator.hpp>
+#include <boost/static_assert.hpp>
+
+namespace boost { namespace coerce { namespace detail {
+
+    template <typename U, typename V>
+    struct backend_impl {
+        BOOST_STATIC_ASSERT(sizeof(U) == 0);
+    };
+
+    template <typename U>
+    struct backend_impl<U, mpl::true_> {
+        typedef detail::qi type;
+    };
+
+    template <>
+    struct backend_impl<mpl::true_, mpl::false_> {
+        typedef detail::karma type;
+    };
+
+    template <typename Target, typename Source, typename Enable = void>
+    struct backend
+        : backend_impl<
+            typename detail::has_push_back<Target>::type,
+            typename has_range_const_iterator<Source>::type
+        > { };
+
+} } }  // namespace boost::coerce::detail
+
+#endif  // BOOST_COERCE_DETAIL_BACKEND_HPP
Copied: sandbox/coerce/boost/coerce/detail/karma.hpp (from r71773, /sandbox/coerce/boost/coerce/karma.hpp)
==============================================================================
--- /sandbox/coerce/boost/coerce/karma.hpp	(original)
+++ sandbox/coerce/boost/coerce/detail/karma.hpp	2011-05-07 09:54:50 EDT (Sat, 07 May 2011)
@@ -4,14 +4,13 @@
 //  (See accompanying file ../../LICENSE_1_0.txt or copy at
 //          http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_COERCE_KARMA_HPP
-#define BOOST_COERCE_KARMA_HPP
+#ifndef BOOST_COERCE_DETAIL_KARMA_HPP
+#define BOOST_COERCE_DETAIL_KARMA_HPP
 
 #ifdef _MSC_VER
 #pragma once
 #endif
 
-#include <boost/coerce/domain.hpp>
 #include <boost/coerce/reserve.hpp>
 
 #include <boost/spirit/home/karma/auto.hpp>
@@ -20,10 +19,10 @@
 #include <boost/spirit/home/karma/operator/optional.hpp>
 #include <boost/spirit/include/version.hpp>
 
-namespace boost { namespace coerce { namespace traits {
+namespace boost { namespace coerce { namespace detail {
 
-    template <typename Target, typename Source>
-    struct as<spirit::karma::domain, Target, Source> {
+    struct karma {
+        template <typename Target, typename Source>
         static inline bool
         call(Target & target, Source const & source) {
             detail::call_reserve(
@@ -41,6 +40,6 @@
         }
     };
 
-} } }  // namespace boost::coerce::traits
+} } }  // namespace boost::coerce::detail
 
-#endif  // BOOST_COERCE_KARMA_HPP
+#endif  // BOOST_COERCE_DETAIL_KARMA_HPP
Copied: sandbox/coerce/boost/coerce/detail/qi.hpp (from r71773, /sandbox/coerce/boost/coerce/qi.hpp)
==============================================================================
--- /sandbox/coerce/boost/coerce/qi.hpp	(original)
+++ sandbox/coerce/boost/coerce/detail/qi.hpp	2011-05-07 09:54:50 EDT (Sat, 07 May 2011)
@@ -4,15 +4,14 @@
 //  (See accompanying file ../../LICENSE_1_0.txt or copy at
 //          http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_COERCE_QI_HPP
-#define BOOST_COERCE_QI_HPP
+#ifndef BOOST_COERCE_DETAIL_QI_HPP
+#define BOOST_COERCE_DETAIL_QI_HPP
 
 #ifdef _MSC_VER
 #pragma once
 #endif
 
 #include <boost/coerce/detail/reserve.hpp>
-#include <boost/coerce/domain.hpp>
 
 #include <boost/range/begin.hpp>
 #include <boost/range/const_iterator.hpp>
@@ -24,10 +23,10 @@
 #include <boost/spirit/home/qi/numeric.hpp>
 #include <boost/spirit/home/qi/operator/optional.hpp>
 
-namespace boost { namespace coerce { namespace traits {
+namespace boost { namespace coerce { namespace detail {
 
-    template <typename Target, typename Source>
-    struct as<spirit::qi::domain, Target, Source> {
+    struct qi {
+        template <typename Target, typename Source>
         static inline bool
         call(Target & target, Source const & source) {
             typename range_difference<Source>::type size =
@@ -49,6 +48,6 @@
         }
     };
 
-} } }  // namespace boost::coerce::traits
+} } }  // namespace boost::coerce::detail
 
-#endif  // BOOST_COERCE_QI_HPP
+#endif  // BOOST_COERCE_DETAIL_QI_HPP
Deleted: sandbox/coerce/boost/coerce/domain.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/domain.hpp	2011-05-07 09:54:50 EDT (Sat, 07 May 2011)
+++ (empty file)
@@ -1,51 +0,0 @@
-//              Copyright Jeroen Habraken 2011.
-//
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file ../../../LICENSE_1_0.txt or copy at
-//          http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_COERCE_DOMAIN_HPP
-#define BOOST_COERCE_DOMAIN_HPP
-
-#ifdef _MSC_VER
-#pragma once
-#endif
-
-#include <boost/coerce/detail/push_back.hpp>
-
-#include <boost/mpl/bool.hpp>
-#include <boost/range/has_range_iterator.hpp>
-#include <boost/spirit/home/karma/domain.hpp>
-#include <boost/spirit/home/qi/domain.hpp>
-#include <boost/static_assert.hpp>
-
-namespace boost { namespace coerce { namespace traits {
-
-    template <typename U, typename V>
-    struct domain_impl {
-        BOOST_STATIC_ASSERT(sizeof(U) == 0);
-    };
-
-    template <typename U>
-    struct domain_impl<U, mpl::true_> {
-        typedef spirit::qi::domain type;
-    };
-
-    template <>
-    struct domain_impl<mpl::true_, mpl::false_> {
-        typedef spirit::karma::domain type;
-    };
-
-    template <typename Target, typename Source, typename Enable = void>
-    struct domain
-        : domain_impl<
-            typename detail::has_push_back<Target>::type,
-            typename has_range_const_iterator<Source>::type
-        > { };
-
-    template <typename Domain, typename Target, typename Source>
-    struct as;
-
-} } }  // namespace boost::coerce::traits
-
-#endif  // BOOST_COERCE_DOMAIN_HPP
Deleted: sandbox/coerce/boost/coerce/karma.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/karma.hpp	2011-05-07 09:54:50 EDT (Sat, 07 May 2011)
+++ (empty file)
@@ -1,46 +0,0 @@
-//           Copyright Jeroen Habraken 2010 - 2011.
-//
-// Distributed under the Boost Software License, Version 1.0.
-//  (See accompanying file ../../LICENSE_1_0.txt or copy at
-//          http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_COERCE_KARMA_HPP
-#define BOOST_COERCE_KARMA_HPP
-
-#ifdef _MSC_VER
-#pragma once
-#endif
-
-#include <boost/coerce/domain.hpp>
-#include <boost/coerce/reserve.hpp>
-
-#include <boost/spirit/home/karma/auto.hpp>
-#include <boost/spirit/home/karma/char.hpp>
-#include <boost/spirit/home/karma/numeric.hpp>
-#include <boost/spirit/home/karma/operator/optional.hpp>
-#include <boost/spirit/include/version.hpp>
-
-namespace boost { namespace coerce { namespace traits {
-
-    template <typename Target, typename Source>
-    struct as<spirit::karma::domain, Target, Source> {
-        static inline bool
-        call(Target & target, Source const & source) {
-            detail::call_reserve(
-                target,
-                traits::reserve_size<Source>::call(source));
-
-            bool result = spirit::karma::generate(
-                std::back_inserter(target),
-#if SPIRIT_VERSION <= 0x2030
-                spirit::karma::auto_,
-#endif
-                source);
-
-            return result; 
-        }
-    };
-
-} } }  // namespace boost::coerce::traits
-
-#endif  // BOOST_COERCE_KARMA_HPP
Deleted: sandbox/coerce/boost/coerce/qi.hpp
==============================================================================
--- sandbox/coerce/boost/coerce/qi.hpp	2011-05-07 09:54:50 EDT (Sat, 07 May 2011)
+++ (empty file)
@@ -1,54 +0,0 @@
-//           Copyright Jeroen Habraken 2010 - 2011.
-//
-// Distributed under the Boost Software License, Version 1.0.
-//  (See accompanying file ../../LICENSE_1_0.txt or copy at
-//          http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_COERCE_QI_HPP
-#define BOOST_COERCE_QI_HPP
-
-#ifdef _MSC_VER
-#pragma once
-#endif
-
-#include <boost/coerce/detail/reserve.hpp>
-#include <boost/coerce/domain.hpp>
-
-#include <boost/range/begin.hpp>
-#include <boost/range/const_iterator.hpp>
-#include <boost/range/end.hpp>
-#include <boost/range/has_range_iterator.hpp>
-#include <boost/range/size.hpp>
-#include <boost/spirit/home/qi/auto.hpp>
-#include <boost/spirit/home/qi/char.hpp>
-#include <boost/spirit/home/qi/numeric.hpp>
-#include <boost/spirit/home/qi/operator/optional.hpp>
-
-namespace boost { namespace coerce { namespace traits {
-
-    template <typename Target, typename Source>
-    struct as<spirit::qi::domain, Target, Source> {
-        static inline bool
-        call(Target & target, Source const & source) {
-            typename range_difference<Source>::type size =
-                boost::size(source);
-            detail::call_reserve(target, size);
-
-            typedef typename range_const_iterator<Source>::type iterator_type;
-            iterator_type begin = boost::const_begin(source),
-                          iterator = begin;
-            iterator_type end = boost::const_end(source);
-
-            bool result = spirit::qi::parse(
-                iterator, end, target);
-
-            if (!result || !((begin <= iterator && iterator < end && *iterator == 0) || iterator == end))
-                return false;
-
-            return true;
-        }
-    };
-
-} } }  // namespace boost::coerce::traits
-
-#endif  // BOOST_COERCE_QI_HPP
Modified: sandbox/coerce/libs/coerce/example/Jamfile.v2
==============================================================================
--- sandbox/coerce/libs/coerce/example/Jamfile.v2	(original)
+++ sandbox/coerce/libs/coerce/example/Jamfile.v2	2011-05-07 09:54:50 EDT (Sat, 07 May 2011)
@@ -13,5 +13,8 @@
 exe coerce :
     coerce.cpp ;
 
+exe domain :
+    domain.cpp ;
+
 exe optional :
     optional.cpp ;
Modified: sandbox/coerce/libs/coerce/example/coerce.cpp
==============================================================================
--- sandbox/coerce/libs/coerce/example/coerce.cpp	(original)
+++ sandbox/coerce/libs/coerce/example/coerce.cpp	2011-05-07 09:54:50 EDT (Sat, 07 May 2011)
@@ -7,7 +7,6 @@
 #include <boost/coerce.hpp>
 
 #include <iostream>
-#include <ostream>
 #include <string>
 
 int
Modified: sandbox/coerce/libs/coerce/example/optional.cpp
==============================================================================
--- sandbox/coerce/libs/coerce/example/optional.cpp	(original)
+++ sandbox/coerce/libs/coerce/example/optional.cpp	2011-05-07 09:54:50 EDT (Sat, 07 May 2011)
@@ -8,7 +8,6 @@
 #include <boost/optional.hpp>
 
 #include <iostream>
-#include <ostream>
 
 namespace std {