Boost logo

Boost-Commit :

From: technews_at_[hidden]
Date: 2008-01-14 15:31:40


Author: turkanis
Date: 2008-01-14 15:31:39 EST (Mon, 14 Jan 2008)
New Revision: 42777
URL: http://svn.boost.org/trac/boost/changeset/42777

Log:
fixes for overhaul of dual_use filters
Text files modified:
   branches/iostreams_dev/boost/iostreams/combine.hpp | 26 ++++++++++----------
   branches/iostreams_dev/boost/iostreams/compose.hpp | 21 ++++++----------
   branches/iostreams_dev/libs/iostreams/test/combine_test.cpp | 48 ++++++++++++++++++++++++++++++++++++++++
   3 files changed, 69 insertions(+), 26 deletions(-)

Modified: branches/iostreams_dev/boost/iostreams/combine.hpp
==============================================================================
--- branches/iostreams_dev/boost/iostreams/combine.hpp (original)
+++ branches/iostreams_dev/boost/iostreams/combine.hpp 2008-01-14 15:31:39 EST (Mon, 14 Jan 2008)
@@ -99,22 +99,22 @@
 
     template<typename Sink>
     void close(Sink& snk, BOOST_IOS::openmode which)
- {
- if (which == BOOST_IOS::in) {
- if (is_convertible<in_category, dual_use>::value) {
- iostreams::close(in_, snk, BOOST_IOS::in);
- } else {
- detail::close_all(in_, snk);
- }
+ {
+ if (which == BOOST_IOS::in) {
+ if (is_convertible<in_category, dual_use>::value) {
+ iostreams::close(in_, snk, BOOST_IOS::in);
+ } else {
+ detail::close_all(in_, snk);
             }
- if (which == BOOST_IOS::out) {
- if (is_convertible<in_category, dual_use>::value) {
- iostreams::close(out_, snk, BOOST_IOS::out);
- } else {
- detail::close_all(out_, snk);
- }
+ }
+ if (which == BOOST_IOS::out) {
+ if (is_convertible<out_category, dual_use>::value) {
+ iostreams::close(out_, snk, BOOST_IOS::out);
+ } else {
+ detail::close_all(out_, snk);
             }
         }
+ }
     #ifndef BOOST_NO_STD_LOCALE
         void imbue(const std::locale& loc);
     #endif

Modified: branches/iostreams_dev/boost/iostreams/compose.hpp
==============================================================================
--- branches/iostreams_dev/boost/iostreams/compose.hpp (original)
+++ branches/iostreams_dev/boost/iostreams/compose.hpp 2008-01-14 15:31:39 EST (Mon, 14 Jan 2008)
@@ -416,6 +416,11 @@
 void composite_device<Filter, Device, Mode>::close()
 {
     BOOST_STATIC_ASSERT((!is_convertible<Mode, two_sequence>::value));
+ BOOST_STATIC_ASSERT(
+ !(is_convertible<filter_mode, dual_use>::value) ||
+ !(is_convertible<device_mode, input>::value) ||
+ !(is_convertible<device_mode, output>::value)
+ );
 
     // Close input sequences in reverse order and output sequences
     // in forward order
@@ -443,17 +448,10 @@
 void composite_device<Filter, Device, Mode>::close(BOOST_IOS::openmode which)
 {
     BOOST_STATIC_ASSERT((is_convertible<Mode, two_sequence>::value));
- BOOST_STATIC_ASSERT(
- !(is_convertible<filter_mode, dual_use>::value) ||
- !(is_convertible<device_mode, input>::value) ||
- !(is_convertible<device_mode, output>::value)
- );
+ BOOST_STATIC_ASSERT(!(is_convertible<filter_mode, dual_use>::value));
 
     // Close input sequences in reverse order
- if ( which == BOOST_IOS::in &&
- ( !is_convertible<filter_mode, dual_use>::value ||
- is_convertible<device_mode, input>::value ) )
- {
+ if (which == BOOST_IOS::in) {
         detail::execute_all(
             detail::call_close(device_, BOOST_IOS::in),
             detail::call_close(filter_, device_, BOOST_IOS::in)
@@ -461,10 +459,7 @@
     }
 
     // Close output sequences in forward order
- if ( which == BOOST_IOS::out &&
- ( !is_convertible<filter_mode, dual_use>::value ||
- is_convertible<device_mode, output>::value ) )
- {
+ if (which == BOOST_IOS::out) {
         detail::execute_all(
             detail::call_close(filter_, device_, BOOST_IOS::out),
             detail::call_close(device_, BOOST_IOS::out)

Modified: branches/iostreams_dev/libs/iostreams/test/combine_test.cpp
==============================================================================
--- branches/iostreams_dev/libs/iostreams/test/combine_test.cpp (original)
+++ branches/iostreams_dev/libs/iostreams/test/combine_test.cpp 2008-01-14 15:31:39 EST (Mon, 14 Jan 2008)
@@ -142,6 +142,54 @@
         BOOST_CHECK_OPERATION_SEQUENCE(seq);
     }
 
+ // Combine a dual-use filter and an input filter
+ {
+ operation_sequence seq;
+ chain<bidirectional> ch;
+ operation dummy;
+ ch.push(
+ io::combine(
+ closable_filter<input>(seq.new_operation(2)),
+ closable_filter<dual_use>(
+ dummy,
+ seq.new_operation(3)
+ )
+ )
+ );
+ ch.push(
+ closable_device<bidirectional>(
+ seq.new_operation(1),
+ seq.new_operation(4)
+ )
+ );
+ BOOST_CHECK_NO_THROW(ch.reset());
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+ }
+
+ // Combine a dual-use filter and an output filter
+ {
+ operation_sequence seq;
+ chain<bidirectional> ch;
+ operation dummy;
+ ch.push(
+ io::combine(
+ closable_filter<dual_use>(
+ seq.new_operation(2),
+ dummy
+ ),
+ closable_filter<output>(seq.new_operation(3))
+ )
+ );
+ ch.push(
+ closable_device<bidirectional>(
+ seq.new_operation(1),
+ seq.new_operation(4)
+ )
+ );
+ BOOST_CHECK_NO_THROW(ch.reset());
+ BOOST_CHECK_OPERATION_SEQUENCE(seq);
+ }
+
     // Combine two dual-use filters
     {
         operation_sequence seq;


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