resonance 1.0.1
Loading...
Searching...
No Matches
hxstream.h
Go to the documentation of this file.
1#pragma once
2
3class HxStr;
4
17
35class HxStream {
36public:
46 virtual ~HxStream();
47
59 virtual void SetMarker(int nOffset, int nWhence);
60
70 virtual int GetMarker();
71
81 virtual int Size();
82
94 virtual HxStream &Write(const void *pSrc, int nSize);
95
107 virtual HxStream &ReadData(void *pDest, int nSize);
108
120
134 HxStream &ReadNum(void *pDest, int nSize);
135
149 HxStream &WriteNum(const void *pSrc, int nSize);
150
164 HxStream &ReadStr(char *pszDest, int nDestSize);
165
179
191
202 static const int goodbit;
203
210 static const int kStatusEnd;
211
218 static const int failbit;
219
226 static const int badbit;
227
237
238protected:
246
247 // Status word. HxMemStream stores 1 once the read position arrives at the end of the data and
248 // 0 when a seek clamps to the start.
250 // When non-zero, HxMemStream::ReadData() reports a fatal error rather than a short read. Only
251 // HxIDataChunk's constructors set it.
253};
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
virtual int GetMarker()
Report the read position.
HxStream & WriteNum(const void *pSrc, int nSize)
Move nSize bytes out of pSrc, reversing their order when the stream swaps bytes.
virtual HxStream * UnderlyingStream()
Report the stream this one reads through, if any.
int mSwapBytes
Non-zero when multi-byte values on the stream are in the opposite byte order.
Definition hxstream.h:236
virtual HxStream & Write(const void *pSrc, int nSize)
Move nSize bytes out of pSrc.
virtual int Size()
Report the length of the data.
HxStream * GetRootStream()
Follow UnderlyingStream() from this stream until a stream reports none, and report that stream.
HxStream()
Construct a stream with a zeroed state.
static const int goodbit
Status value of a stream with nothing wrong.
Definition hxstream.h:202
int mFatalOnEnd
Definition hxstream.h:252
static const int failbit
Status bit a seek outside a chunk's bounds would set.
Definition hxstream.h:218
virtual ~HxStream()
Close the stream.
static const int kStatusEnd
Status value of a stream whose read position arrived at the end of its data.
Definition hxstream.h:210
virtual HxStream & ReadData(void *pDest, int nSize)
Move nSize bytes into pDest.
int mStatus
Definition hxstream.h:249
static const int badbit
Second status bit GetMarker() and SetMarker() of HxIDataChunk test.
Definition hxstream.h:226
HxStream & ReadStr(char *pszDest, int nDestSize)
Read a string with a variable-length size prefix into a fixed buffer.
HxStream & ReadString(HxStr &str)
Read a string with a variable-length size prefix into an HxStr.
HxStream & ReadNum(void *pDest, int nSize)
Move nSize bytes into pDest, reversing their order when the stream swaps bytes.
virtual void SetMarker(int nOffset, int nWhence)
Move the read position.
HxStreamSeekOrigin
Origin an HxStream::SetMarker() offset is measured from.
Definition hxstream.h:12
@ kHxSeekSet
Definition hxstream.h:13
@ kHxSeekEnd
Definition hxstream.h:15
@ kHxSeekCur
Definition hxstream.h:14