Panda3D
Public Member Functions | List of all members
OStreamWrapper Class Reference

This class provides a locking wrapper around an arbitrary ostream pointer. More...

#include "streamWrapper.h"

Inheritance diagram for OStreamWrapper:
StreamWrapperBase StreamWrapper

Public Member Functions

 OStreamWrapper (ostream *stream, bool owns_pointer, bool stringstream_hack=false)
 
 OStreamWrapper (ostream &stream)
 
ostream * get_ostream () const
 Returns the ostream this object is wrapping. More...
 
bool put (char c)
 Atomically writes a single character to the stream. More...
 
void seek_eof_write (const char *buffer, streamsize num_bytes, bool &fail)
 Atomically seeks to the end of the file, and writes a number of bytes to the stream. More...
 
streamsize seek_ppos_eof ()
 Atomically seeks to EOF and returns the ppos there; that is, returns the file size. More...
 
void seek_write (streamsize pos, const char *buffer, 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, streamsize num_bytes)
 Atomically writes a number of bytes to the stream, without error detection. More...
 
void write (const char *buffer, streamsize num_bytes, bool &fail)
 Atomically writes a number of bytes to the stream. More...
 
- Public Member Functions inherited from StreamWrapperBase
void acquire ()
 Acquires the internal lock. More...
 
void release ()
 Releases the internal lock. More...
 

Detailed Description

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 81 of file streamWrapper.h.

Member Function Documentation

◆ get_ostream()

ostream * OStreamWrapper::get_ostream ( ) const
inline

Returns the ostream this object is wrapping.

Definition at line 158 of file streamWrapper.I.

References put().

Referenced by IStreamWrapper::get().

◆ put()

bool OStreamWrapper::put ( char  c)
inline

Atomically writes a single character to the stream.

Returns true on success, false on failure.

Definition at line 169 of file streamWrapper.I.

References StreamWrapperBase::acquire(), StreamWrapper::get_iostream(), and StreamWrapperBase::release().

Referenced by get_ostream().

◆ seek_eof_write()

void OStreamWrapper::seek_eof_write ( const char *  buffer,
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 236 of file streamWrapper.cxx.

References StreamWrapperBase::acquire(), StreamWrapperBase::release(), and seek_ppos_eof().

Referenced by seek_write(), and SubStreamBuf::seekpos().

◆ seek_ppos_eof()

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 263 of file streamWrapper.cxx.

References StreamWrapperBase::acquire(), and StreamWrapperBase::release().

Referenced by seek_eof_write(), and SubStreamBuf::seekoff().

◆ seek_write()

void OStreamWrapper::seek_write ( streamsize  pos,
const char *  buffer,
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 209 of file streamWrapper.cxx.

References StreamWrapperBase::acquire(), StreamWrapperBase::release(), and seek_eof_write().

Referenced by SubStreamBuf::seekpos(), and write().

◆ write() [1/2]

void OStreamWrapper::write ( const char *  buffer,
streamsize  num_bytes 
)

Atomically writes a number of bytes to the stream, without error detection.

Definition at line 178 of file streamWrapper.cxx.

References StreamWrapperBase::acquire(), and StreamWrapperBase::release().

Referenced by IStreamWrapper::seek_gpos_eof().

◆ write() [2/2]

void OStreamWrapper::write ( const char *  buffer,
streamsize  num_bytes,
bool &  fail 
)

Atomically writes a number of bytes to the stream.

Returns whether a failure condition was detected by the operation.

Definition at line 192 of file streamWrapper.cxx.

References StreamWrapperBase::acquire(), StreamWrapperBase::release(), and seek_write().


The documentation for this class was generated from the following files: