This class provides a locking wrapper around an arbitrary ostream pointer. More...
#include "streamWrapper.h"
Public Member Functions | |
OStreamWrapper (std::ostream *stream, bool owns_pointer, bool stringstream_hack=false) | |
OStreamWrapper (std::ostream &stream) | |
std::ostream * | get_ostream () const |
bool | put (char c) |
Atomically writes a single character to the stream. More... | |
void | seek_eof_write (const char *buffer, std::streamsize num_bytes, bool &fail) |
Atomically seeks to the end of the file, and writes a number of bytes to the stream. More... | |
std::streamsize | seek_ppos_eof () |
Atomically seeks to EOF and returns the ppos there; that is, returns the file size. More... | |
void | seek_write (std::streamsize pos, const char *buffer, std::streamsize num_bytes, bool &fail) |
Atomically seeks to a particular offset from the beginning of the file, and writes a number of bytes to the stream. More... | |
void | write (const char *buffer, std::streamsize num_bytes) |
void | write (const char *buffer, std::streamsize num_bytes, bool &fail) |
Public Member Functions inherited from StreamWrapperBase | |
void | acquire () |
Acquires the internal lock. More... | |
void | ref () const |
Increments the reference count. More... | |
void | release () |
Releases the internal lock. More... | |
bool | unref () const |
Decrements the reference count. More... | |
Public Attributes | |
get_ostream | |
Returns the ostream this object is wrapping. More... | |
This class provides a locking wrapper around an arbitrary ostream pointer.
A thread may use this class to perform an atomic seek/write operation.
Definition at line 86 of file streamWrapper.h.
|
inline |
Atomically writes a single character to the stream.
Returns true on success, false on failure.
Definition at line 159 of file streamWrapper.I.
References StreamWrapperBase::acquire(), and StreamWrapperBase::release().
void OStreamWrapper::seek_eof_write | ( | const char * | buffer, |
std::streamsize | num_bytes, | ||
bool & | fail | ||
) |
Atomically seeks to the end of the file, and writes a number of bytes to the stream.
Returns whether a failure condition was detected by the operation.
Definition at line 206 of file streamWrapper.cxx.
References StreamWrapperBase::acquire(), and StreamWrapperBase::release().
streamsize OStreamWrapper::seek_ppos_eof | ( | ) |
Atomically seeks to EOF and returns the ppos there; that is, returns the file size.
Note that the EOF might have been moved in another thread by the time this method returns.
Definition at line 230 of file streamWrapper.cxx.
References StreamWrapperBase::acquire(), and StreamWrapperBase::release().
void OStreamWrapper::seek_write | ( | std::streamsize | pos, |
const char * | buffer, | ||
std::streamsize | num_bytes, | ||
bool & | fail | ||
) |
Atomically seeks to a particular offset from the beginning of the file, and writes a number of bytes to the stream.
Returns whether a failure condition was detected by the operation.
Definition at line 181 of file streamWrapper.cxx.
References StreamWrapperBase::acquire(), and StreamWrapperBase::release().
|
inline |
Returns the ostream this object is wrapping.
Definition at line 94 of file streamWrapper.h.