BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlsb::FixedMemInput Class Reference

#include <bdlsb_fixedmeminput.h>

Public Types

typedef char char_type
 
typedef bsl::char_traits< char > traits_type
 
typedef traits_type::int_type int_type
 
typedef traits_type::pos_type pos_type
 
typedef traits_type::off_type off_type
 

Public Member Functions

 FixedMemInput (const char *buffer, bsl::size_t length)
 
 ~FixedMemInput ()=default
 Destroy this stream buffer.
 
bsl::streamsize in_avail ()
 
FixedMemInputpubsetbuf (const char *buffer, bsl::streamsize length)
 
pos_type pubseekoff (off_type offset, bsl::ios_base::seekdir way, bsl::ios_base::openmode which=bsl::ios_base::in)
 
pos_type pubseekpos (pos_type position, bsl::ios_base::openmode which=bsl::ios_base::in)
 
int_type sbumpc ()
 
int_type sgetc ()
 
bsl::streamsize sgetn (char_type *destination, bsl::streamsize length)
 
int_type snextc ()
 
int_type sputbackc (char c)
 
int_type sungetc ()
 
bsl::size_t capacity () const
 
const char * data () const
 
bsl::size_t length () const
 

Detailed Description

This class, like bdlsb::FixedMemInStreamBuf, implements the input functionality of the basic_streambuf interface, using client-supplied char * memory. It has an interface identical to bdlsb::FixedMemInStreamBuf but does not inherit from bsl::streambuf. This implementation is advantageous for performance reasons, as the overhead of the initialization and virtual function calls of a bsl::streambuf can be undesirable. It is especially designed for streaming a very small amount of information from a fixed-length buffer using a bslx_genericinstream when the number of characters read from the input is guaranteed not to exceed the length of the buffer. Note that this class is not designed to be derived from.

See bdlsb_fixedmeminput

Member Typedef Documentation

◆ char_type

◆ int_type

typedef traits_type::int_type bdlsb::FixedMemInput::int_type

◆ off_type

typedef traits_type::off_type bdlsb::FixedMemInput::off_type

◆ pos_type

typedef traits_type::pos_type bdlsb::FixedMemInput::pos_type

◆ traits_type

typedef bsl::char_traits<char> bdlsb::FixedMemInput::traits_type

Constructor & Destructor Documentation

◆ FixedMemInput()

bdlsb::FixedMemInput::FixedMemInput ( const char *  buffer,
bsl::size_t  length 
)
inline

Create a FixedMemInput using the specified buffer of the specified length. The position indicator is set to the beginning of the buffer. The behavior is undefined unless buffer != 0 && length > 0 or length == 0. Note that buffer is held but not owned.

◆ ~FixedMemInput()

bdlsb::FixedMemInput::~FixedMemInput ( )
default

Member Function Documentation

◆ capacity()

bsl::size_t bdlsb::FixedMemInput::capacity ( ) const
inline

Return the size for the buffer held by this buffer, in bytes, supplied at construction.

◆ data()

const char * bdlsb::FixedMemInput::data ( ) const
inline

Return the address of the non-modifiable character buffer held by this stream buffer.

◆ in_avail()

bsl::streamsize bdlsb::FixedMemInput::in_avail ( )
inline

Return the number of characters available from the current read position in this stream buffer.

◆ length()

bsl::size_t bdlsb::FixedMemInput::length ( ) const
inline

Return the number of characters that can be successfully read from this stream buffer before reading traits_type::eof() – i.e., the number of characters between the current read position and the end of this buffer.

◆ pubseekoff()

pos_type bdlsb::FixedMemInput::pubseekoff ( off_type  offset,
bsl::ios_base::seekdir  way,
bsl::ios_base::openmode  which = bsl::ios_base::in 
)

Set the position indicator to the relative specified offset from the base position indicated by the specified way and return the resulting absolute position on success or pos_type(-1) on failure. Optionally specify which area of the stream buffer. The seek operation will fail if which does not include the flag bsl::ios_base::in or if the resulting absolute position is less than zero or greater than the value returned by length.

◆ pubseekpos()

pos_type bdlsb::FixedMemInput::pubseekpos ( pos_type  position,
bsl::ios_base::openmode  which = bsl::ios_base::in 
)

Set the position indicator to the specified position and return the resulting absolute position on success or pos_type(-1) on failure. Optionally specify which area of the stream buffer. The seekpos operation will fail if which does not include the flag bsl::ios_base::in or if position is less then zero or greater than the value returned by length.

◆ pubsetbuf()

FixedMemInput * bdlsb::FixedMemInput::pubsetbuf ( const char *  buffer,
bsl::streamsize  length 
)
inline

Reinitialize this stream buffer to use the specified character buffer having the specified length. Return a pointer providing modifiable access to this stream buffer. The behaviour is undefined unless buffer != 0 && length > 0 or length == 0. Upon reinitialization for use of the new buffer, the position indicator is set to the beginning of the buffer. Note that buffer is held but not owned.

◆ sbumpc()

FixedMemInput::int_type bdlsb::FixedMemInput::sbumpc ( )
inline

Return the character at the current read position from this buffer, or traits_type::eof() if the end of the buffer is reached and advance read position indicator.

◆ sgetc()

FixedMemInput::int_type bdlsb::FixedMemInput::sgetc ( )
inline

Return the character at the current read position from this buffer, or traits_type::eof() if the end of the buffer is reached.

◆ sgetn()

bsl::streamsize bdlsb::FixedMemInput::sgetn ( char_type destination,
bsl::streamsize  length 
)
inline

Read the specified length characters to the specified destination. Return the number of characters successfully read from this buffer, which is either equal to the length parameter or equal to the distance from the current read position to the end of the input buffer, whichever is smaller, and move the read cursor position by this amount. The behavior is undefined unless '0 <= length'.

◆ snextc()

FixedMemInput::int_type bdlsb::FixedMemInput::snextc ( )
inline

Advance the current read position and return the character at the resulting position from this buffer, or traits_type::eof() if the end of the buffer is reached.

◆ sputbackc()

FixedMemInput::int_type bdlsb::FixedMemInput::sputbackc ( char  c)
inline

Move the current read position back one character if the current read position is not at the beginning of the buffer and the previous position contains the specified character c, and return that character. Otherwise, return traits_type::eof() and do not move the current read position.

◆ sungetc()

FixedMemInput::int_type bdlsb::FixedMemInput::sungetc ( )
inline

Move the current read position back one character if the current read position is not at the beginning of the buffer, and return the character at the resulting current read position from this buffer. Return traits_type::eof() otherwise.


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