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

#include <bdlsb_memoutstreambuf.h>

Inheritance diagram for bdlsb::MemOutStreamBuf:

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (MemOutStreamBuf, bslma::UsesBslmaAllocator)
 
 MemOutStreamBuf (bslma::Allocator *basicAllocator=0)
 
 MemOutStreamBuf (bsl::size_t numElements, bslma::Allocator *basicAllocator=0)
 
 ~MemOutStreamBuf () BSLS_KEYWORD_OVERRIDE
 Destroy this stream buffer.
 
void reserveCapacity (bsl::size_t numCharacters)
 
void reset ()
 
bsl::size_t capacity () const
 
const char * data () const
 
bsl::size_t length () const
 Return the number of valid characters in this stream buffer.
 

Protected Member Functions

int_type overflow (int_type insertionChar=bsl::streambuf::traits_type::eof()) BSLS_KEYWORD_OVERRIDE
 
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
 
bsl::streamsize xsputn (const char_type *source, bsl::streamsize numChars) BSLS_KEYWORD_OVERRIDE
 

Detailed Description

This class implements the output functionality of the basic_streambuf protocol, using a user-supplied or default bslma allocator to supply memory.

See bdlsb_memoutstreambuf

Constructor & Destructor Documentation

◆ MemOutStreamBuf() [1/2]

bdlsb::MemOutStreamBuf::MemOutStreamBuf ( bslma::Allocator basicAllocator = 0)
inlineexplicit

Create an empty stream buffer. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ MemOutStreamBuf() [2/2]

bdlsb::MemOutStreamBuf::MemOutStreamBuf ( bsl::size_t  numElements,
bslma::Allocator basicAllocator = 0 
)
inlineexplicit

Create an empty stream buffer with sufficient initial capacity to accommodate up to the specified numElements characters without subsequent reallocation. If numElements == 0, an implementation-defined initial capacity is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ ~MemOutStreamBuf()

bdlsb::MemOutStreamBuf::~MemOutStreamBuf ( )
inline

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

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

◆ capacity()

bsl::size_t bdlsb::MemOutStreamBuf::capacity ( ) const
inline

Return the current capacity of the buffer managed by this stream buffer.

◆ data()

const char * bdlsb::MemOutStreamBuf::data ( ) const
inline

Return the address of the non-modifiable character buffer managed by this stream buffer.

◆ length()

bsl::size_t bdlsb::MemOutStreamBuf::length ( ) const
inline

◆ overflow()

int_type bdlsb::MemOutStreamBuf::overflow ( int_type  insertionChar = bsl::streambuf::traits_type::eof())
protected

Append the optionally specified insertionChar to this stream buffer's character buffer and return insertionChar. If insertionChar is not specified, traits_type::eof() is appended instead.

◆ reserveCapacity()

void bdlsb::MemOutStreamBuf::reserveCapacity ( bsl::size_t  numCharacters)

Reserve sufficient internal capacity to store at least the specified numCharacters characters without reallocation. Note that if the storage size specified is less than the number of characters already in the buffer, this method has no effect.

◆ reset()

void bdlsb::MemOutStreamBuf::reset ( )
inline

Destroy the contents of this stream buffer, return all allocated memory to the allocator, and reset the buffer to the default constructed state. Note that length() == 0 holds following a call to this method.

◆ seekoff()

pos_type bdlsb::MemOutStreamBuf::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 less than zero or greater then length().

◆ seekpos()

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

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 or greater than length().

◆ xsputn()

bsl::streamsize bdlsb::MemOutStreamBuf::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: