Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions | Protected Member Functions

bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR > Class Template Reference

#include <bslstl_stringbuf.h>

List of all members.

Public Types

typedef CHAR_TYPE char_type
typedef CHAR_TRAITS traits_type
typedef ALLOCATOR allocator_type
typedef traits_type::int_type int_type
typedef traits_type::off_type off_type
typedef traits_type::pos_type pos_type

Public Member Functions

 basic_stringbuf (const allocator_type &allocator=allocator_type())
 basic_stringbuf (ios_base::openmode modeBitMask, const allocator_type &allocator=allocator_type())
 basic_stringbuf (const StringType &initialString, const allocator_type &allocator=allocator_type())
 basic_stringbuf (const StringType &initialString, ios_base::openmode modeBitMask, const allocator_type &allocator=allocator_type())
 basic_stringbuf (BloombergLP::bslmf::MovableRef< StringType > initialString)
 basic_stringbuf (BloombergLP::bslmf::MovableRef< StringType > initialString, const allocator_type &allocator)
 basic_stringbuf (BloombergLP::bslmf::MovableRef< StringType > initialString, ios_base::openmode modeBitMask)
 basic_stringbuf (BloombergLP::bslmf::MovableRef< StringType > initialString, ios_base::openmode modeBitMask, const allocator_type &allocator)
template<class SALLOC >
 basic_stringbuf (const bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, SALLOC > &initialString, const allocator_type &allocator=allocator_type(), typename bsl::enable_if< !bsl::is_same< ALLOCATOR, SALLOC >::value, void * >::type=0)
template<class SALLOC >
 basic_stringbuf (const bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, SALLOC > &initialString, ios_base::openmode modeBitMask, const allocator_type &allocator=allocator_type(), typename bsl::enable_if< !bsl::is_same< ALLOCATOR, SALLOC >::value, void * >::type=0)
 ~basic_stringbuf ()
void str (const StringType &value)
void str (BloombergLP::bslmf::MovableRef< StringType > value)
template<class SALLOC >
bsl::enable_if<!bsl::is_same
< ALLOCATOR, SALLOC >::value,
void >::type 
str (const basic_string< CHAR_TYPE, CHAR_TRAITS, SALLOC > &value)
void swap (basic_stringbuf &other)
allocator_type get_allocator () const BSLS_KEYWORD_NOEXCEPT
StringType str () const
template<class SALLOC >
bsl::enable_if
< bsl::IsStdAllocator< SALLOC >
::value, basic_string
< CHAR_TYPE, CHAR_TRAITS,
SALLOC > >::type 
str (const SALLOC &allocator) const
ViewType view () const BSLS_KEYWORD_NOEXCEPT

Protected Member Functions

virtual pos_type seekoff (off_type offset, ios_base::seekdir whence, ios_base::openmode modeBitMask=ios_base::in|ios_base::out)
virtual pos_type seekpos (pos_type absoluteOffset, ios_base::openmode modeBitMask=ios_base::in|ios_base::out)
virtual std::streamsize xsgetn (char_type *result, std::streamsize numCharacters)
virtual int_type underflow ()
virtual int_type uflow ()
virtual int_type pbackfail (int_type character=traits_type::eof())
virtual std::streamsize xsputn (const char_type *inputString, std::streamsize numCharacters)
virtual int_type overflow (int_type character=traits_type::eof())

Detailed Description

template<class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
class bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >

This class implements a standard stream buffer providing an unformatted character input sequence and an unformatted character output sequence that may be initialized or accessed using a string value.

See Component bslstl_stringbuf


Member Typedef Documentation

template<class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
typedef CHAR_TYPE bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::char_type
template<class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
typedef CHAR_TRAITS bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::traits_type
template<class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
typedef ALLOCATOR bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::allocator_type
template<class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
typedef traits_type::int_type bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::int_type
template<class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
typedef traits_type::off_type bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::off_type
template<class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
typedef traits_type::pos_type bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::pos_type

Constructor & Destructor Documentation

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringbuf ( const allocator_type allocator = allocator_type()  )  [explicit]
template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringbuf ( ios_base::openmode  modeBitMask,
const allocator_type allocator = allocator_type() 
) [explicit]
template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringbuf ( const StringType initialString,
const allocator_type allocator = allocator_type() 
) [explicit]
template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringbuf ( const StringType initialString,
ios_base::openmode  modeBitMask,
const allocator_type allocator = allocator_type() 
) [inline]

