BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR > Class Template Reference

#include <bslstl_stringbuf.h>

Inheritance diagram for bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >:

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 ()
 Destroy this object.
 
void str (const StringType &value)
 
void str (BloombergLP::bslmf::MovableRef< StringType > value)
 Note: implemented inline due to Sun CC compilation error.
 
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
 Return the allocator used by the underlying string to supply memory.
 
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.

Member Typedef Documentation

◆ allocator_type

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

◆ char_type

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

◆ int_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

◆ off_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

◆ pos_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

◆ traits_type

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

Constructor & Destructor Documentation

◆ basic_stringbuf() [1/10]

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

◆ basic_stringbuf() [2/10]

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

◆ basic_stringbuf() [3/10]

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

◆ basic_stringbuf() [4/10]

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.

◆ basic_stringbuf() [5/10]

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringbuf ( BloombergLP::bslmf::MovableRef< StringType initialString)
inlineexplicit

◆ basic_stringbuf() [6/10]

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

◆ basic_stringbuf() [7/10]

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

◆ basic_stringbuf() [8/10]

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.

◆ basic_stringbuf() [9/10]

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 
)
inlineexplicit

Create a basic_stringbuf object. Use the specified initialString indicating the initial sequence of characters that this buffer will access or manipulate. 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.

◆ basic_stringbuf() [10/10]

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

Create a basic_stringbuf object. Use the specified initialString indicating the initial sequence of characters that this buffer will access or manipulate. Use the specified modeBitMask to indicate whether this buffer may be read from, written to, or both. 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.

Note: implemented inline due to Sun CC compilation error.

◆ ~basic_stringbuf()

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::~basic_stringbuf ( )

Member Function Documentation

◆ get_allocator()

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

◆ overflow()

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

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.

◆ pbackfail()

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

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.

◆ seekoff()

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 
)
protectedvirtual

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.

◆ 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 
)
inlineprotectedvirtual

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.

◆ str() [1/5]

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.

◆ str() [2/5]

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
void bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str ( BloombergLP::bslmf::MovableRef< StringType value)

◆ str() [3/5]

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

◆ str() [4/5]

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.

◆ str() [5/5]

template<class CHAR_TYPE , class CHAR_TRAITS , class ALLOCATOR >
void bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str ( const StringType 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.

◆ swap()

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.

◆ uflow()

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

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.

◆ underflow()

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

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.

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

◆ xsgetn()

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 
)
protectedvirtual

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.

◆ xsputn()

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 
)
protectedvirtual

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.


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