[#bsl-basic_stringbuf] = xref:bsl.adoc[bsl]::basic_stringbuf :relfileprefix: ../ :mrdocs: 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. == Synopsis Declared in `<bslstl_stringbuf.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class CHAR_TYPE, class CHAR_TRAITS = char_traits<CHAR_TYPE>, class ALLOCATOR = xref:bsl/allocator-0df.adoc[allocator<CHAR_TYPE>]> class basic_stringbuf : public std::basic_streambuf<CHAR_TYPE, CHAR_TRAITS> ---- == Base Classes [cols="1,4"] |=== | Name| Description | `std::basic_streambuf<CHAR_TYPE, CHAR_TRAITS>` | The actual work of input and output (interface). |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:bsl/basic_stringbuf/__streambuf_type.adoc[`__streambuf_type`] | @{ This is a non‐standard type. | xref:bsl/basic_stringbuf/allocator_type.adoc[`allocator_type`] | This `typedef` is an alias to the (template parameter) `ALLOCATOR`. | xref:bsl/basic_stringbuf/char_type.adoc[`char_type`] | This `typedef` is an alias to the (template parameter) `CHAR_TYPE`. | xref:bsl/basic_stringbuf/int_type.adoc[`int_type`] | This `typedef` is an alias to `traits_type::int_type`. | xref:bsl/basic_stringbuf/off_type.adoc[`off_type`] | This `typedef` is an alias to `traits_type::off_type`. | xref:bsl/basic_stringbuf/pos_type.adoc[`pos_type`] | This `typedef` is an alias to `traits_type::pos_type`. | xref:bsl/basic_stringbuf/traits_type.adoc[`traits_type`] | This `typedef` is an alias to the (template parameter) `CHAR_TRAITS`. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/basic_stringbuf/2constructor-0d2.adoc[`basic_stringbuf`] [.small]#[constructor]# | Constructors | xref:bsl/basic_stringbuf/2destructor.adoc[`~basic_stringbuf`] [.small]#[destructor]# | Destroy this object. | xref:bsl/basic_stringbuf/operator_assign-02.adoc[`operator=`] | Assign to this object the value of the specified `rhs`, and return a reference providing modifiable access to this object. The contents of `rhs` are move‐assigned to this object. `rhs` is left in a valid but unspecified state. | xref:bsl/basic_stringbuf/get_allocator.adoc[`get_allocator`] | Return the allocator used by the underlying string to supply memory. | xref:bsl/basic_stringbuf/getloc.adoc[`getloc`] | Locale access. | xref:bsl/basic_stringbuf/in_avail.adoc[`in_avail`] | Looking ahead into the stream. | xref:bsl/basic_stringbuf/pubimbue.adoc[`pubimbue`] | Entry point for imbue(). | xref:bsl/basic_stringbuf/pubseekoff.adoc[`pubseekoff`] | Alters the stream position. | xref:bsl/basic_stringbuf/pubseekpos.adoc[`pubseekpos`] | Alters the stream position. | xref:bsl/basic_stringbuf/pubsetbuf.adoc[`pubsetbuf`] | Entry points for derived buffer functions. | xref:bsl/basic_stringbuf/pubsync.adoc[`pubsync`] | Calls virtual sync function. | xref:bsl/basic_stringbuf/sbumpc.adoc[`sbumpc`] | Getting the next character. | xref:bsl/basic_stringbuf/sgetc.adoc[`sgetc`] | Getting the next character. | xref:bsl/basic_stringbuf/sgetn.adoc[`sgetn`] | Entry point for xsgetn. | xref:bsl/basic_stringbuf/snextc.adoc[`snextc`] | Getting the next character. | xref:bsl/basic_stringbuf/sputbackc.adoc[`sputbackc`] | Pushing characters back into the input stream. | xref:bsl/basic_stringbuf/sputc.adoc[`sputc`] | Entry point for all single‐character output functions. | xref:bsl/basic_stringbuf/sputn.adoc[`sputn`] | Entry point for all single‐character output functions. | xref:bsl/basic_stringbuf/str-0d9.adoc[`str`] | `str` overloads | xref:bsl/basic_stringbuf/sungetc.adoc[`sungetc`] | Moving backwards in the input stream. | xref:bsl/basic_stringbuf/swap-08.adoc[`swap`] | 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. | xref:bsl/basic_stringbuf/view.adoc[`view`] | 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. |=== == Protected Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/basic_stringbuf/operator_assign-0b.adoc[`operator=`] | | xref:bsl/basic_stringbuf/__safe_gbump.adoc[`__safe_gbump`] | | xref:bsl/basic_stringbuf/__safe_pbump.adoc[`__safe_pbump`] | | xref:bsl/basic_stringbuf/eback.adoc[`eback`] | Access to the get area. | xref:bsl/basic_stringbuf/egptr.adoc[`egptr`] | | xref:bsl/basic_stringbuf/epptr.adoc[`epptr`] | | xref:bsl/basic_stringbuf/gbump.adoc[`gbump`] | Moving the read position. | xref:bsl/basic_stringbuf/gptr.adoc[`gptr`] | | xref:bsl/basic_stringbuf/imbue.adoc[`imbue`] [.small]#[virtual]# | Changes translations. | xref:bsl/basic_stringbuf/overflow-090.adoc[`overflow`] | `overflow` overloads | xref:bsl/basic_stringbuf/pbackfail-07.adoc[`pbackfail`] | `pbackfail` overloads | xref:bsl/basic_stringbuf/pbase.adoc[`pbase`] | Access to the put area. | xref:bsl/basic_stringbuf/pbump.adoc[`pbump`] | Moving the write position. | xref:bsl/basic_stringbuf/pptr.adoc[`pptr`] | | xref:bsl/basic_stringbuf/seekoff-00.adoc[`seekoff`] | `seekoff` overloads | xref:bsl/basic_stringbuf/seekpos-05.adoc[`seekpos`] | `seekpos` overloads | xref:bsl/basic_stringbuf/setbuf.adoc[`setbuf`] [.small]#[virtual]# | Manipulates the buffer. | xref:bsl/basic_stringbuf/setg.adoc[`setg`] | Setting the three read area pointers. | xref:bsl/basic_stringbuf/setp.adoc[`setp`] | Setting the three write area pointers. | xref:bsl/basic_stringbuf/showmanyc.adoc[`showmanyc`] [.small]#[virtual]# | Investigating the data available. | xref:bsl/basic_stringbuf/swap-00.adoc[`swap`] | | xref:bsl/basic_stringbuf/sync.adoc[`sync`] [.small]#[virtual]# | Synchronizes the buffer arrays with the controlled sequences. | xref:bsl/basic_stringbuf/uflow.adoc[`uflow`] [.small]#[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. | xref:bsl/basic_stringbuf/underflow.adoc[`underflow`] [.small]#[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. | xref:bsl/basic_stringbuf/xsgetn-09.adoc[`xsgetn`] | `xsgetn` overloads | xref:bsl/basic_stringbuf/xsputn-06.adoc[`xsputn`] | `xsputn` overloads |=== == Protected Data Members [cols="1,4"] |=== | Name| Description | xref:bsl/basic_stringbuf/_M_buf_locale.adoc[`_M_buf_locale`] | Current locale setting. | xref:bsl/basic_stringbuf/_M_in_beg.adoc[`_M_in_beg`] | Start of get area. | xref:bsl/basic_stringbuf/_M_in_cur.adoc[`_M_in_cur`] | Current read area. | xref:bsl/basic_stringbuf/_M_in_end.adoc[`_M_in_end`] | End of get area. | xref:bsl/basic_stringbuf/_M_out_beg.adoc[`_M_out_beg`] | Start of put area. | xref:bsl/basic_stringbuf/_M_out_cur.adoc[`_M_out_cur`] | Current put area. | xref:bsl/basic_stringbuf/_M_out_end.adoc[`_M_out_end`] | End of put area. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/swap-06f.adoc[`swap`] | Efficiently exchange the values of the specified `a` and `b` objects. This method provides the no‐throw exception‐safety guarantee if `a` and `b` allocators compare equal. Note that this function is only available for C++11 (and later) language standards. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#