Create a basic_stringbuf object. Optionally specify a modeBitMask indicating whether this buffer may be read from, written to, or both. If modeBitMask is not supplied, this buffer is created with ios_base::in | ios_base::out. Optionally specify an initialString indicating the initial sequence of characters that this buffer will access or manipulate. If initialString is not supplied, the initial sequence of characters will be empty. Optionally specify the allocator used to supply memory. If allocator is not supplied, a default-constructed object of the (template parameter) ALLOCATOR type is used. If the ALLOCATOR argument is of type bsl::allocator (the default), then allocator, if supplied, shall be convertible to bslma::Allocator *. If the ALLOCATOR argument is of type bsl::allocator and allocator is not supplied, the currently installed default allocator will be used to supply memory.

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringbuf ( BloombergLP::bslmf::MovableRef< StringType initialString  )  [inline, explicit]
template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringbuf ( BloombergLP::bslmf::MovableRef< StringType initialString,
const allocator_type allocator 
) [inline]
template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringbuf ( BloombergLP::bslmf::MovableRef< StringType initialString,
ios_base::openmode  modeBitMask 
) [inline]
template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringbuf ( BloombergLP::bslmf::MovableRef< StringType initialString,
ios_base::openmode  modeBitMask,
const allocator_type allocator 
) [inline]

Create a basic_stringbuf object. Use the specified initialString indicating the initial sequence of characters that this buffer will access or manipulate. Optionally specify a modeBitMask indicating whether this buffer may be read from, written to, or both. If modeBitMask is not supplied, this buffer is created with ios_base::in | ios_base::out. Optionally specify the allocator used to supply memory. If allocator is not supplied, the allocator in initialString is used. initialString is left in a valid but unspecified state.

template<class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
template<class SALLOC >
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringbuf ( const bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, SALLOC > &  initialString,
const allocator_type allocator = allocator_type(),
typename bsl::enable_if< !bsl::is_same< ALLOCATOR, SALLOC >::value, void * >::type  = 0 
) [inline, explicit]
template<class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
template<class SALLOC >
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringbuf ( const bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, SALLOC > &  initialString,
ios_base::openmode  modeBitMask,
const allocator_type allocator = allocator_type(),
typename bsl::enable_if< !bsl::is_same< ALLOCATOR, SALLOC >::value, void * >::type  = 0 
) [inline]
template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::~basic_stringbuf (  ) 

Destroy this object.

References BSLS_ASSERT.


Member Function Documentation

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::pos_type bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::seekoff ( off_type  offset,
ios_base::seekdir  whence,
ios_base::openmode  modeBitMask = ios_base::in | ios_base::out 
) [protected, virtual]

Set the current input position or the current output position (or both) to the specified offset from the specified whence location. Optionally specify a modeBitMask indicating whether to set the current input position, current output position, or both. If whence is ios_base::beg, set the current position to the indicated offset from the beginning of the stream; if whence is ios_base::end, set the current position to the indicated offset from the end of the stream; and if whence is ios_base::cur, set the current input or output position to the indicated offset from its current position. If whence is ios_base::cur, then modeBitMask may be either ios_base::in or ios_base::out, but not both. Return the offset of the new position on success, and pos_type(off_type(-1)) otherwise.

References BSLS_ASSERT_OPT, and bsl::end().

Referenced by bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::seekpos().

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::pos_type bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::seekpos ( pos_type  absoluteOffset,
ios_base::openmode  modeBitMask = ios_base::in | ios_base::out 
) [inline, protected, virtual]

Set the current input position or the current output position (or both) to the specified absoluteOffset from the beginning of the stream. Optionally specify a modeBitMask indicating whether to set the current input position, current output position, or both. Return the offset of the new position on success, and pos_type(off_type(-1)) otherwise.

References bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::seekoff().

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
std::streamsize bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::xsgetn ( char_type result,
std::streamsize  numCharacters 
) [protected, virtual]

Read up to the specified numCharacters from this stringbuf object and store them in the specified result array. Return the number of characters loaded into result. Note that if fewer than numCharacters characters are available in the buffer, all available characters are loaded into result. The behavior is undefined unless result refers to a contiguous sequence of at least numCharacters characters.

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::int_type bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::underflow (  )  [protected, virtual]

Return the character at the current input position, if a character is available, and traits_type::eof() otherwise. Update the end of the input area, egptr, if additional characters are available (as may occur if additional characters have been written to the string buffer). Note that this operation is similar to uflow, but does not advance the current input position.

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::int_type bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::uflow (  )  [protected, virtual]

Return the character at the current input position and advance the input position by 1. If no character is available at the current input position, return traits_type::eof(). Update the end of the input area, egptr, if additional characters are available (as may occur if additional characters have been written to the string buffer). Note that this operation is similar to underflow, but advances the current input position.

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::int_type bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::pbackfail ( int_type  character = traits_type::eof()  )  [protected, virtual]

