replaced use of scope_guard with closer

[SVN r27122]
This commit is contained in:
Jonathan Turkanis
2005-02-04 21:47:58 +00:00
parent 82f066c45f
commit d18e2b08bd
2 changed files with 20 additions and 24 deletions

View File

@@ -18,10 +18,8 @@
#include <ios> // openmode.
#include <iterator> // back_inserter
#include <vector>
#include <boost/bind.hpp> // Used w/ scope_guard.
#include <boost/ref.hpp> // Used w/ scope_guard.
#include <boost/iostreams/categories.hpp>
#include <boost/iostreams/detail/scope_guard.hpp>
#include <boost/iostreams/detail/closer.hpp>
namespace boost { namespace iostreams {
@@ -71,16 +69,16 @@ public:
data_.insert(data_.end(), s, s + n);
}
#include <boost/iostreams/detail/scope_guard_prefix.hpp> // CW workaround
typedef one_step_filter<Ch, Alloc> self;
friend struct detail::closer<self>;
template<typename Sink>
void close(Sink& sink, std::ios::openmode which)
{
if ((state_ & f_read) && (which & std::ios::in))
close_impl();
close();
if ((state_ & f_write) && (which & std::ios::out)) {
typedef one_step_filter<Ch, Alloc> self;
BOOST_SCOPE_GUARD(boost::bind(&self::close_impl, boost::ref(*this)));
detail::closer<self> closer(*this);
vector_type filtered;
do_filter(data_, filtered);
boost::iostreams::write(
@@ -89,7 +87,6 @@ public:
);
}
}
#include <boost/iostreams/detail/scope_guard_suffix.hpp>
protected:
typedef std::vector<Ch, Alloc> vector_type;
@@ -111,7 +108,7 @@ private:
state_ |= f_eof;
}
void close_impl()
void close()
{
data_.clear();
ptr_ = 0;

View File

@@ -38,15 +38,13 @@
#include <boost/iostreams/detail/disable_warnings.hpp> // MSVC.
#include <cassert>
#include <memory> // allocator
#include <boost/bind.hpp> // Used w/ scope_guard.
#include <boost/ref.hpp> // Used w/ scope_guard.
#include <boost/iostreams/constants.hpp> // buffer size.
#include <boost/iostreams/constants.hpp> // buffer size.
#include <memory> // allocator
#include <boost/config.hpp> // BOOST_DEDUCED_TYPENAME.
#include <boost/iostreams/constants.hpp> // buffer size.
#include <boost/iostreams/detail/buffer.hpp>
#include <boost/iostreams/detail/scope_guard.hpp>
#include <boost/iostreams/detail/closer.hpp>
#include <boost/iostreams/traits.hpp>
#include <boost/iostreams/operations.hpp> // read, write.
#include <boost/iostreams/operations.hpp> // read, write.
#include <boost/shared_ptr.hpp>
namespace boost { namespace iostreams {
@@ -122,7 +120,8 @@ public:
}
}
#include <boost/iostreams/detail/scope_guard_prefix.hpp> // CW workaround.
typedef symmetric_filter_adapter_impl<SymmetricFilter, Alloc> self;
friend struct closer<self>;
template<typename Sink>
void close(Sink& snk, std::ios::openmode which)
{
@@ -130,11 +129,8 @@ public:
if ((state_ & f_read) && (which & ios::in))
close();
if ((state_ & f_write) && (which & ios::out)) {
void (symmetric_filter_adapter_impl::*close) () =
&symmetric_filter_adapter_impl::close;
BOOST_SCOPE_GUARD(bind(close, ref(*this)));
char e; // Dummy.
closer<self> closer(*this);
char e; // Dummy.
const char* end = &e;
bool done = false;
flush(snk);
@@ -146,7 +142,6 @@ public:
}
}
}
#include <boost/iostreams/detail/scope_guard_suffix.hpp>
SymmetricFilter& filter() { return *filter_; }
string_type unconsumed_input() const;
@@ -180,7 +175,11 @@ private:
} // End namespace detail.
template< typename SymmetricFilter,
typename Alloc = std::allocator<BOOST_IOSTREAMS_CHAR_TYPE(SymmetricFilter)> >
typename Alloc =
std::allocator<
BOOST_DEDUCED_TYPENAME
io_char<SymmetricFilter>::type
> >
class symmetric_filter_adapter {
private:
typedef detail::symmetric_filter_adapter_impl<