aboutsummaryrefslogtreecommitdiffstats
path: root/src/fs/io/BufferedOutputStream.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-03-22 17:01:33 +0100
committerMax Kellermann <max@duempel.org>2015-03-23 22:03:25 +0100
commitcd352716981310c37ae59d9b09f353b621318a3b (patch)
tree1212e74cc9263e7f9d24f5f67ae2c41823f8e3af /src/fs/io/BufferedOutputStream.hxx
parent7b575f61d0f5c34267fcfd60229d25edbcbe33da (diff)
downloadmpd-cd352716981310c37ae59d9b09f353b621318a3b.tar.gz
mpd-cd352716981310c37ae59d9b09f353b621318a3b.tar.xz
mpd-cd352716981310c37ae59d9b09f353b621318a3b.zip
fs/io/BufferedOutputStream: add code comments
Diffstat (limited to 'src/fs/io/BufferedOutputStream.hxx')
-rw-r--r--src/fs/io/BufferedOutputStream.hxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/fs/io/BufferedOutputStream.hxx b/src/fs/io/BufferedOutputStream.hxx
index 9be4c125a..63a3f4aee 100644
--- a/src/fs/io/BufferedOutputStream.hxx
+++ b/src/fs/io/BufferedOutputStream.hxx
@@ -30,6 +30,14 @@
class OutputStream;
class Error;
+/**
+ * An #OutputStream wrapper that buffers its output to reduce the
+ * number of OutputStream::Write() calls.
+ *
+ * It simplifies error handling by managing an #Error attribute.
+ * Invoke any number of writes, and check for errors in the end using
+ * Check().
+ */
class BufferedOutputStream {
OutputStream &os;
@@ -47,11 +55,18 @@ public:
gcc_printf(2,3)
bool Format(const char *fmt, ...);
+ /**
+ * Returns false if an error has occurred.
+ */
gcc_pure
bool Check() const {
return !last_error.IsDefined();
}
+ /**
+ * Returns false if an error has occurred. In that case, a
+ * copy of the #Error is returned.
+ */
bool Check(Error &error) const {
if (last_error.IsDefined()) {
error.Set(last_error);
@@ -60,6 +75,9 @@ public:
return true;
}
+ /**
+ * Write buffer contents to the #OutputStream.
+ */
bool Flush();
bool Flush(Error &error);