added strict_sync

[SVN r28194]
This commit is contained in:
Jonathan Turkanis
2005-04-13 04:26:01 +00:00
parent d04950c451
commit fdcd9b1d33
2 changed files with 13 additions and 1 deletions

View File

@@ -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(); }

View File

@@ -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<T, Tr, Alloc, Mode>::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<typename T, typename Tr, typename Alloc, typename Mode>
bool indirect_streambuf<T, Tr, Alloc, Mode>::strict_sync()
{
try { // sync() is no-throw.
sync_impl();
return obj().flush(next_);
} catch (std::exception&) { return false; }
}
template<typename T, typename Tr, typename Alloc, typename Mode>
inline typename indirect_streambuf<T, Tr, Alloc, Mode>::pos_type
indirect_streambuf<T, Tr, Alloc, Mode>::seekoff