From fdcd9b1d33d228d814e7845907f7cd7fc025bae1 Mon Sep 17 00:00:00 2001 From: Jonathan Turkanis Date: Wed, 13 Apr 2005 04:26:01 +0000 Subject: [PATCH] added strict_sync [SVN r28194] --- .../iostreams/detail/streambuf/direct_streambuf.hpp | 1 + .../detail/streambuf/indirect_streambuf.hpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/boost/iostreams/detail/streambuf/direct_streambuf.hpp b/include/boost/iostreams/detail/streambuf/direct_streambuf.hpp index e4bfeda..853c9a6 100755 --- a/include/boost/iostreams/detail/streambuf/direct_streambuf.hpp +++ b/include/boost/iostreams/detail/streambuf/direct_streambuf.hpp @@ -53,6 +53,7 @@ public: // stream_facade needs access. void close(); bool auto_close() const { return auto_close_; } void set_auto_close(bool close) { auto_close_ = close; } + bool strict_sync() { return true; } // Declared in linked_streambuf. T* component() { return storage_.get_ptr(); } diff --git a/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp b/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp index 3298993..c787766 100755 --- a/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp +++ b/include/boost/iostreams/detail/streambuf/indirect_streambuf.hpp @@ -63,6 +63,7 @@ public: void close(); bool auto_close() const; void set_auto_close(bool close); + bool strict_sync(); // Declared in linked_streambuf. T* component() { return &*obj(); } @@ -356,10 +357,20 @@ int indirect_streambuf::sync() { try { // sync() is no-throw. sync_impl(); - return obj().flush(next_) ? 0 : -1; + obj().flush(next_); + return 0; } catch (std::exception&) { return -1; } } +template +bool indirect_streambuf::strict_sync() +{ + try { // sync() is no-throw. + sync_impl(); + return obj().flush(next_); + } catch (std::exception&) { return false; } +} + template inline typename indirect_streambuf::pos_type indirect_streambuf::seekoff