Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55776 - in trunk/boost/spirit/home/karma: . detail stream stream/detail
From: hartmut.kaiser_at_[hidden]
Date: 2009-08-25 10:52:36


Author: hkaiser
Date: 2009-08-25 10:52:35 EDT (Tue, 25 Aug 2009)
New Revision: 55776
URL: http://svn.boost.org/trac/boost/changeset/55776

Log:
Spirit: moved karma::ostream_iterator out of namespace detail to make it usable by user code
Added:
   trunk/boost/spirit/home/karma/stream/ostream_iterator.hpp (contents, props changed)
Removed:
   trunk/boost/spirit/home/karma/detail/ostream_iterator.hpp
Text files modified:
   trunk/boost/spirit/home/karma/detail/output_iterator.hpp | 14 +++++++-------
   trunk/boost/spirit/home/karma/stream.hpp | 1 +
   trunk/boost/spirit/home/karma/stream/detail/format_manip.hpp | 10 +++++-----
   trunk/boost/spirit/home/karma/stream/format_manip.hpp | 2 +-
   trunk/boost/spirit/home/karma/stream/stream.hpp | 8 ++++----
   5 files changed, 18 insertions(+), 17 deletions(-)

Deleted: trunk/boost/spirit/home/karma/detail/ostream_iterator.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/detail/ostream_iterator.hpp 2009-08-25 10:52:35 EDT (Tue, 25 Aug 2009)
+++ (empty file)
@@ -1,65 +0,0 @@
-// 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_OSTREAM_ITERATOR_MAY_26_2007_1016PM)
-#define BOOST_SPIRIT_KARMA_OSTREAM_ITERATOR_MAY_26_2007_1016PM
-
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
-#include <iterator>
-
-///////////////////////////////////////////////////////////////////////////////
-namespace boost { namespace spirit { namespace karma { namespace detail
-{
- ///////////////////////////////////////////////////////////////////////////
- // We need our own implementation of an ostream_iterator just to be able
- // to access the wrapped ostream, which is necessary for the
- // stream_director, where we must generate the output using the original
- // ostream to retain possibly registered facets.
- ///////////////////////////////////////////////////////////////////////////
- template <
- typename T, typename Elem = char
- , typename Traits = std::char_traits<Elem> >
- class ostream_iterator
- : public std::iterator<std::output_iterator_tag, void, void, void, void>
- {
- public:
- typedef Elem char_type;
- typedef Traits traits_type;
- typedef std::basic_ostream<Elem, Traits> ostream_type;
- typedef ostream_iterator<T, Elem, Traits> self_type;
-
- ostream_iterator(ostream_type& os_, Elem const* delim_ = 0)
- : os(&os_), delim(delim_) {}
-
- self_type& operator= (T const& val)
- {
- *os << val;
- if (0 != delim)
- *os << delim;
- return *this;
- }
-
- self_type& operator*() { return *this; }
- self_type& operator++() { return *this; }
- self_type operator++(int) { return *this; }
-
- // expose underlying stream
- ostream_type& get_ostream() { return *os; }
- ostream_type const& get_ostream() const { return *os; }
-
- // expose good bit of underlying stream object
- bool good() const { return get_ostream().good(); }
-
- protected:
- ostream_type *os;
- Elem const* delim;
- };
-
-}}}}
-
-#endif

Modified: trunk/boost/spirit/home/karma/detail/output_iterator.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/detail/output_iterator.hpp (original)
+++ trunk/boost/spirit/home/karma/detail/output_iterator.hpp 2009-08-25 10:52:35 EDT (Tue, 25 Aug 2009)
@@ -19,7 +19,7 @@
 #include <boost/mpl/if.hpp>
 
 #include <boost/spirit/home/karma/generator.hpp>
-#include <boost/spirit/home/karma/detail/ostream_iterator.hpp>
+#include <boost/spirit/home/karma/stream/ostream_iterator.hpp>
 #include <boost/spirit/home/support/unused.hpp>
 
 namespace boost { namespace spirit { namespace karma { namespace detail
@@ -470,15 +470,15 @@
 
     ///////////////////////////////////////////////////////////////////////////
     template <typename T, typename Elem, typename Traits, typename Properties>
- class output_iterator<ostream_iterator<T, Elem, Traits>, Properties>
- : public output_iterator<ostream_iterator<T, Elem, Traits>, Properties
- , output_iterator<ostream_iterator<T, Elem, Traits>, Properties> >
+ class output_iterator<karma::ostream_iterator<T, Elem, Traits>, Properties>
+ : public output_iterator<karma::ostream_iterator<T, Elem, Traits>, Properties
+ , output_iterator<karma::ostream_iterator<T, Elem, Traits>, Properties> >
     {
     private:
- typedef output_iterator<ostream_iterator<T, Elem, Traits>, Properties
- , output_iterator<ostream_iterator<T, Elem, Traits>, Properties>
+ typedef output_iterator<karma::ostream_iterator<T, Elem, Traits>, Properties
+ , output_iterator<karma::ostream_iterator<T, Elem, Traits>, Properties>
> base_type;
- typedef ostream_iterator<T, Elem, Traits> base_iterator_type;
+ typedef karma::ostream_iterator<T, Elem, Traits> base_iterator_type;
         typedef std::basic_ostream<Elem, Traits> ostream_type;
 
     public:

Modified: trunk/boost/spirit/home/karma/stream.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/stream.hpp (original)
+++ trunk/boost/spirit/home/karma/stream.hpp 2009-08-25 10:52:35 EDT (Tue, 25 Aug 2009)
@@ -12,6 +12,7 @@
 
 #include <boost/spirit/home/karma/stream/format_manip.hpp>
 #include <boost/spirit/home/karma/stream/format_manip_attr.hpp>
+#include <boost/spirit/home/karma/stream/ostream_iterator.hpp>
 #include <boost/spirit/home/karma/stream/stream.hpp>
 
 #endif

Modified: trunk/boost/spirit/home/karma/stream/detail/format_manip.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/stream/detail/format_manip.hpp (original)
+++ trunk/boost/spirit/home/karma/stream/detail/format_manip.hpp 2009-08-25 10:52:35 EDT (Tue, 25 Aug 2009)
@@ -13,7 +13,7 @@
 #include <iterator>
 #include <string>
 #include <boost/spirit/home/karma/generate.hpp>
-#include <boost/spirit/home/karma/detail/ostream_iterator.hpp>
+#include <boost/spirit/home/karma/stream/ostream_iterator.hpp>
 #include <boost/mpl/bool.hpp>
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -59,7 +59,7 @@
     operator<< (std::basic_ostream<Char, Traits> &os
       , format_manip<Expr, Copy> const& fm)
     {
- ostream_iterator<Char, Char, Traits> sink(os);
+ karma::ostream_iterator<Char, Char, Traits> sink(os);
         if (!karma::generate (sink, fm.expr))
         {
             os.setstate(std::ios_base::failbit);
@@ -74,7 +74,7 @@
     operator<< (std::basic_ostream<Char, Traits> &os
       , format_manip<Expr, Copy, unused_type, Attribute> const& fm)
     {
- ostream_iterator<Char, Char, Traits> sink(os);
+ karma::ostream_iterator<Char, Char, Traits> sink(os);
         if (!karma::generate(sink, fm.expr, fm.attr))
         {
             os.setstate(std::ios_base::failbit);
@@ -88,7 +88,7 @@
     operator<< (std::basic_ostream<Char, Traits> &os
       , format_manip<Expr, Copy, Delimiter> const& fm)
     {
- ostream_iterator<Char, Char, Traits> sink(os);
+ karma::ostream_iterator<Char, Char, Traits> sink(os);
         if (!karma::generate_delimited(sink, fm.expr, fm.delim, fm.pre))
         {
             os.setstate(std::ios_base::failbit);
@@ -103,7 +103,7 @@
     operator<< (std::basic_ostream<Char, Traits> &os
       , format_manip<Expr, Copy, Delimiter, Attribute> const& fm)
     {
- ostream_iterator<Char, Char, Traits> sink(os);
+ karma::ostream_iterator<Char, Char, Traits> sink(os);
         if (!karma::generate_delimited(sink, fm.expr, fm.delim, fm.pre, fm.attr))
         {
             os.setstate(std::ios_base::failbit);

Modified: trunk/boost/spirit/home/karma/stream/format_manip.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/stream/format_manip.hpp (original)
+++ trunk/boost/spirit/home/karma/stream/format_manip.hpp 2009-08-25 10:52:35 EDT (Tue, 25 Aug 2009)
@@ -100,7 +100,7 @@
         typedef traits::properties_of<
             typename result_of::compile<karma::domain, Derived>::type
> properties;
- typedef karma::detail::ostream_iterator<Char, Char, Traits> outiter_type;
+ typedef karma::ostream_iterator<Char, Char, Traits> outiter_type;
 
         outiter_type target_sink(os);
         karma::detail::output_iterator<outiter_type, properties> sink(target_sink);

Added: trunk/boost/spirit/home/karma/stream/ostream_iterator.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/spirit/home/karma/stream/ostream_iterator.hpp 2009-08-25 10:52:35 EDT (Tue, 25 Aug 2009)
@@ -0,0 +1,65 @@
+// 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_OSTREAM_ITERATOR_MAY_26_2007_1016PM)
+#define BOOST_SPIRIT_KARMA_OSTREAM_ITERATOR_MAY_26_2007_1016PM
+
+#if defined(_MSC_VER)
+#pragma once
+#endif
+
+#include <iterator>
+
+///////////////////////////////////////////////////////////////////////////////
+namespace boost { namespace spirit { namespace karma
+{
+ ///////////////////////////////////////////////////////////////////////////
+ // We need our own implementation of an ostream_iterator just to be able
+ // to access the wrapped ostream, which is necessary for the
+ // stream_director, where we must generate the output using the original
+ // ostream to retain possibly registered facets.
+ ///////////////////////////////////////////////////////////////////////////
+ template <
+ typename T, typename Elem = char
+ , typename Traits = std::char_traits<Elem> >
+ class ostream_iterator
+ : public std::iterator<std::output_iterator_tag, void, void, void, void>
+ {
+ public:
+ typedef Elem char_type;
+ typedef Traits traits_type;
+ typedef std::basic_ostream<Elem, Traits> ostream_type;
+ typedef ostream_iterator<T, Elem, Traits> self_type;
+
+ ostream_iterator(ostream_type& os_, Elem const* delim_ = 0)
+ : os(&os_), delim(delim_) {}
+
+ self_type& operator= (T const& val)
+ {
+ *os << val;
+ if (0 != delim)
+ *os << delim;
+ return *this;
+ }
+
+ self_type& operator*() { return *this; }
+ self_type& operator++() { return *this; }
+ self_type operator++(int) { return *this; }
+
+ // expose underlying stream
+ ostream_type& get_ostream() { return *os; }
+ ostream_type const& get_ostream() const { return *os; }
+
+ // expose good bit of underlying stream object
+ bool good() const { return get_ostream().good(); }
+
+ protected:
+ ostream_type *os;
+ Elem const* delim;
+ };
+
+}}}
+
+#endif

Modified: trunk/boost/spirit/home/karma/stream/stream.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/stream/stream.hpp (original)
+++ trunk/boost/spirit/home/karma/stream/stream.hpp 2009-08-25 10:52:35 EDT (Tue, 25 Aug 2009)
@@ -143,11 +143,11 @@
>
         static bool generate(
             karma::detail::output_iterator<
- karma::detail::ostream_iterator<T, Char, Traits>, Properties
+ karma::ostream_iterator<T, Char, Traits>, Properties
>& sink, Context&, Delimiter const& d, Attribute const& attr)
         {
             typedef karma::detail::output_iterator<
- karma::detail::ostream_iterator<T, Char, Traits>, Properties
+ karma::ostream_iterator<T, Char, Traits>, Properties
> output_iterator;
             typedef karma::detail::iterator_sink<
                 output_iterator, Char, CharEncoding, Tag
@@ -226,11 +226,11 @@
           , typename Context, typename Delimiter, typename Attribute>
         bool generate(
             karma::detail::output_iterator<
- karma::detail::ostream_iterator<T1, Char, Traits>, Properties
+ karma::ostream_iterator<T1, Char, Traits>, Properties
>& sink, Context&, Delimiter const& d, Attribute const&)
         {
             typedef karma::detail::output_iterator<
- karma::detail::ostream_iterator<T1, Char, Traits>, Properties
+ karma::ostream_iterator<T1, Char, Traits>, Properties
> output_iterator;
             typedef karma::detail::iterator_sink<
                 output_iterator, Char, CharEncoding, Tag


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