Put back the specified character into the input sequence so that the next character read from the input sequence will be character. If character is either traits_type::eof() or is the same as the previously read character from the input sequence, then adjust the current input position, gptr, back one position. If character is neither traits_type::eof() nor the character previously read from the input sequence, but this string buffer was opened for writing (ios_base::out), then adjust the input sequence back one position and write character to that position. Return the character that was put back on success and traits_type::eof() if either the input position is currently at the beginning of the sequence or if the previous character in the input sequence is not character and this buffer was not opened for writing.

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
std::streamsize bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::xsputn ( const char_type inputString,
std::streamsize  numCharacters 
) [protected, virtual]

Append the specified numCharacters from the specified inputString to the output sequence starting at the current output position (pptr). Update the current output position of this string buffer to refer to the last appended character. Return the number of characters that were appended. The behavior is undefined unless inputString refers to a contiguous sequence of at least numCharacters characters.

References bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::append(), BSLS_ASSERT, bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::data(), and bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::size().

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::int_type bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::overflow ( int_type  character = traits_type::eof()  )  [protected, virtual]

Append the specified character to the output sequence of this stream buffer at the current output position (pptr), and advance the output position by one. This operation may update the end of output area (epptr) to allow for additional writes (e.g., by the base basic_streambuf type) to the output sequence without calling a method on this type. Return the written character on success, and traits_type::eof() if character is traits_type::eof() or this stream buffer was not opened for writing.

References bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::push_back(), and bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::size().

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
void bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str ( const StringType value  ) 
template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
void bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str ( BloombergLP::bslmf::MovableRef< StringType value  ) 
template<class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
template<class SALLOC >
bsl::enable_if<!bsl::is_same<ALLOCATOR, SALLOC>::value, void>::type bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str ( const basic_string< CHAR_TYPE, CHAR_TRAITS, SALLOC > &  value  )  [inline]
Parameters:
value Reset the internally buffered sequence of characters to the specified value. Update the beginning and end of both the input and output sequences to be the beginning and end of the updated buffer, update the current input position to be the beginning of the updated buffer, and update the current output position to be the end of the updated buffer. If value is passed by MovableRef, then it is left in an unspecified but valid state.

Note: implemented inline due to Sun CC compilation error.

References bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::assign(), bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::data(), and bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::size().

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
void bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::swap ( basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR > &  other  ) 

Efficiently exchange the value of this object with the value of the specified other object. This method provides the no-throw exception-safety guarantee if *this and other allocators compare equal. The behavior is undefined unless either *this and other allocators compare equal or propagate_on_container_swap is true. Note that this function is only available for C++11 (and later) language standards because it requires that swap be provided on the (platform supplied) base class for this type.

References BSLS_ASSERT, bsl::basic_string< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::get_allocator(), and bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::swap().

Referenced by bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::swap().

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::allocator_type bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::get_allocator (  )  const [inline]

Return the allocator used by the underlying string to supply memory.

Referenced by bsl::basic_ostringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::get_allocator().

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::StringType bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str (  )  const [inline]

Return the currently buffered sequence of characters. If this object was created only in input mode, the resultant StringType contains the character sequence in the range [eback(), egptr()). If modeBitMask & ios_base::out specified at construction is nonzero then the resultant StringType contains the character sequence in the range [pbase(), high_mark), where high_mark represents the position one past the highest initialized character in the buffer. Otherwise this object has been created in neither input nor output mode and a zero length StringType is returned.

template<class CHAR_TYPE, class CHAR_TRAITS, class ALLOCATOR>
template<class SALLOC >
bsl::enable_if< bsl::IsStdAllocator<SALLOC>::value, basic_string<CHAR_TYPE, CHAR_TRAITS, SALLOC> >::type bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str ( const SALLOC &  allocator  )  const [inline]

< Return the currently buffered sequence of characters in a basic_string that uses the specified allocator. If this object was created only in input mode, the resultant basic_string contains the character sequence in the range [eback(), egptr()). If modeBitMask & ios_base::out specified at construction is nonzero then the resultant basic_string contains the character sequence in the range [pbase(), high_mark), where high_mark represents the position one past the highest initialized character in the buffer. Otherwise this object has been created in neither input nor output mode and a zero length basic_string is returned.

Note: implemented inline due to Sun CC compilation error.

References bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::view().

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::ViewType bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::view (  )  const [inline]

Return a string_view containing the currently buffered sequence of characters. If this object was created only in input mode, the resultant ViewType contains the character sequence in the range [eback(), egptr()). If modeBitMask & ios_base::out specified at construction is nonzero then the resultant StringType contains the character sequence in the range [pbase(), high_mark), where high_mark represents the position one past the highest initialized character in the buffer. Otherwise this object has been created in neither input nor output mode and a zero length ViewType is returned.

Referenced by bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str(), bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::view(), bsl::basic_ostringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::view(), and bsl::basic_istringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::view().


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