7 #ifndef _STREAM_CLASS_HEADER_
8 #define _STREAM_CLASS_HEADER_
29 typedef enum : uint8_t
46 FLG_KEEP_POSITION = 1,
70 uint32_t ui32Flags=0);;
146 tResult Read(
void* pvBuffer,
size_t nBufferSize,
size_t* pnBytesRead=
nullptr)
const override;
156 tResult Write(
const void* pvBuffer,
size_t nBufferSize,
size_t* pnBytesWritten=
nullptr)
override;
229 size_t& szReadCount);
244 T oValueToWrite = oValue;
250 auto pReadPosition =
reinterpret_cast<const uint8_t*
>(&oValueToWrite);
251 size_t nBytesToWrite =
sizeof(oValueToWrite);
252 while (nBytesToWrite)
254 size_t szWrittenSize = 0;
256 szCount += szWrittenSize;
257 pReadPosition += szWrittenSize;
258 nBytesToWrite -= szWrittenSize;
268 auto pWritePosition =
reinterpret_cast<uint8_t*
>(&oValue);
269 size_t nBytesToRead =
sizeof(oValue);
272 size_t szReadSize = 0;
274 szCount += szReadSize;
275 pWritePosition += szReadSize;
276 nBytesToRead -= szReadSize;
294 return ucom_write_to_stream_string(oOutStream, strValue, szCount);
300 return ucom_read_from_stream_string(oInStream, strValue, szReadCount);
318 IOutputStream& operator<<(IOutputStream& oWriteStream,
const T& oValue)
321 ucom_type_streamer<T>::Write(oWriteStream, oValue, szCount);
326 const IInputStream& operator>>(
const IInputStream& oReadStream, T& oValue)
329 ucom_type_streamer<T>::Read(oReadStream, oValue, szCount);
338 using ant::ucom_type_streamer;
340 using ant::ucom_write_to_stream;
341 using ant::ucom_read_from_stream;
343 using ant::ucom_write_to_stream_buffer;
344 using ant::ucom_read_from_stream_buffer;
346 using ant::ucom_write_to_stream_string;
347 using ant::ucom_read_from_stream_string;
tInt64 tFileSize
type definition for a file or stream size value (platform and compiler independent type).
tInt64 tFilePos
type definition for a file or stream position value (platform and compiler independent type).
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
A common result class usable as return value throughout.
An interface for writing data to a stream.
virtual tResult Write(const void *pvBuffer, size_t nBufferSize, size_t *pnBytesWritten=nullptr)=0
Write data to stream.
The cStream Class provides a basic, simple implementation for IStream interface.
const void * GetCurrentPtr() const
Gets the address of the buffers current seek position.
tResult SetSize(tFileSize szBuffer, uint32_t ui32Flags=0)
Sets the current size of the stream.
tFileSize GetCurrentSize() const
Returns the current buffer size.
tResult AttachReference(void *pReferenceBuffer, tFileSize szBufferSize)
Reference to a extern buffer (no intern buffer will be used to write to or read from).
tResult CopyTo(cStream &strmOutput) const
Copies a Stream to another.
tStreamType
Stream direction type.
tResult Reset() override
Implements.
cStream(tStreamType eType, tFileSize szBuffer=0, uint32_t ui32Flags=0)
Constructs a Stream with the current size.
tResult CopyFrom(cStream &strmInput)
Copies content from another Stream.
virtual ~cStream()
Destructor.
tResult Seek(tFilePos nPos, tSeekOrigin eOrigin, tFilePos *pNewPos=nullptr) const override
Implements IStream::Seek.
tResult Flush() override
Implements.
tResult Write(const void *pvBuffer, size_t nBufferSize, size_t *pnBytesWritten=nullptr) override
Implements.
tResult Read(void *pvBuffer, size_t nBufferSize, size_t *pnBytesRead=nullptr) const override
Implements.
tFileSize GetHighestPosIndex() const
Returns the current buffer size which was written (without a gap at the end).
tStreamType m_eType
Type of Stream, see tStreamType.
bool IsEof() const
Checks if end of stream is reached.
tFileSize GetRemainingBytes() const
tResult DetachReference()
Reference to a buffer will be detached.
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an e...
#define PLATFORM_BIG_ENDIAN_8
defines the big endianess value, that will be retrieved by
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
ADTF adtf_util Namespace - Within adtf this is used as adtf::util or adtf_util and also defined as A_...
Namespace for entire ADTF SDK.
Helper template for writing and reading types.