A concrete implementation of InputStream that performs input operations from an in-memory buffer.
More...
#include <bond/io/memoryinputstream.h>
|
| | MemoryInputStream (const void *buffer, pos_t size) |
| | Constructs a MemoryInputStream object.
|
| virtual | ~MemoryInputStream () |
| virtual void | VScan (const char *format, va_list argList) override |
| | Reads formatted input from the stream using a variable argument list.
|
| virtual size_t | Read (uint8_t *bytes, size_t numBytes) override |
| | Reads a sequence of bytes from the stream.
|
| virtual int | Read () override |
| | Reads a single byte from the stream.
|
| virtual pos_t | GetPosition () const override |
| | Returns the current position within the stream.
|
| virtual pos_t | GetEndPosition () const override |
| | Returns the end position of the stream.
|
| virtual void | SetPosition (off_t offset) override |
| | Sets the current position within the stream.
|
| virtual void | SetPositionFromEnd (off_t offset) override |
| | Sets the current position relative to the end of the stream.
|
| virtual void | AddOffset (off_t offset) override |
| | Advances the current position by the given offset.
|
| virtual bool | IsEof () const override |
| | Tests whether the current position is at or beyond the end of the stream.
|
| virtual bool | HasError () const override |
| | Tests whether the stream is currently in an error state.
|
| virtual void | ClearError () override |
| | Clears the current error state of the stream.
|
| virtual | ~InputStream () |
| | Destroys an InputStream object.
|
| virtual void | Scan (const char *format,...) |
| | Reads formatted input from the stream.
|
| size_t | Read (char *bytes, size_t numBytes) |
| | Reads a sequence of bytes from the stream into a character buffer.
|
| virtual | ~Stream () |
| | Destroys a Stream object.
|
| virtual void | Close () |
| | Closes the stream.
|
|
| typedef long | pos_t |
| | A type used to represent absolute positions within a stream.
|
| typedef long | off_t |
| | A type used to represent relative offsets within a stream.
|
| static const int | Eof = -1 |
| | A special value returned by single-byte input functions to indicate end of stream.
|
A concrete implementation of InputStream that performs input operations from an in-memory buffer.
MemoryInputStream provides a non-owning view over a contiguous block of memory and reads data from that buffer without copying it.
- See also
- InputStream, MemoryOutputStream
◆ MemoryInputStream()
| Bond::MemoryInputStream::MemoryInputStream |
( |
const void * | buffer, |
|
|
pos_t | size ) |
Constructs a MemoryInputStream object.
- Parameters
-
| buffer | A pointer to the memory buffer from which bytes will be read. The buffer is not copied and must remain valid for the lifetime of the MemoryInputStream. |
| size | The size of the memory buffer, in bytes. |
◆ ~MemoryInputStream()
| virtual Bond::MemoryInputStream::~MemoryInputStream |
( |
| ) |
|
|
inlinevirtual |
◆ AddOffset()
| virtual void Bond::MemoryInputStream::AddOffset |
( |
off_t | offset | ) |
|
|
overridevirtual |
Advances the current position by the given offset.
- Parameters
-
| offset | The signed amount by which the current position should be adjusted. |
Implements Bond::Stream.
◆ ClearError()
| virtual void Bond::MemoryInputStream::ClearError |
( |
| ) |
|
|
inlineoverridevirtual |
Clears the current error state of the stream.
Implements Bond::Stream.
◆ GetEndPosition()
| virtual pos_t Bond::MemoryInputStream::GetEndPosition |
( |
| ) |
const |
|
inlineoverridevirtual |
Returns the end position of the stream.
- Returns
- The absolute position one past the last byte in the stream.
Implements Bond::Stream.
◆ GetPosition()
| virtual pos_t Bond::MemoryInputStream::GetPosition |
( |
| ) |
const |
|
inlineoverridevirtual |
Returns the current position within the stream.
- Returns
- The current absolute stream position.
Implements Bond::Stream.
◆ HasError()
| virtual bool Bond::MemoryInputStream::HasError |
( |
| ) |
const |
|
inlineoverridevirtual |
Tests whether the stream is currently in an error state.
- Returns
- True if an error has occurred on the underlying stream.
Implements Bond::Stream.
◆ IsEof()
| virtual bool Bond::MemoryInputStream::IsEof |
( |
| ) |
const |
|
inlineoverridevirtual |
Tests whether the current position is at or beyond the end of the stream.
- Returns
- True if no more data can be read or written at the current position.
Implements Bond::Stream.
◆ Read() [1/2]
| virtual int Bond::MemoryInputStream::Read |
( |
| ) |
|
|
overridevirtual |
Reads a single byte from the stream.
- Returns
- The next byte in the stream, or Stream::Eof if the end of the stream is reached.
Implements Bond::InputStream.
◆ Read() [2/2]
| virtual size_t Bond::MemoryInputStream::Read |
( |
uint8_t * | bytes, |
|
|
size_t | numBytes ) |
|
overridevirtual |
Reads a sequence of bytes from the stream.
- Parameters
-
| bytes | The destination buffer where the bytes will be written. |
| numBytes | The maximum number of bytes to read. |
- Returns
- The number of bytes actually read from the stream.
Reimplemented from Bond::InputStream.
◆ SetPosition()
| virtual void Bond::MemoryInputStream::SetPosition |
( |
off_t | offset | ) |
|
|
overridevirtual |
Sets the current position within the stream.
- Parameters
-
| offset | The absolute position to which the stream should be moved. |
Implements Bond::Stream.
◆ SetPositionFromEnd()
| virtual void Bond::MemoryInputStream::SetPositionFromEnd |
( |
off_t | offset | ) |
|
|
overridevirtual |
Sets the current position relative to the end of the stream.
- Parameters
-
| offset | The offset from the end position to which the stream should be moved. |
Implements Bond::Stream.
◆ VScan()
| virtual void Bond::MemoryInputStream::VScan |
( |
const char * | format, |
|
|
va_list | argList ) |
|
overridevirtual |
Reads formatted input from the stream using a variable argument list.
- Parameters
-
| format | A scanf-style format string describing the values to be read. |
| argList | A variable argument list containing pointers to storage for the parsed values. |
Implements Bond::InputStream.
The documentation for this class was generated from the following file:
- include/bond/io/memoryinputstream.h