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

#include <bdlsb_overflowmemoutstreambuf.h>

Inheritance diagram for bdlsb::OverflowMemOutStreamBuf:

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (OverflowMemOutStreamBuf, bslma::UsesBslmaAllocator)
 
 OverflowMemOutStreamBuf (char *buffer, bsl::size_t size, bslma::Allocator *basicAllocator=0)
 
 ~OverflowMemOutStreamBuf () BSLS_KEYWORD_OVERRIDE
 Destroy this stream buffer.
 
bsl::size_t dataLength () const
 
bsl::size_t dataLengthInInitialBuffer () const
 
bsl::size_t dataLengthInOverflowBuffer () const
 
const char * initialBuffer () const
 Return a pointer to the non-modifiable buffer supplied at construction.
 
bsl::size_t initialBufferSize () const
 Return the size of the buffer supplied at construction.
 
const char * overflowBuffer () const
 
bsl::size_t overflowBufferSize () const
 

Protected Member Functions

pos_type seekoff (off_type offset, bsl::ios_base::seekdir way, bsl::ios_base::openmode which=bsl::ios_base::in|bsl::ios_base::out) BSLS_KEYWORD_OVERRIDE
 
pos_type seekpos (pos_type position, bsl::ios_base::openmode which=bsl::ios_base::in|bsl::ios_base::out) BSLS_KEYWORD_OVERRIDE
 
int sync () BSLS_KEYWORD_OVERRIDE
 
bsl::streamsize xsputn (const char_type *source, bsl::streamsize numChars) BSLS_KEYWORD_OVERRIDE
 
int_type overflow (int_type c=bsl::streambuf::traits_type::eof()) BSLS_KEYWORD_OVERRIDE
 

Detailed Description

This class implements the output functionality of the bsl::basic_streambuf protocol, using client-supplied memory and client-supplied allocator if additional memory is needed.

See bdlsb_overflowmemoutstreambuf

Constructor & Destructor Documentation

◆ OverflowMemOutStreamBuf()

bdlsb::OverflowMemOutStreamBuf::OverflowMemOutStreamBuf ( char *  buffer,
bsl::size_t  size,
bslma::Allocator basicAllocator = 0 
)

Create an empty stream buffer that uses the specified buffer as an initial output buffer of the specified size (in bytes). 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 points to a valid sequence of positive size characters. Note that this stream buffer does not assume ownership of buffer.

◆ ~OverflowMemOutStreamBuf()

bdlsb::OverflowMemOutStreamBuf::~OverflowMemOutStreamBuf ( )
inline

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

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

◆ dataLength()

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

Return the number of bytes written to this stream. Note that if pptr() is currently pointing into the overflow buffer the data length will be greater than the size of the initial buffer.

◆ dataLengthInInitialBuffer()

bsl::size_t bdlsb::OverflowMemOutStreamBuf::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::OverflowMemOutStreamBuf::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::OverflowMemOutStreamBuf::initialBuffer ( ) const
inline

◆ initialBufferSize()

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

◆ overflow()

int_type bdlsb::OverflowMemOutStreamBuf::overflow ( int_type  c = bsl::streambuf::traits_type::eof())
protected

If c is not EOF, adjust the underlying buffer so that the next put position is valid, put the specified c at this position, and increment the put position. Return c on success, and traits_type::not_eof(c) if c is EOF.

◆ overflowBuffer()

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

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

◆ overflowBufferSize()

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

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

◆ seekoff()

pos_type bdlsb::OverflowMemOutStreamBuf::seekoff ( off_type  offset,
bsl::ios_base::seekdir  way,
bsl::ios_base::openmode  which = bsl::ios_base::in|bsl::ios_base::out 
)
protected

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 negative.

◆ seekpos()

OverflowMemOutStreamBuf::pos_type bdlsb::OverflowMemOutStreamBuf::seekpos ( pos_type  position,
bsl::ios_base::openmode  which = bsl::ios_base::in | bsl::ios_base::out 
)
inlineprotected

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 negative.

◆ sync()

int bdlsb::OverflowMemOutStreamBuf::sync ( )
inlineprotected

Set d_dataLength to the amount of data that has been written to this stream buffer, from the beginning of the stream to the current pptr() position and return 0. Note that if pptr() points into the overflow buffer, this size the initial buffer, plus the portion of the overflow buffer that has been written to.

◆ xsputn()

bsl::streamsize bdlsb::OverflowMemOutStreamBuf::xsputn ( const char_type *  source,
bsl::streamsize  numChars 
)
protected

Write the specified numChars characters from the specified source to the stream buffer. Return the number of characters successfully written. The behavior is undefined unless '(source && 0 < numChars) || 0 == numChars'.


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