Boost logo

Boost-Commit :

From: john.groups_at_[hidden]
Date: 2007-10-15 05:29:09


Author: jtorjo
Date: 2007-10-15 05:29:08 EDT (Mon, 15 Oct 2007)
New Revision: 40042
URL: http://svn.boost.org/trac/boost/changeset/40042

Log:
[logging]
v0.7, 15 oct 2007
- compiles with gcc 3.4.2

Added:
   sandbox/logging/lib/logging/samples/gcc/ (props changed)
   sandbox/logging/lib/logging/samples/gcc/main.cpp (contents, props changed)
Properties modified:
   sandbox/logging/lib/logging/samples/vc8/loggingvc8/ (props changed)
Text files modified:
   sandbox/logging/boost/logging/detail/manipulator.hpp | 4 +-
   sandbox/logging/boost/logging/filter.hpp | 8 ++--
   sandbox/logging/boost/logging/format.hpp | 58 ++++++++++++++++++++--------------------
   sandbox/logging/boost/logging/format/array.hpp | 4 +-
   sandbox/logging/boost/logging/process_msg.hpp | 15 ++++++---
   sandbox/logging/boost/logging/process_msg/ostream_like.hpp | 16 ++++++++++
   sandbox/logging/boost/logging/sink.hpp | 4 +-
   sandbox/logging/boost/logging/writer/on_dedicated_thread.hpp | 34 +++++++++++-----------
   sandbox/logging/lib/logging/src/changelog.txt | 4 ++
   9 files changed, 85 insertions(+), 62 deletions(-)

Modified: sandbox/logging/boost/logging/detail/manipulator.hpp
==============================================================================
--- sandbox/logging/boost/logging/detail/manipulator.hpp (original)
+++ sandbox/logging/boost/logging/detail/manipulator.hpp 2007-10-15 05:29:08 EDT (Mon, 15 Oct 2007)
@@ -171,7 +171,7 @@
 
     typedef base_no_operator_call<implement_op_equal, ptr_type_> self_type;
     typedef typename detail::ptr_finder<ptr_type_> type_finder;
- typedef typename type_finder::find<self_type>::type ptr_type;
+ typedef typename type_finder::template find<self_type>::type ptr_type;
 
     virtual ~base_no_operator_call() {}
 };
@@ -212,7 +212,7 @@
 
     typedef base<arg_type, implement_op_equal, ptr_type_> self_type;
     typedef typename detail::ptr_finder<ptr_type_> type_finder;
- typedef typename type_finder::find<self_type>::type ptr_type;
+ typedef typename type_finder::template find<self_type>::type ptr_type;
 
     typedef arg_type param;
 

Modified: sandbox/logging/boost/logging/filter.hpp
==============================================================================
--- sandbox/logging/boost/logging/filter.hpp (original)
+++ sandbox/logging/boost/logging/filter.hpp 2007-10-15 05:29:08 EDT (Mon, 15 Oct 2007)
@@ -270,15 +270,15 @@
 
         BOOST_LOGGING_FORWARD_CONSTRUCTOR(logger, process_base)
 
- operator bool() const { return is_enabled(); }
- bool operator!() const { return !is_enabled(); }
+ operator bool() const { return filter::is_enabled(); }
+ bool operator!() const { return !filter::is_enabled(); }
 
         /**
             Syntactic sugar. Allow writing <tt>logger->some_method(x);</tt>, which is equivalent to
             <tt>logger.process_msg().some_method(x);</tt>
         */
- const process_msg_type* operator->() const { return &process_msg(); }
- process_msg_type* operator->() { return &process_msg(); }
+ const process_msg_type* operator->() const { return &process_base::process_msg(); }
+ process_msg_type* operator->() { return &process_base::process_msg(); }
 
     };
 

Modified: sandbox/logging/boost/logging/format.hpp
==============================================================================
--- sandbox/logging/boost/logging/format.hpp (original)
+++ sandbox/logging/boost/logging/format.hpp 2007-10-15 05:29:08 EDT (Mon, 15 Oct 2007)
@@ -165,7 +165,7 @@
         simple_care_for_clear_format( msg_type & msg) : simple_base_type(msg), m_original_msg( msg ) {}
 
         void clear_format() {
- m_msg = m_original_msg;
+ simple_base_type::m_msg = m_original_msg;
         }
     private:
         msg_type m_original_msg;
