resonance 1.0.1
Loading...
Searching...
No Matches
acircbuff.h
Go to the documentation of this file.
1#pragma once
2
16class ACircBuff {
17public:
26 ACircBuff(char *pBuff, int nSize);
27
37 int Avail();
38
47 int IsRoom(int nBytes);
48
57
66 char *AdvanceRead(int nBytes);
67
79 int FullyRead(const char *pStart, int nBytes) const;
80
89 int WillWriteWrap(int nBytes) const;
90
102 char *AdvanceWrite(int nBytes);
103
116 int Write(const void *pSrc, int nBytes);
117
130 int Write(int nFile, int nBytes);
131
139 void Dump(const char *pszLabel) const;
140
141 // The deleting destructor at 0x0060e8d0 frees the object and nothing else, so the class
142 // declares no destructor of its own.
143
144 char *mBuff;
146 char *mWrite;
147 char *mRead;
148 char *mWrap;
149};
int Avail()
Report how many bytes can be written before the write pointer meets the read pointer.
int FullyRead(const char *pStart, int nBytes) const
Report whether the write pointer lies outside the nBytes starting at pStart.
void Dump(const char *pszLabel) const
Log the pointers and the size under a label.
int Write(int nFile, int nBytes)
Read nBytes from a file into the buffer in one piece.
char * mBuff
Definition acircbuff.h:144
int mBuffSize
Definition acircbuff.h:145
char * mRead
Definition acircbuff.h:147
int Write(const void *pSrc, int nBytes)
Copy nBytes into the buffer in one piece.
ACircBuff(char *pBuff, int nSize)
Take over a buffer of nSize bytes with both pointers at its start.
char * AdvanceWrite(int nBytes)
Commit nBytes written at the write pointer.
void WrapWriteIfOk()
Move the write pointer back to mBuff once it has reached mWrap, unless the read pointer is still at m...
char * mWrite
Definition acircbuff.h:146
int WillWriteWrap(int nBytes) const
Clamp nBytes to the space between the write pointer and mWrap.
char * AdvanceRead(int nBytes)
Consume nBytes, wrapping the read pointer past mWrap.
int IsRoom(int nBytes)
Report whether nBytes fit in one contiguous write.
char * mWrap
Definition acircbuff.h:148