2001-10-06 18:13:28 +04:00
|
|
|
#ifndef CSTREAMBUFFER_H
|
|
|
|
#define CSTREAMBUFFER_H
|
|
|
|
|
|
|
|
#include "BasicTypes.h"
|
2002-06-01 23:26:11 +04:00
|
|
|
#include "stdlist.h"
|
|
|
|
#include "stdvector.h"
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
class CStreamBuffer {
|
2002-04-29 18:40:01 +04:00
|
|
|
public:
|
2001-10-06 18:13:28 +04:00
|
|
|
CStreamBuffer();
|
|
|
|
~CStreamBuffer();
|
|
|
|
|
|
|
|
// manipulators
|
|
|
|
|
|
|
|
// peek() returns a buffer of n bytes (which must be <= getSize()).
|
|
|
|
// pop() discards the next n bytes.
|
2001-10-14 20:58:01 +04:00
|
|
|
const void* peek(UInt32 n);
|
|
|
|
void pop(UInt32 n);
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
// write() appends n bytes to the buffer
|
2001-10-14 20:58:01 +04:00
|
|
|
void write(const void*, UInt32 n);
|
2001-10-06 18:13:28 +04:00
|
|
|
|
|
|
|
// accessors
|
|
|
|
|
|
|
|
// return the number of bytes in the buffer
|
2001-10-14 20:58:01 +04:00
|
|
|
UInt32 getSize() const;
|
2001-10-06 18:13:28 +04:00
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
private:
|
2001-10-06 18:13:28 +04:00
|
|
|
static const UInt32 kChunkSize;
|
|
|
|
|
|
|
|
typedef std::vector<UInt8> Chunk;
|
|
|
|
typedef std::list<Chunk> ChunkList;
|
|
|
|
|
|
|
|
ChunkList m_chunks;
|
|
|
|
UInt32 m_size;
|
2002-06-14 22:08:20 +04:00
|
|
|
UInt32 m_headUsed;
|
2001-10-06 18:13:28 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|