@@ -259,23 +259,23 @@
         template<class formatter_array, class destination_array> simple(const formatter_array&, const destination_array&) {}
         
         void append_formatter(formatter_ptr fmt) {
- data::write to_write(m_to_write);
+ typename data::write to_write(m_to_write);
             to_write->formats.push_back(fmt);
         }
         void del_formatter(formatter_ptr fmt) {
- data::write to_write(m_to_write);
- f_array::iterator del = std::remove(to_write->formats.begin(), to_write->formats.end(), fmt);
+ typename data::write to_write(m_to_write);
+ typename f_array::iterator del = std::remove(to_write->formats.begin(), to_write->formats.end(), fmt);
             to_write->formats.erase(del, to_write->formats.end());
         }
 
         void append_destination(destination_ptr dest) {
- data::write to_write(m_to_write);
+ typename data::write to_write(m_to_write);
             to_write->destinations.push_back(dest);
         }
 
         void del_destination(destination_ptr dest) {
- data::write to_write(m_to_write);
- d_array::iterator del = std::remove(to_write->destinations.begin(), to_write->destinations.end(), dest);
+ typename data::write to_write(m_to_write);
+ typename d_array::iterator del = std::remove(to_write->destinations.begin(), to_write->destinations.end(), dest);
             to_write->destinations.erase(del, to_write->destinations.end());
         }
 
@@ -283,11 +283,11 @@
             format_and_write m(msg);
 
             // note: here, we're reading (data::read)!
- data::read to_write(m_to_write);
- for ( f_array::const_iterator b_f = to_write->formats.begin(), e_f = to_write->formats.end(); b_f != e_f; ++b_f)
+ typename data::read to_write(m_to_write);
+ for ( typename f_array::const_iterator b_f = to_write->formats.begin(), e_f = to_write->formats.end(); b_f != e_f; ++b_f)
                 m.format(*b_f);
 
- for ( d_array::const_iterator b_d = to_write->destinations.begin(), e_d = to_write->destinations.end(); b_d != e_d; ++b_d)
+ for ( typename d_array::const_iterator b_d = to_write->destinations.begin(), e_d = to_write->destinations.end(); b_d != e_d; ++b_d)
                 m.write(*b_d);
         }
 
