Quick Links: |
Provide a C++03-compatible stringstream
class.
More...
Classes | |
class | bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR > |
Typedefs | |
typedef CHAR_TYPE | bsl::basic_stringstream::char_type |
typedef CHAR_TRAITS | bsl::basic_stringstream::traits_type |
typedef ALLOCATOR | bsl::basic_stringstream::allocator_type |
typedef traits_type::int_type | bsl::basic_stringstream::int_type |
typedef traits_type::off_type | bsl::basic_stringstream::off_type |
typedef traits_type::pos_type | bsl::basic_stringstream::pos_type |
Functions | |
bsl::basic_stringstream::basic_stringstream (const allocator_type &allocator=allocator_type()) | |
bsl::basic_stringstream::basic_stringstream (ios_base::openmode modeBitMask, const allocator_type &allocator=allocator_type()) | |
bsl::basic_stringstream::basic_stringstream (const StringType &initialString, const allocator_type &allocator=allocator_type()) | |
bsl::basic_stringstream::basic_stringstream (const StringType &initialString, ios_base::openmode modeBitMask, const allocator_type &allocator=allocator_type()) | |
bsl::basic_stringstream::basic_stringstream (BloombergLP::bslmf::MovableRef< StringType > initialString) | |
bsl::basic_stringstream::basic_stringstream (BloombergLP::bslmf::MovableRef< StringType > initialString, const allocator_type &allocator) | |
bsl::basic_stringstream::basic_stringstream (BloombergLP::bslmf::MovableRef< StringType > initialString, ios_base::openmode modeBitMask) | |
bsl::basic_stringstream::basic_stringstream (BloombergLP::bslmf::MovableRef< StringType > initialString, ios_base::openmode modeBitMask, const allocator_type &allocator) | |
template<class SALLOC > | |
bsl::basic_stringstream::basic_stringstream (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 > | |
bsl::basic_stringstream::basic_stringstream (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) | |
bsl::basic_stringstream::~basic_stringstream () | |
void | bsl::basic_stringstream::str (const StringType &value) |
void | bsl::basic_stringstream::str (BloombergLP::bslmf::MovableRef< StringType > value) |
template<class SALLOC > | |
bsl::enable_if<!bsl::is_same < ALLOCATOR, SALLOC >::value, void >::type | bsl::basic_stringstream::str (const basic_string< CHAR_TYPE, CHAR_TRAITS, SALLOC > &value) |
StreamBufType * | bsl::basic_stringstream::rdbuf () const |
StringType | bsl::basic_stringstream::str () const |
template<class SALLOC > | |
bsl::enable_if < bsl::IsStdAllocator< SALLOC > ::value, basic_string < CHAR_TYPE, CHAR_TRAITS, SALLOC > >::type | bsl::basic_stringstream::str (const SALLOC &allocator) const |
ViewType | bsl::basic_stringstream::view () const BSLS_KEYWORD_NOEXCEPT |
stringstream
class. bsl::stringstream | C++03-compatible stringstream class |
<bsl_sstream.h>
instead. bsl::basic_stringstream
, implementing a standard stream that provides a constructor and manipulator (str
) that allow clients to directly set the internal sequence of characters that is accessed (or modified) by the stream, as well as an accessor (str
) for obtaining a string having the same sequence of characters to which the stream currently refers (see 27.8.5 [stringstream] of the C++11 standard). This component also defines two standard aliases, bsl::stringstream
and bsl::wstringstream
, that refer to specializations of the bsl::basic_stringstream
template for char
and wchar_t
types, respectively. The bsl::basic_stringstream
template has three parameters, CHAR_TYPE
, CHAR_TRAITS
, and ALLOCATOR
. The CHAR_TYPE
and CHAR_TRAITS
parameters respectively define the character type for the string-stream and a type providing a set of operations the string-stream will use to manipulate characters of that type, which must meet the character traits requirements defined by the C++11 standard, 21.2 [char.traits]. The ALLOCATOR
template parameter is described in the "Memory Allocation" section below. ALLOCATOR
template parameter determines how that string-stream will allocate memory. The basic_stringstream
template supports allocators meeting the requirements of the C++11 standard, 17.6.3.5 [allocator.requirements]; in addition, it supports scoped-allocators derived from the bslma::Allocator
memory allocation protocol. Clients intending to use bslma
-style allocators should use bsl::allocator
, which provides a C++11 standard-compatible adapter for a bslma::Allocator
object. Note that the standard aliases bsl::stringstream
and bsl::wstringstream
both use bsl::allocator
. ALLOCATOR
template parameter of an stringstream
instantiation is bsl::allocator
, then objects of that string-stream type will conform to the standard behavior of a bslma
-allocator-enabled type. Such a string-stream accepts an optional bslma::Allocator
argument at construction. If the address of a bslma::Allocator
object is explicitly supplied at construction, it will be used to supply memory for the string-stream throughout its lifetime; otherwise, the string-stream will use the default allocator installed at the time of the string-stream's construction (see bslma_default
). bsl::stringstream
to read and write data of various types to a bsl::string
object. TYPE1
and TYPE2
. We use bsl::stringstream
to implement the lexicalCast
function. We write the data of type TYPE1
into the stream with operator<<
and then read it back as the data of TYPE2
with operator>>
: template <class TYPE2, class TYPE1> TYPE2 lexicalCast(const TYPE1& what) { bsl::stringstream converter; converter << what; TYPE2 val; converter >> val; return val; }
lexicalCast
function works on some simple test cases: assert(lexicalCast<int>("1234") == 1234); assert(lexicalCast<short>("-5") == -5); assert(lexicalCast<bsl::string>("abc") == "abc"); assert(lexicalCast<bsl::string>(1234) == "1234"); assert(lexicalCast<short>(-5) == -5);
typedef CHAR_TYPE bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::char_type [inherited] |
typedef CHAR_TRAITS bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::traits_type [inherited] |
typedef ALLOCATOR bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::allocator_type [inherited] |
typedef traits_type::int_type bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::int_type [inherited] |
typedef traits_type::off_type bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::off_type [inherited] |
typedef traits_type::pos_type bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::pos_type [inherited] |
bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringstream | ( | const allocator_type & | allocator = allocator_type() |
) | [inline, explicit, inherited] |
bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringstream | ( | ios_base::openmode | modeBitMask, | |
const allocator_type & | allocator = allocator_type() | |||
) | [inline, explicit, inherited] |
bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringstream | ( | const StringType & | initialString, | |
const allocator_type & | allocator = allocator_type() | |||
) | [inline, explicit, inherited] |
bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringstream | ( | const StringType & | initialString, | |
ios_base::openmode | modeBitMask, | |||
const allocator_type & | allocator = allocator_type() | |||
) | [inline, inherited] |
Create a basic_stringstream
object. Optionally specify a modeBitMask
indicating whether the underlying stream-buffer may be read from, written to, or both (rdbuf
is created using modeBitMask
). If modeBitMask
is not supplied, rdbuf
will be created using ios_base::in | ios_base::out
. Optionally specify an initialString
indicating the initial sequence of characters that this stream may 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. If initialString
is passed by MovableRef
, it is left in a valid but unspecified state.
bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringstream | ( | BloombergLP::bslmf::MovableRef< StringType > | initialString | ) | [inline, explicit, inherited] |
bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringstream | ( | BloombergLP::bslmf::MovableRef< StringType > | initialString, | |
const allocator_type & | allocator | |||
) | [inline, inherited] |
bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringstream | ( | BloombergLP::bslmf::MovableRef< StringType > | initialString, | |
ios_base::openmode | modeBitMask | |||
) | [inline, inherited] |
bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringstream | ( | BloombergLP::bslmf::MovableRef< StringType > | initialString, | |
ios_base::openmode | modeBitMask, | |||
const allocator_type & | allocator | |||
) | [inline, inherited] |
Create a basic_stringstream
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.
bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringstream | ( | 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, inherited] |
bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::basic_stringstream | ( | 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, inherited] |
bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::~basic_stringstream | ( | ) | [inherited] |
Destroy this object.
void bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str | ( | const StringType & | value | ) | [inline, inherited] |
void bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str | ( | BloombergLP::bslmf::MovableRef< StringType > | value | ) | [inline, inherited] |
bsl::enable_if<!bsl::is_same<ALLOCATOR, SALLOC>::value, void>::type bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str | ( | const basic_string< CHAR_TYPE, CHAR_TRAITS, SALLOC > & | value | ) | [inline, inherited] |
value | Reset the internally buffered sequence of characters maintained by this stream to the specified value . If value is passed by MovableRef , it is left in a valid but unspecified state. |
Note: implemented inline due to Sun CC compilation error.
References bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::rdbuf(), and bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str().
basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::StreamBufType * bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::rdbuf | ( | ) | const [inline, inherited] |
Return an address providing modifiable access to the basic_stringbuf
object that is internally used by this stream object to buffer unformatted characters.
Reimplemented from bsl::StringBufContainer< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >.
References bsl::StringBufContainer< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::rdbuf().
Referenced by bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str(), and bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::view().
basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::StringType bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str | ( | ) | const [inline, inherited] |
Return the internally buffered sequence of characters maintained by this stream object.
References bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::rdbuf(), and bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str().
bsl::enable_if< bsl::IsStdAllocator<SALLOC>::value, basic_string<CHAR_TYPE, CHAR_TRAITS, SALLOC> >::type bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str | ( | const SALLOC & | allocator | ) | const [inline, inherited] |
< Return a copy of the internally buffered sequence of characters maintained by this stream object in a basic_string
that uses the specified allocator
.
Note: implemented inline due to Sun CC compilation error.
References bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::rdbuf(), and bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::str().
basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::ViewType bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::view | ( | ) | const [inline, inherited] |
Return a view of the internally buffered sequence of characters maintained by this stream object.
References bsl::basic_stringstream< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::rdbuf(), and bsl::basic_stringbuf< CHAR_TYPE, CHAR_TRAITS, ALLOCATOR >::view().