Quick Links:

bal | bbl | bdl | bsl

Public Member Functions | Protected Member Functions

bdlsb::MemOutStreamBuf Class Reference

#include <bdlsb_memoutstreambuf.h>

List of all members.

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 ()
void reserveCapacity (bsl::size_t numCharacters)
void reset ()
bsl::size_t capacity () const
const char * data () const
bsl::size_t length () const

Protected Member Functions

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

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 Component bdlsb_memoutstreambuf


Constructor & Destructor Documentation

bdlsb::MemOutStreamBuf::MemOutStreamBuf ( bslma::Allocator basicAllocator = 0  )  [explicit]

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

bdlsb::MemOutStreamBuf::MemOutStreamBuf ( bsl::size_t  numElements,
bslma::Allocator basicAllocator = 0 
) [explicit]

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.

bdlsb::MemOutStreamBuf::~MemOutStreamBuf (  ) 

Destroy this stream buffer.


Member Function Documentation

virtual int_type bdlsb::MemOutStreamBuf::overflow ( int_type  insertionChar = bsl::streambuf::traits_type::eof()  )  [protected, virtual]

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.

virtual 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, virtual]

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().

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

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().

virtual bsl::streamsize bdlsb::MemOutStreamBuf::xsputn ( const char_type *  source,
bsl::streamsize  numChars 
) [protected, virtual]

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

bdlsb::MemOutStreamBuf::BSLMF_NESTED_TRAIT_DECLARATION ( MemOutStreamBuf  ,
bslma::UsesBslmaAllocator   
)
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.

void bdlsb::MemOutStreamBuf::reset (  ) 

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.

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

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

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

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

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

Return the number of valid characters in this stream buffer.


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