BDE 4.14.0 Production release
|
Provide a basic output stream buffer using a client buffer.
This component implements the output portion of the bsl::basic_streambuf
protocol using a client-supplied memory buffer. Method names correspond to the protocol-specified method names. Clients supply the character buffer at stream buffer construction, and can later reinitialize the stream buffer with a different character buffer by calling the pubsetbuf
method. The only difference between this component and bdlsb_fixedmemoutstreambuf is that the class bdlsb::FixedMemOutput
does not derive from a bsl::streambuf
and does not support locales. This is advantageous for performance reasons, as the overhead of the initialization and virtual function calls of a bsl::streambuf
can be undesirable. The bdlsb::FixedMemOutput
is designed to be used by generic template code that must be instantiated on a type that matches the interface of bsl::streambuf
, but does not require an actual bsl::streambuf
, in particular bslx_genericoutstream .
This section illustrates intended use of this component.
This example demonstrates instantiating a template, bslx::GenericOutStream', on a bdlsb::FixedMemOutput
object and using the bslx::GenericOutStream
object to stream out some data.
First, we create an object of our stream buffer:
Then, we create an instance of bslx::GenericOutStream
using streamBuf
, with an arbitrary value for its versionSelector
, and externalize some values:
Finally, we compare the contents of the buffer to the expected value: