BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlsb::OverflowMemOutput Class Reference

#include <bdlsb_overflowmemoutput.h>

Public Types

typedef char char_type
 
typedef bsl::char_traits< char > traits_type
 
typedef traits_type::int_type int_type
 
typedef traits_type::pos_type pos_type
 
typedef traits_type::off_type off_type
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (OverflowMemOutput, bslma::UsesBslmaAllocator)
 
 OverflowMemOutput (char *buffer, bsl::size_t length, bslma::Allocator *basicAllocator=0)
 
 ~OverflowMemOutput ()
 Destroy this stream buffer.
 
pos_type pubseekoff (off_type offset, bsl::ios_base::seekdir way, bsl::ios_base::openmode which=bsl::ios_base::out)
 
pos_type pubseekpos (pos_type position, bsl::ios_base::openmode which=bsl::ios_base::out)
 
OverflowMemOutputpubsetbuf (char *buffer, bsl::streamsize length)
 
int pubsync ()
 
int_type sputc (char c)
 
bsl::streamsize sputn (const char *source, bsl::streamsize length)
 
bsl::size_t dataLength () const
 Return the number of bytes that have been written to this object.
 
bsl::size_t dataLengthInInitialBuffer () const
 
bsl::size_t dataLengthInOverflowBuffer () const
 
const char * initialBuffer () const
 
bsl::size_t initialBufferSize () const
 Return the size of the initial buffer held by this stream buffer.
 
const char * overflowBuffer () const
 
bsl::size_t overflowBufferSize () const
 

Detailed Description

This class, like bdlsb::OverflowMemOutStreamBuf, implements the output functionality of the bsl::basic_streambuf interface, using a client-supplied buffer and allocator-supplied overflow buffer if additional memory is needed. It has an interface similar to bdlsb::OverflowMemOutStreamBuf but does not inherit from bsl::streambuf. Thus, it is suitable for use as template parameter to bslx::GenericByteOutStream (but not to bslx::ByteOutStream or bslx::ByteOutStreamFormatter). Note that this class is not designed to be derived from.

See bdlsb_overflowmemoutput

Member Typedef Documentation

◆ char_type

◆ int_type

typedef traits_type::int_type bdlsb::OverflowMemOutput::int_type

◆ off_type

typedef traits_type::off_type bdlsb::OverflowMemOutput::off_type

◆ pos_type

typedef traits_type::pos_type bdlsb::OverflowMemOutput::pos_type

◆ traits_type

typedef bsl::char_traits<char> bdlsb::OverflowMemOutput::traits_type

Constructor & Destructor Documentation

◆ OverflowMemOutput()

bdlsb::OverflowMemOutput::OverflowMemOutput ( char *  buffer,
bsl::size_t  length,
bslma::Allocator basicAllocator = 0 
)

Create an OverflowMemOutput using the specified buffer of the specified length as the initial output buffer. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless buffer != 0 && length > 0. Note that this stream buffer does not assume ownership of buffer.

◆ ~OverflowMemOutput()

bdlsb::OverflowMemOutput::~OverflowMemOutput ( )
inline

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

bdlsb::OverflowMemOutput::BSLMF_NESTED_TRAIT_DECLARATION ( OverflowMemOutput  ,
bslma::UsesBslmaAllocator   
)

◆ dataLength()

bsl::size_t bdlsb::OverflowMemOutput::dataLength ( ) const
inline

◆ dataLengthInInitialBuffer()

bsl::size_t bdlsb::OverflowMemOutput::dataLengthInInitialBuffer ( ) const
inline

Return the length of data in the initial buffer, i.e., dataLength() if there is no overflow buffer, or initialBufferSize() if there is one.

◆ dataLengthInOverflowBuffer()

bsl::size_t bdlsb::OverflowMemOutput::dataLengthInOverflowBuffer ( ) const
inline

Return the length of the data in the overflow buffer, i.e., 0 if there is no overflow buffer, or dataLength() - initialBufferSize() if there is one.

◆ initialBuffer()

const char * bdlsb::OverflowMemOutput::initialBuffer ( ) const
inline

Return a pointer providing non-modifiable access to the character buffer held by this stream buffer (specified at construction).

◆ initialBufferSize()

bsl::size_t bdlsb::OverflowMemOutput::initialBufferSize ( ) const
inline

◆ overflowBuffer()

const char * bdlsb::OverflowMemOutput::overflowBuffer ( ) const
inline

Return a pointer providing non-modifiable access to the overflow buffer if there is one, or 0 otherwise.

◆ overflowBufferSize()

bsl::size_t bdlsb::OverflowMemOutput::overflowBufferSize ( ) const
inline

Return the size of the overflow buffer, or 0 if there is no overflow buffer.

◆ pubseekoff()

pos_type bdlsb::OverflowMemOutput::pubseekoff ( off_type  offset,
bsl::ios_base::seekdir  way,
bsl::ios_base::openmode  which = bsl::ios_base::out 
)

Set the position indicator to the relative specified offset from the base position indicated by the specified way and return the resulting absolute position on success or pos_type(-1) on failure. Optionally specify which area of the stream buffer. The seek operation will fail if which does not include the flag bsl::ios_base::out or if the resulting absolute position is less than zero.

◆ pubseekpos()

OverflowMemOutput::pos_type bdlsb::OverflowMemOutput::pubseekpos ( pos_type  position,
bsl::ios_base::openmode  which = bsl::ios_base::out 
)
inline

Set the position indicator to the specified position and return the resulting absolute position on success or pos_type(-1) on failure. Optionally specify which area of the stream buffer. The seekpos operation will fail if which does not include the flag bsl::ios_base::out or if position is less then zero.

◆ pubsetbuf()

OverflowMemOutput * bdlsb::OverflowMemOutput::pubsetbuf ( char *  buffer,
bsl::streamsize  length 
)
inline

Reinitialize this stream buffer to use the specified character buffer having the specified length. Return a pointer providing modifiable access to this stream buffer. This stream buffer does not support reinitialization of the internal character buffer.

◆ pubsync()

int bdlsb::OverflowMemOutput::pubsync ( )
inline

Synchronize this stream buffer with associated character sequence. Operation has no effect. Return 0 unconditionally.

◆ sputc()

int_type bdlsb::OverflowMemOutput::sputc ( char  c)

Write the specified character c at the current write position and advance write position of this buffer. Return c, or traits_type::eof() if the end of the write buffer is reached.

◆ sputn()

bsl::streamsize bdlsb::OverflowMemOutput::sputn ( const char *  source,
bsl::streamsize  length 
)

Write the specified length characters from the specified source to this buffer. Return the number of characters written, which is either length or the distance from the current write position to the end of the write buffer, whichever is smaller, and move the write cursor position by this amount. The behaviour is undefined unless source != 0 || length > 0.


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