The cStream Class provides a basic, simple implementation for IStream interface. More...
#include <stream.h>
Public Types | |
enum | tStreamType : uint8_t { INPUT_STREAM = 1 , OUTPUT_STREAM = 2 } |
Stream direction type. More... | |
Public Member Functions | |
cStream (tStreamType eType, tFileSize szBuffer=0, uint32_t ui32Flags=0) | |
Constructs a Stream with the current size. | |
virtual | ~cStream () |
Destructor. | |
tResult | SetSize (tFileSize szBuffer, uint32_t ui32Flags=0) |
Sets the current size of the stream. | |
tResult | CopyTo (cStream &strmOutput) const |
Copies a Stream to another. | |
tResult | CopyFrom (cStream &strmInput) |
Copies content from another Stream. | |
const void * | GetCurrentPtr () const |
Gets the address of the buffers current seek position. | |
tFileSize | GetCurrentSize () const |
Returns the current buffer size. | |
tFileSize | GetHighestPosIndex () const |
Returns the current buffer size which was written (without a gap at the end). | |
tResult | AttachReference (void *pReferenceBuffer, tFileSize szBufferSize) |
Reference to a extern buffer (no intern buffer will be used to write to or read from). | |
tResult | DetachReference () |
Reference to a buffer will be detached. | |
tResult | Read (void *pvBuffer, size_t nBufferSize, size_t *pnBytesRead=nullptr) const override |
Implements. | |
tResult | Write (const void *pvBuffer, size_t nBufferSize, size_t *pnBytesWritten=nullptr) override |
Implements. | |
tResult | Seek (tFilePos nPos, tSeekOrigin eOrigin, tFilePos *pNewPos=nullptr) const override |
Implements Seek. | |
tResult | Reset () override |
Implements. | |
tResult | Flush () override |
Implements. | |
![]() | |
tResult | GetInterface (const char *i_strIID, void *&o_pInterface) override |
Query interfaces on an object. | |
tResult | GetInterface (const char *i_strIID, const void *&o_pInterface) const override |
Provides const correct interface querying. | |
void | Destroy () const override |
Switch from non-virtual destructor to virtual destructor. | |
tResult | GetInterface (const char *i_strIID, void *&o_pInterface) override |
Query interfaces on an object. | |
tResult | GetInterface (const char *i_strIID, const void *&o_pInterface) const override |
Provides const correct interface querying. | |
void | Destroy () const override |
Switch from non-virtual destructor to virtual destructor. | |
tResult | GetInterface (const char *i_strIID, void *&o_pInterface) override |
Query interfaces on an object. | |
tResult | GetInterface (const char *i_strIID, const void *&o_pInterface) const override |
Provides const correct interface querying. | |
void | Destroy () const override |
Switch from non-virtual destructor to virtual destructor. | |
![]() | |
ADTF_IID (IObject, "object.ant.ucom.adtf.iid") | |
Marks the IObject to be castable with the ucom_cast() | |
Protected Types | |
enum | tStreamFlags { FLG_KEEP_POSITION = 1 , FLG_DONT_GROW = 2 } |
Stream flags. More... | |
Protected Member Functions | |
bool | IsEof () const |
Checks if end of stream is reached. | |
tFileSize | GetRemainingBytes () const |
![]() | |
~IObject ()=default | |
Protected destructor --> Only the final implementation can be destroyed! | |
Protected Attributes | |
tStreamType | m_eType |
Type of Stream, see tStreamType. | |
Private Member Functions | |
cStream (const cStream &oStream)=delete | |
cStream & | operator= (const cStream &oStream)=delete |
cStream & | operator= (cStream &&oStream)=delete |
cStream (cStream &&oStream)=delete | |
|
protected |
Stream flags.
Enumerator | |
---|---|
FLG_KEEP_POSITION | Sets correct end of file marker at.
|
FLG_DONT_GROW | Will only have the at construction time decided size. |
enum tStreamType : uint8_t |
|
explicit |
Constructs a Stream with the current size.
eType | [in] The In or Ouput Type. |
szBuffer | [in] The stream buffer size which will be preallocated. |
ui32Flags | [in] The creating flags ( |
Reference to a extern buffer (no intern buffer will be used to write to or read from).
Mind: A SetSize will be failed, while a Buffer is attached!!
pReferenceBuffer | Reference to the extern buffer. |
szBufferSize | Size of the Extern buffer. |
Copies content from another Stream.
strmInput | The Stream to copy from. |
Copies a Stream to another.
strmOutput | The Stream to copy to. |
tResult DetachReference | ( | ) |
|
override |
Implements.
const void * GetCurrentPtr | ( | ) | const |
Gets the address of the buffers current seek position.
tFileSize GetCurrentSize | ( | ) | const |
Returns the current buffer size.
tFileSize GetHighestPosIndex | ( | ) | const |
Returns the current buffer size which was written (without a gap at the end).
|
protected |
|
protected |
Checks if end of stream is reached.
true | End of stream reached |
false | End of stream is not reached |
|
override |
Implements.
pvBuffer | reference address the cStream will copy the read data to. |
nBufferSize | size of bytes to read. |
pnBytesRead | return value for size of bytes read. |
|
override |
Implements.
Implements Seek.
Sets the current position in the stream.
nPos | Position to set to (in bytes). |
eOrigin | tSeekOrigin. |
pNewPos | return value for the new position (same as |
Sets the current size of the stream.
szBuffer | [in] The stream buffer size which will be allocated. |
ui32Flags | [in] The set size flags ( |
|
override |
Implements.
pvBuffer | reference address the cStream will copy the data from. |
nBufferSize | size of bytes to write. |
pnBytesWritten | return value for size of bytes written. |
|
protected |
Type of Stream, see tStreamType.