Boost logo

Boost-Commit :

From: jeff_at_[hidden]
Date: 2007-07-30 23:53:03


Author: jefffaust
Date: 2007-07-30 23:53:03 EDT (Mon, 30 Jul 2007)
New Revision: 7604
URL: http://svn.boost.org/trac/boost/changeset/7604

Log:
implement a row count for wrapping.
Text files modified:
   sandbox/explore/boost/explore/container_stream_state.hpp | 11 ++++++-----
   sandbox/explore/boost/explore/stream_container.hpp | 19 ++++++++++++++-----
   2 files changed, 20 insertions(+), 10 deletions(-)

Modified: sandbox/explore/boost/explore/container_stream_state.hpp
==============================================================================
--- sandbox/explore/boost/explore/container_stream_state.hpp (original)
+++ sandbox/explore/boost/explore/container_stream_state.hpp 2007-07-30 23:53:03 EDT (Mon, 30 Jul 2007)
@@ -42,7 +42,7 @@
         typedef std::vector<str_typ, std::allocator<str_typ> > cont_typ;
 
         container_stream_state()
- : m_depth(0), m_itemw(0)
+ : m_depth(0), m_rows(0)
         {
             init<Elem>();
         }
@@ -66,7 +66,7 @@
         const str_typ& assoc_separator(std::size_t index = 0) const { return at(m_assoc_separator, index); }
         const str_typ& assoc_start(std::size_t index = 0) const { return at(m_assoc_start, index); }
         const str_typ& assoc_end(std::size_t index = 0) const { return at(m_assoc_end, index); }
- std::streamsize itemw() const { return m_itemw; }
+ std::size_t rows() const { return m_rows; }
 
         // write
         void set_separator(const str_typ& str, std::size_t index = 0) { at(m_separator, index) = str; }
@@ -75,7 +75,7 @@
         void set_assoc_separator(const str_typ& str, std::size_t index = 0) { at(m_assoc_separator, index) = str; }
         void set_assoc_start(const str_typ& str, std::size_t index = 0) { at(m_assoc_start, index) = str; }
         void set_assoc_end(const str_typ& str, std::size_t index = 0) { at(m_assoc_end, index) = str; }
- void set_itemw(std::streamsize itemw, std::size_t index = 0) { m_itemw = itemw; }
+ void set_rows(std::size_t rows, std::size_t index = 0) { m_rows = rows; }
 
         std::size_t depth() const
         {
@@ -94,9 +94,10 @@
         cont_typ m_assoc_end;
         std::size_t m_depth;
 
- std::streamsize m_itemw;
+ std::size_t m_rows;
 
- void init(cont_typ& c, str_typ val)
+ template<typename T>
+ void init(cont_typ& c, const T& val)
         {
             c.resize(1);
             c[0] = val;

Modified: sandbox/explore/boost/explore/stream_container.hpp
==============================================================================
--- sandbox/explore/boost/explore/stream_container.hpp (original)
+++ sandbox/explore/boost/explore/stream_container.hpp 2007-07-30 23:53:03 EDT (Mon, 30 Jul 2007)
@@ -105,11 +105,11 @@
             explore::get_stream_state<container_stream_state<Elem> >(ostr)->set_assoc_end(end, depth);
         }
 
- // function ptr object for setitemw
+ // function ptr object for setrows
         //template<typename Elem>
- void setitemwFn(std::ios_base& ostr, std::streamsize sz, std::size_t depth)
+ void setrowsFn(std::ios_base& ostr, std::size_t sz, std::size_t depth)
         {
- explore::get_stream_state<container_stream_state<char> >(ostr)->set_itemw(sz, depth);
+ explore::get_stream_state<container_stream_state<char> >(ostr)->set_rows(sz, depth);
         }
     }
 
@@ -124,8 +124,17 @@
         // starting delimiter
         ostr << state->start(depth);
 
+ std::size_t rows = state->rows();
+
+ std::size_t cur_row = 0;
         while( first != last )
         {
+ if( rows && cur_row++ == rows )
+ {
+ ostr << std::endl;
+ cur_row = 1;
+ }
+
             // value
             f(ostr, *first, state);
             if( ++first != last )
@@ -270,9 +279,9 @@
         return detail::manipfunc<const Elem*>(&detail::assoc_endFn, end, depth);
     }
 
- detail::manipfunc<std::streamsize> setitemw(std::streamsize sz, std::size_t depth = 0)
+ detail::manipfunc<size_t> setrows(std::size_t sz, std::size_t depth = 0)
     {
- return detail::manipfunc<std::streamsize>(detail::setitemwFn, sz, depth);
+ return detail::manipfunc<std::size_t>(detail::setrowsFn, sz, depth);
     }
 
     // manipulator


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