Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58082 - in trunk/boost/spirit/home: . karma karma/auto qi/auto support/auto
From: hartmut.kaiser_at_[hidden]
Date: 2009-12-01 09:30:55


Author: hkaiser
Date: 2009-12-01 09:30:54 EST (Tue, 01 Dec 2009)
New Revision: 58082
URL: http://svn.boost.org/trac/boost/changeset/58082

Log:
Spirit: auto_ tweaks, added missing header
Added:
   trunk/boost/spirit/home/karma/format.hpp (contents, props changed)
Text files modified:
   trunk/boost/spirit/home/karma.hpp | 1 +
   trunk/boost/spirit/home/karma/auto/meta_create.hpp | 31 +++++++++++++++++++++++--------
   trunk/boost/spirit/home/qi/auto/meta_create.hpp | 19 ++++++++++++++++++-
   trunk/boost/spirit/home/support/auto/meta_create.hpp | 6 ++++++
   4 files changed, 48 insertions(+), 9 deletions(-)

Modified: trunk/boost/spirit/home/karma.hpp
==============================================================================
--- trunk/boost/spirit/home/karma.hpp (original)
+++ trunk/boost/spirit/home/karma.hpp 2009-12-01 09:30:54 EST (Tue, 01 Dec 2009)
@@ -26,5 +26,6 @@
 #include <boost/spirit/home/karma/what.hpp>
 #include <boost/spirit/home/karma/stream.hpp>
 #include <boost/spirit/home/karma/auto.hpp>
+#include <boost/spirit/home/karma/format.hpp>
 
 #endif

Modified: trunk/boost/spirit/home/karma/auto/meta_create.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/auto/meta_create.hpp (original)
+++ trunk/boost/spirit/home/karma/auto/meta_create.hpp 2009-12-01 09:30:54 EST (Tue, 01 Dec 2009)
@@ -18,10 +18,12 @@
 #include <boost/variant.hpp>
 #include <boost/optional.hpp>
 #include <boost/config.hpp>
+#include <boost/mpl/not.hpp>
 #include <boost/mpl/fold.hpp>
 #include <boost/mpl/vector.hpp>
 #include <boost/mpl/push_back.hpp>
 #include <boost/fusion/include/as_vector.hpp>
+#include <boost/type_traits/is_same.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
 namespace boost { namespace spirit { namespace karma
@@ -147,28 +149,31 @@
     ///////////////////////////////////////////////////////////////////////////
     // the default is to use the standard streaming operator unless it's a
     // STL container or a fusion sequence
+
+ // The default implementation will be chosen if no predefined mapping of
+ // the data type T to a Karma component is defined.
+ struct no_auto_mapping_exists {};
+
     template <typename T, typename Enable = void>
- struct meta_create_impl;
+ struct meta_create_impl : mpl::identity<no_auto_mapping_exists> {};
 
     template <typename T>
     struct meta_create_impl<T
           , typename enable_if_c<
- traits::is_container<T>::value && !traits::is_string<T>::value
+ traits::is_container<T>::value &&
+ !traits::is_string<T>::value &&
+ !fusion::traits::is_sequence<T>::value
>::type>
       : meta_create_container<T> {};
 
     template <typename T>
     struct meta_create_impl<T
- , typename enable_if<
- traits::is_string<T>
- >::type>
+ , typename enable_if<traits::is_string<T> >::type>
       : meta_create_string<T> {};
 
     template <typename T>
     struct meta_create_impl<T
- , typename enable_if<
- fusion::traits::is_sequence<T>
- >::type>
+ , typename enable_if<fusion::traits::is_sequence<T> >::type>
       : meta_create_sequence<T> {};
 
     template <typename T, typename Enable = void>
@@ -341,6 +346,16 @@
     template <typename T>
     struct meta_create<karma::domain, T>
       : create_generator<typename spirit::detail::remove_const_ref<T>::type> {};
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Check whether a valid mapping exits for the given data type to a Karma
+ // component
+ template <typename T>
+ struct meta_create_exists<karma::domain, T>
+ : mpl::not_<is_same<
+ karma::no_auto_mapping_exists
+ , typename meta_create<karma::domain, T>::type
+ > > {};
 }}}
 
 #endif

Added: trunk/boost/spirit/home/karma/format.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/karma/format.hpp 2009-12-01 09:30:54 EST (Tue, 01 Dec 2009)
@@ -0,0 +1,16 @@
+// Copyright (c) 2001-2009 Hartmut Kaiser
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+#if !defined(BOOST_SPIRIT_KARMA_FORMAT_DEC_01_2009_0716AM)
+#define BOOST_SPIRIT_KARMA_FORMAT_DEC_01_2009_0716AM
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <boost/spirit/home/karma/stream/format_manip.hpp>
+#include <boost/spirit/home/karma/stream/format_manip_attr.hpp>
+
+#endif

Modified: trunk/boost/spirit/home/qi/auto/meta_create.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/auto/meta_create.hpp (original)
+++ trunk/boost/spirit/home/qi/auto/meta_create.hpp 2009-12-01 09:30:54 EST (Tue, 01 Dec 2009)
@@ -18,9 +18,11 @@
 #include <boost/variant.hpp>
 #include <boost/optional.hpp>
 #include <boost/config.hpp>
+#include <boost/mpl/not.hpp>
 #include <boost/mpl/fold.hpp>
 #include <boost/mpl/vector.hpp>
 #include <boost/mpl/push_back.hpp>
+#include <boost/type_traits/is_same.hpp>
 #include <boost/fusion/include/as_vector.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -89,8 +91,13 @@
     ///////////////////////////////////////////////////////////////////////////
     // the default is to use the standard streaming operator unless it's a
     // STL container or a fusion sequence
+
+ // The default implementation will be chosen if no predefined mapping of
+ // the data type T to a Karma component is defined.
+ struct no_auto_mapping_exists {};
+
     template <typename T, typename Enable = void>
- struct meta_create_impl;
+ struct meta_create_impl : mpl::identity<no_auto_mapping_exists> {};
 
     template <typename T>
     struct meta_create_impl<T
@@ -272,6 +279,16 @@
     template <typename T>
     struct meta_create<qi::domain, T>
       : create_parser<typename spirit::detail::remove_const_ref<T>::type> {};
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Check whether a valid mapping exits for the given data type to a Karma
+ // component
+ template <typename T>
+ struct meta_create_exists<qi::domain, T>
+ : mpl::not_<is_same<
+ qi::no_auto_mapping_exists
+ , typename meta_create<qi::domain, T>::type
+ > > {};
 }}}
 
 #endif

Modified: trunk/boost/spirit/home/support/auto/meta_create.hpp
==============================================================================
--- trunk/boost/spirit/home/support/auto/meta_create.hpp (original)
+++ trunk/boost/spirit/home/support/auto/meta_create.hpp 2009-12-01 09:30:54 EST (Tue, 01 Dec 2009)
@@ -26,6 +26,12 @@
     // This is the main dispatching point for meta_create to the correct domain
     template <typename Domain, typename T, typename Enable = void>
     struct meta_create;
+
+ ///////////////////////////////////////////////////////////////////////////
+ // This allows to query whether a valid mapping exits for the given data
+ // type to a component in the given domain
+ template <typename Domain, typename T, typename Enable = void>
+ struct meta_create_exists : mpl::false_ {};
 }}}
 
 namespace boost { namespace spirit


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