Mother interface for all stream-like data accessors.
More...
#include <iolink/storage/StreamAccess.h>
|
virtual StreamAccessCapabilitySet | capabilities () const =0 |
|
bool | support (StreamAccessCapabilitySet flags) |
| Checks if the StreamAccess supports the given capabilities.
|
|
virtual bool | good () const |
| Checks if the stream is currently valid for reading (only) Default implementation returns true if nor 'end of file' or 'fail' status are raised. More...
|
|
virtual bool | eof () const =0 |
| Checks if the cursor is at the end of the stream for reading For writing, this status is not relevant. More...
|
|
virtual bool | fail () const =0 |
|
std::string | toString () const |
| Return a string representation.
|
|
virtual size_t | read (size_t size, void *dst) |
| Read data from cursor current position into destination buffer. More...
|
|
virtual uint8_t | peek () |
| Return the current byte without moving the cursor. More...
|
|
virtual size_t | write (size_t size, const void *src) |
| Write content of src buffer into StreamAccess. More...
|
|
virtual void | flush () |
| Assure that all data is written to the endpoint. More...
|
|
virtual size_t | tell () |
| Returns the current position of the cursor. More...
|
|
virtual void | seek (int64_t offset, SeekOrigin origin) |
| Move the cursor to the desired position. More...
|
|
virtual void * | buffer () |
| Return a mutable pointer to the internal CPU memory buffer. More...
|
|
virtual const void * | bufferReadOnly () const |
| Return an immutable pointer to the internal CPU memory buffer. More...
|
|
virtual size_t | bufferSize () |
| Size in bytes of the internal CPU buffer. More...
|
|
virtual std::shared_ptr< DataStorage > | storage () const =0 |
| Get the storage to which this data accessor belong.
|
|
virtual const std::string & | resourceId () const =0 |
| Return the resource identifier of this data accessor.
|
|
Mother interface for all stream-like data accessors.
This interface capabilities are indicated by the StreamAccessCapabilitySet returned by the method StreamAccess::capabilities. Each capability enables the use of a specific set of methods. When one of those methods is called, if its corresponding capability is not supported, a NotImplemented exception will be thrown.
- See also
- StreamAccessCapability for capabilities managed by this object
◆ buffer()
virtual void* iolink::StreamAccess::buffer |
( |
| ) |
|
|
virtual |
Return a mutable pointer to the internal CPU memory buffer.
Available when the RandomAccess has the MEMORY_ACCESS capability.
- Exceptions
-
◆ bufferReadOnly()
virtual const void* iolink::StreamAccess::bufferReadOnly |
( |
| ) |
const |
|
virtual |
Return an immutable pointer to the internal CPU memory buffer.
Available when the RandomAccess has the MEMORY_ACCESS capability.
- Exceptions
-
◆ bufferSize()
virtual size_t iolink::StreamAccess::bufferSize |
( |
| ) |
|
|
virtual |
Size in bytes of the internal CPU buffer.
Available when the RandomAccess has the MEMORY_ACCESS capability.
- Exceptions
-
◆ capabilities()
- Returns
- capabilities for current stream
◆ eof()
virtual bool iolink::StreamAccess::eof |
( |
| ) |
const |
|
pure virtual |
Checks if the cursor is at the end of the stream for reading For writing, this status is not relevant.
- Returns
- true if the end of stream is reached. No more byte can be read.
◆ flush()
virtual void iolink::StreamAccess::flush |
( |
| ) |
|
|
virtual |
Assure that all data is written to the endpoint.
Available when the StreamAccess has the WRITE capability.
◆ good()
virtual bool iolink::StreamAccess::good |
( |
| ) |
const |
|
virtual |
Checks if the stream is currently valid for reading (only) Default implementation returns true if nor 'end of file' or 'fail' status are raised.
- Returns
- true if the stream can be read
◆ peek()
virtual uint8_t iolink::StreamAccess::peek |
( |
| ) |
|
|
virtual |
Return the current byte without moving the cursor.
Available when the StreamAccess has the READ capability.
- Exceptions
-
Error | if cursor is at EOF. |
◆ read()
virtual size_t iolink::StreamAccess::read |
( |
size_t |
size, |
|
|
void * |
dst |
|
) |
| |
|
virtual |
Read data from cursor current position into destination buffer.
Cursor position is incremented by the actually read bytes count.
Available when the StreamAccess has the READ capability.
- Parameters
-
size | Size in byte of the area to read |
dst | Destination buffer. This buffer should have a size of "size" |
- Returns
- Count of actually read bytes.
◆ seek()
virtual void iolink::StreamAccess::seek |
( |
int64_t |
offset, |
|
|
SeekOrigin |
origin |
|
) |
| |
|
virtual |
Move the cursor to the desired position.
Available when the StreamAccess has the SEEK capability.
Cursor position must be set as following: new position = current position + offset If new computed position is less than 0, previous current position is kept.
- Parameters
-
offset | Offset used to move the cursor according to the origin. |
origin | The origin from which to move the cursor. Can be the start of the stream, the current position of the cursor, or the end of the stream. Positive offsets always make the cursor move forward in the stream, whatever the origin. Negative offsets always make the cursor move backward. |
- Exceptions
-
Error | if trying to set cursor before BEGIN position (negative value) |
◆ tell()
virtual size_t iolink::StreamAccess::tell |
( |
| ) |
|
|
virtual |
Returns the current position of the cursor.
Available when the StreamAccess has the SEEK capability.
◆ write()
virtual size_t iolink::StreamAccess::write |
( |
size_t |
size, |
|
|
const void * |
src |
|
) |
| |
|
virtual |
Write content of src buffer into StreamAccess.
Stream cursor is incremented by actually written bytes count.
Available when the StreamAccess has the WRITE capability.
- Parameters
-
size | Size in byte of given buffer to write |
src | Source buffer. This buffer should have a size of "size" |
- Returns
- Count of actually written bytes. It may not be considered as an error that return value if different than size (ie. an exception may not be thrown). It is up to user to decide what to do in this case.
The documentation for this class was generated from the following file: