ADTF
Loading...
Searching...
No Matches
adtf::ucom::ant::cStream Class Reference

#include <stream.h>

Inherits adtf::ucom::catwo::object< IInputStream, IOutputStream, IStream >.

Public Types

enum  tStreamType : uint8_t { INPUT_STREAM = 1 , OUTPUT_STREAM = 2 }
 

Public Member Functions

 cStream (tStreamType eType, tFileSize szBuffer=0, uint32_t ui32Flags=0)
 
virtual ~cStream ()
 
tResult SetSize (tFileSize szBuffer, uint32_t ui32Flags=0)
 
tResult CopyTo (cStream &strmOutput) const
 
tResult CopyFrom (cStream &strmInput)
 
const void * GetCurrentPtr () const
 
tFileSize GetCurrentSize () const
 
tFileSize GetHighestPosIndex () const
 
tResult AttachReference (void *pReferenceBuffer, tFileSize szBufferSize)
 
tResult DetachReference ()
 
tResult Read (void *pvBuffer, size_t nBufferSize, size_t *pnBytesRead=nullptr) const override
 
tResult Write (const void *pvBuffer, size_t nBufferSize, size_t *pnBytesWritten=nullptr) override
 
tResult Seek (tFilePos nPos, tSeekOrigin eOrigin, tFilePos *pNewPos=nullptr) const override
 
tResult Reset () override
 
tResult Flush () override
 
- Public Member Functions inherited from adtf::ucom::catwo::object< IInputStream, IOutputStream, IStream >
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.
 
- Public Member Functions inherited from adtf::ucom::ant::IObject
 ADTF_IID (IObject, "object.ant.ucom.adtf.iid")
 

Protected Types

enum  tStreamFlags { FLG_KEEP_POSITION = 1 , FLG_DONT_GROW = 2 }
 

Protected Member Functions

bool IsEof () const
 
tFileSize GetRemainingBytes () const
 
- Protected Member Functions inherited from adtf::ucom::ant::IObject
 ~IObject ()=default
 Protected destructor --> Only the final implementation can be destroyed!
 

Protected Attributes

tStreamType m_eType
 Type of Stream, see tStreamType.
 

Detailed Description

The cStream Class provides a basic, simple implementation for IStream interface.

Member Enumeration Documentation

◆ tStreamFlags

Stream flags.

Enumerator
FLG_KEEP_POSITION 

Sets correct end of file marker at.

See also
cStream::SetSize() call.
FLG_DONT_GROW 

Will only have the at construction time decided size.

◆ tStreamType

Stream direction type.

Enumerator
INPUT_STREAM 

Is a Input Stream (can be read).

OUTPUT_STREAM 

Is a Output Stream (can be written).

Constructor & Destructor Documentation

◆ cStream()

adtf::ucom::ant::cStream::cStream ( tStreamType eType,
tFileSize szBuffer = 0,
uint32_t ui32Flags = 0 )
explicit

Constructs a Stream with the current size.

Parameters
eType[in] The In or Ouput Type.
szBuffer[in] The stream buffer size which will be preallocated.
ui32Flags[in] The creating flags (
See also
tStreamFlags).

◆ ~cStream()

virtual adtf::ucom::ant::cStream::~cStream ( )
virtual

Destructor.

Member Function Documentation

◆ AttachReference()

tResult adtf::ucom::ant::cStream::AttachReference ( void * pReferenceBuffer,
tFileSize szBufferSize )

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!!

Parameters
pReferenceBufferReference to the extern buffer.
szBufferSizeSize of the Extern buffer.
Returns
Standard Result Code.

◆ CopyFrom()

tResult adtf::ucom::ant::cStream::CopyFrom ( cStream & strmInput)

Copies content from another Stream.

Parameters
strmInputThe Stream to copy from.
Returns
Standard Result Code.

◆ CopyTo()

tResult adtf::ucom::ant::cStream::CopyTo ( cStream & strmOutput) const

Copies a Stream to another.

Parameters
strmOutputThe Stream to copy to.
Returns
Standard Result Code.

◆ DetachReference()

tResult adtf::ucom::ant::cStream::DetachReference ( )

Reference to a buffer will be detached

See also
AttachReference.
Returns
Standard Result Code.

◆ Flush()

tResult adtf::ucom::ant::cStream::Flush ( )
override

Implements

See also
IStream::Flush. This function is not supported in the cStream implementation.
Returns
Standard Result Code.

◆ GetCurrentPtr()

const void * adtf::ucom::ant::cStream::GetCurrentPtr ( ) const

Gets the address of the buffers current seek position.

Returns
The buffer address.
Note
rtsafe

◆ GetCurrentSize()

tFileSize adtf::ucom::ant::cStream::GetCurrentSize ( ) const

Returns the current buffer size.

Returns
The buffer size.
Note
rtsafe

◆ GetHighestPosIndex()

tFileSize adtf::ucom::ant::cStream::GetHighestPosIndex ( ) const

Returns the current buffer size which was written (without a gap at the end).

Returns
The current highest pos reached with the Write() call.
Note
rtsafe

◆ GetRemainingBytes()

tFileSize adtf::ucom::ant::cStream::GetRemainingBytes ( ) const
protected
Returns
Remaing vount of bytes
Note
rtsafe

◆ IsEof()

bool adtf::ucom::ant::cStream::IsEof ( ) const
protected

Checks if end of stream is reached.

Return values
trueEnd of stream reached
falseEnd of stream is not reached
Note
rtsafe

◆ Read()

tResult adtf::ucom::ant::cStream::Read ( void * pvBuffer,
size_t nBufferSize,
size_t * pnBytesRead = nullptr ) const
override

Implements

See also
IStream::Read. Will Read from the intern Buffer or extern reference attached.
Parameters
pvBufferreference address the cStream will copy the read data to.
nBufferSizesize of bytes to read.
pnBytesReadreturn value for size of bytes read.
Returns
Standard Result Code.
Note
rtsafe

◆ Reset()

tResult adtf::ucom::ant::cStream::Reset ( )
override

Implements

See also
IStream::Seek. Sets the current position in the stream to the begin.
Returns
Standard Result Code.
Note
rtsafe

◆ Seek()

tResult adtf::ucom::ant::cStream::Seek ( tFilePos nPos,
tSeekOrigin eOrigin,
tFilePos * pNewPos = nullptr ) const
override

Implements IStream::Seek. Sets the current position in the stream.

Parameters
nPosPosition to set to (in bytes).
eOriginIStream::tSeekOrigin.
pNewPosreturn value for the new position (same as
See also
GetCurrentPtr).
Returns
Standard Result Code.
Note
rtsafe

◆ SetSize()

tResult adtf::ucom::ant::cStream::SetSize ( tFileSize szBuffer,
uint32_t ui32Flags = 0 )

Sets the current size of the stream.

Parameters
szBuffer[in] The stream buffer size which will be allocated.
ui32Flags[in] The set size flags (
See also
tStreamFlags).
Returns
Standard Result Code.

◆ Write()

tResult adtf::ucom::ant::cStream::Write ( const void * pvBuffer,
size_t nBufferSize,
size_t * pnBytesWritten = nullptr )
override

Implements

See also
IStream::Write. Writes to the intern buffer or extern reference attached.
Parameters
pvBufferreference address the cStream will copy the data from.
nBufferSizesize of bytes to write.
pnBytesWrittenreturn value for size of bytes written.
Returns
Standard Result Code.

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