@@ -364,7 +364,7 @@
             represents a formatter/destination route to be added/set.
         */
         class route {
- friend class self_type;
+ friend class with_route;
             typedef enum type {
                 is_fmt, is_dest, is_clear
             };
@@ -405,7 +405,7 @@
         struct route_do_set : route {
             route_do_set(self_type &self) : route(self) {}
             ~route_do_set() {
- m_self.do_set_route( *this);
+ route::m_self.do_set_route( *this);
             }
         };
 
@@ -414,7 +414,7 @@
         struct route_do_append : route {
             route_do_append(self_type &self) : route(self) {}
             ~route_do_append() {
- m_self.do_append_route( *this);
+ route::m_self.do_append_route( *this);
             }
         };
 
@@ -429,7 +429,7 @@
         route_do_append append_route() { return route_do_append(*this); }
 
         void append_formatter(formatter_ptr fmt) {
- data::write to_write(m_to_write);
+ typename data::write to_write(m_to_write);
 
             if ( to_write->empty() )
                 to_write->push_back( write_once() );
@@ -442,16 +442,16 @@
             to_write->back().formats.push_back(fmt);
         }
         void del_formatter(formatter_ptr fmt) {
- data::write to_write(m_to_write);
+ typename data::write to_write(m_to_write);
 
- for ( write_array::const_iterator b = to_write->begin(), e = to_write->end(); b != e; ++b) {
- f_array::iterator del = std::remove( b->formats.begin(), b->formats.end(), fmt);
+ for ( typename write_array::const_iterator b = to_write->begin(), e = to_write->end(); b != e; ++b) {
+ typename f_array::iterator del = std::remove( b->formats.begin(), b->formats.end(), fmt);
                 b->formats.erase(del, b->formats.end());
             }
         }
 
         void append_destination(destination_ptr dest) {
- data::write to_write(m_to_write);
+ typename data::write to_write(m_to_write);
 
             if ( to_write->empty() )
                 to_write->push_back( write_once() );
@@ -464,10 +464,10 @@
         }
 
         void del_destination(destination_ptr dest) {
- data::write to_write(m_to_write);
+ typename data::write to_write(m_to_write);
 
- for ( write_array::const_iterator b = to_write->begin(), e = to_write->end(); b != e; ++b) {
- d_array::iterator del = std::remove( b->destinations.begin(), b->destinations.end(), dest);
+ for ( typename write_array::const_iterator b = to_write->begin(), e = to_write->end(); b != e; ++b) {
+ typename d_array::iterator del = std::remove( b->destinations.begin(), b->destinations.end(), dest);
                 b->destinations.erase(del, b->destinations.end());
 
                 // if from a write_once - all destinations are gone, don't clear_afterwards
@@ -477,7 +477,7 @@
         }
 
         void append_clear_format() {
- data::write to_write(m_to_write);
+ typename data::write to_write(m_to_write);
 
             if ( to_write->empty() )
                 to_write->push_back( write_once() );
@@ -490,12 +490,12 @@
             format_and_write m(msg);
 
             // note: here, we're reading (data::read)!
- data::read to_write(m_to_write);
- for ( write_array::const_iterator b = to_write->begin(), e = to_write->end(); b != e; ++b) {
- for ( f_array::const_iterator b_f = b->formats.begin(), e_f = b->formats.end(); b_f != e_f; ++b_f)
+ typename data::read to_write(m_to_write);
+ for ( typename write_array::const_iterator b = to_write->begin(), e = to_write->end(); b != e; ++b) {
+ for ( typename f_array::const_iterator b_f = b->formats.begin(), e_f = b->formats.end(); b_f != e_f; ++b_f)
                     m.format(*b_f);
 
- for ( d_array::const_iterator b_d = b->destinations.begin(), e_d = b->destinations.end(); b_d != e_d; ++b_d)
+ for ( typename d_array::const_iterator b_d = b->destinations.begin(), e_d = b->destinations.end(); b_d != e_d; ++b_d)
                     m.write(*b_d);
 
                 if ( b->do_clear_afterwards)
@@ -508,8 +508,8 @@
             if ( r.m_items.empty() )
                 return; // no route to add
 
- typedef route::array array;
- for ( array::const_iterator b = r.m_items.begin(), e = r.m_items.end(); b != e; ++b) {
+ typedef typename route::array array;
+ for ( typename array::const_iterator b = r.m_items.begin(), e = r.m_items.end(); b != e; ++b) {
                 switch ( b->m_type) {
                 case route::is_fmt: append_formatter( b->m_fmt); break;
                 case route::is_dest: append_destination( b->m_dest); break;
@@ -522,7 +522,7 @@
 
         void do_set_route(const route & r) {
             {
- data::write to_write(m_to_write);
+ typename data::write to_write(m_to_write);
             to_write->clear();
             }
             do_append_route(r);

Modified: sandbox/logging/boost/logging/format/array.hpp
==============================================================================
--- sandbox/logging/boost/logging/format/array.hpp (original)
+++ sandbox/logging/boost/logging/format/array.hpp 2007-10-15 05:29:08 EDT (Mon, 15 Oct 2007)
@@ -55,7 +55,7 @@
 
         template<class derived> base_type * get_ptr(derived val) const {
             scoped_lock lk(m_cs);
- for ( array_type::const_iterator b = m_array.begin(), e = m_array.end(); b != e; ++b)
+ for ( typename array_type::const_iterator b = m_array.begin(), e = m_array.end(); b != e; ++b)
                 if ( val == (*(b->get())) )
                     return b->get();
 
@@ -66,7 +66,7 @@
         template<class derived> void del(derived val) {
             base_type * p = get_ptr(val);
             scoped_lock lk(m_cs);
- for ( array_type::iterator b = m_array.begin(), e = m_array.end(); b != e; ++b)
+ for ( typename array_type::iterator b = m_array.begin(), e = m_array.end(); b != e; ++b)
                 if ( b->get() == p) {
                     m_array.erase(b);
                     return ;

Modified: sandbox/logging/boost/logging/process_msg.hpp
==============================================================================
--- sandbox/logging/boost/logging/process_msg.hpp (original)
+++ sandbox/logging/boost/logging/process_msg.hpp 2007-10-15 05:29:08 EDT (Mon, 15 Oct 2007)
@@ -28,18 +28,23 @@
 
 
     
- template<class holder, class gather> struct gather_holder {
- typedef gather gather_type;
- gather_holder(const holder & p_this) : m_this(p_this) {}
+ template<class holder, class gather_type> struct gather_holder {
+ gather_holder(const holder & p_this) : m_this(p_this), m_use(true) {}
+
+ gather_holder(const gather_holder & other) : m_this(other.m_this), m_use(true) {
+ other.m_use = false;
+ }
+
         ~gather_holder() {
             // FIXME handle exiting from exceptions!!!
-
- m_this.on_do_write(m_obj);
+ if ( m_use)
+ m_this.on_do_write(m_obj);
         }
         gather_type & gather() { return m_obj; }
     private:
         const holder & m_this;
         mutable gather_type m_obj;
+ mutable bool m_use;
     };
 
     namespace detail {

Modified: sandbox/logging/boost/logging/process_msg/ostream_like.hpp
==============================================================================
--- sandbox/logging/boost/logging/process_msg/ostream_like.hpp (original)
+++ sandbox/logging/boost/logging/process_msg/ostream_like.hpp 2007-10-15 05:29:08 EDT (Mon, 15 Oct 2007)
@@ -118,6 +118,9 @@
     In our case, 1. and 2. are the same
 */
 template<class stream_type = std::basic_ostringstream<char_type> > struct return_raw_stream {
+ return_raw_stream() {}
+ return_raw_stream(const return_raw_stream& other) : m_out( other.m_out.str() ) {}
+
     /**
     note: we return the whole stream - we don't return out().str() , because the user might use a better ostream class,
     which could have better access to its buffer/internals
@@ -159,6 +162,9 @@
 
 */
 template<class stream_type = std::basic_ostringstream<char_type> > struct return_str {
+ return_str() {}
+ return_str(const return_str& other) : m_out(other.m_out.str()) {}
+
     stream_type & out() { return m_out; }
     std::basic_string<char_type> msg() { return m_out.str(); }
 private:
@@ -174,7 +180,15 @@
 
     returns a cache string
 */
-template<class cache_string = boost::logging::optimize::cache_string_one_str<> , int prepend_size = 10, int append_size = 10, class stream_type = std::basic_ostringstream<char_type> > struct return_cache_str {
+template<
+ class cache_string = boost::logging::optimize::cache_string_one_str<hold_string_type> ,
+ int prepend_size = 10,
+ int append_size = 10,
+ class stream_type = std::basic_ostringstream<char_type> > struct return_cache_str {
+
+ return_cache_str() {}
+ return_cache_str(const return_cache_str& other) : m_out(other.m_out.str()) {}
+
     stream_type & out() { return m_out; }
     cache_string msg() { return cache_string( m_out.str(), prepend_size, append_size ); }
 private:

Modified: sandbox/logging/boost/logging/sink.hpp
==============================================================================
--- sandbox/logging/boost/logging/sink.hpp (original)
+++ sandbox/logging/boost/logging/sink.hpp 2007-10-15 05:29:08 EDT (Mon, 15 Oct 2007)
@@ -70,9 +70,9 @@
         @sa sink
     */
     template<class process_msg_type> struct negate_sink : sink<process_msg_type> {
- typedef typename sink<process_msg_type> base_type;
+ typedef sink<process_msg_type> base_type;
         template<class logger> negate_sink(const logger & f) : base_type(f) {}
- operator bool() const { return p == 0; }
+ operator bool() const { return base_type::p == 0; }
     };
 
 }}

Modified: sandbox/logging/boost/logging/writer/on_dedicated_thread.hpp
==============================================================================
--- sandbox/logging/boost/logging/writer/on_dedicated_thread.hpp (original)
+++ sandbox/logging/boost/logging/writer/on_dedicated_thread.hpp 2007-10-15 05:29:08 EDT (Mon, 15 Oct 2007)
@@ -102,15 +102,15 @@
     BOOST_LOGGING_FORWARD_CONSTRUCTOR(on_dedicated_thread,base_type)
 
     void write_period(int period_ms) {
- scoped_lock lk( context().cs);
- context().write_period_ms = period_ms;
+ scoped_lock lk( context_type::context().cs);
+ context_type::context().write_period_ms = period_ms;
     }
 
     ~on_dedicated_thread() {
         boost::shared_ptr<boost::thread> writer;
- { scoped_lock lk( context().cs);
- context().is_working = false;
- writer = context().writer;
+ { scoped_lock lk( context_type::context().cs);
+ context_type::context().is_working = false;
+ writer = context_type::context().writer;
         }
 
         if ( writer)
@@ -118,14 +118,14 @@
     }
 
     void operator()(const msg_type & msg) {
- context_type::ptr new_msg(new msg_type(msg));
+ typedef typename context_type::ptr ptr;
+ ptr new_msg(new msg_type(msg));
 
- typedef boost::shared_ptr<boost::thread> ptr;
- scoped_lock lk( context().cs);
- if ( !context().writer)
- context().writer = ptr( new boost::thread( boost::bind(&self_type::do_write,this) ));
+ scoped_lock lk( context_type::context().cs);
+ if ( !context_type::context().writer)
+ context_type::context().writer = ptr( new boost::thread( boost::bind(&self_type::do_write,this) ));
 
- context().msgs.push_back(new_msg);
+ context_type::context().msgs.push_back(new_msg);
     }
 private:
     void do_write() {
@@ -133,10 +133,10 @@
 
         int sleep_ms = 0;
         while ( true) {
- { scoped_lock lk( context().cs);
+ { scoped_lock lk( context_type::context().cs);
               // refresh it - just in case it got changed...
- sleep_ms = context().write_period_ms;
- if ( !context().is_working)
+ sleep_ms = context_type::context().write_period_ms;
+ if ( !context_type::context().is_working)
                   break; // we've been destroyed
             }
 
@@ -150,10 +150,10 @@
 
             typedef typename context_type::array array;
             array msgs;
- { scoped_lock lk( context().cs);
- std::swap( context().msgs, msgs);
+ { scoped_lock lk( context_type::context().cs);
+ std::swap( context_type::context().msgs, msgs);
               // reserve elements - so that we don't get automatically resized often
- context().msgs.reserve( msgs.size() );
+ context_type::context().msgs.reserve( msgs.size() );
             }
 
             for ( typename array::iterator b = msgs.begin(), e = msgs.end(); b != e; ++b)

Added: sandbox/logging/lib/logging/samples/gcc/main.cpp
==============================================================================
--- (empty file)
+++ sandbox/logging/lib/logging/samples/gcc/main.cpp 2007-10-15 05:29:08 EDT (Mon, 15 Oct 2007)
@@ -0,0 +1,12 @@
+#include <cstdlib>
+#include <iostream>
+
+void test_simple_format_and_write_simple_formatter();
+
+using namespace std;
+
+int main(int argc, char *argv[])
+{
+test_simple_format_and_write_simple_formatter();
+ return EXIT_SUCCESS;
+}

Modified: sandbox/logging/lib/logging/src/changelog.txt
==============================================================================
--- sandbox/logging/lib/logging/src/changelog.txt (original)
+++ sandbox/logging/lib/logging/src/changelog.txt 2007-10-15 05:29:08 EDT (Mon, 15 Oct 2007)
@@ -12,3 +12,7 @@
 v0.6, 13 oct 2007
 - added formatters from v1. of the library
 - added convert_format cool function :P
+
+v0.7, 15 oct 2007
+- compiles with gcc 3.4.2
+


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