blob: df216c01ce20d7030c11bb17738cda7ce40d28c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#ifndef _bufferstore_h
#define _bufferstore_h
#include "bool.h"
class ostream;
class bufferStore {
public:
bufferStore();
bufferStore(const unsigned char *, long);
~bufferStore();
bufferStore(const bufferStore &);
bufferStore &operator =(const bufferStore &);
// Reading Utils
unsigned long getLen() const;
unsigned char getByte(long pos) const;
unsigned int getWord(long pos) const;
unsigned int getDWord(long pos) const;
const char* getString(long pos=0) const;
void discardFirstBytes(int);
friend ostream &operator<<(ostream &, const bufferStore &);
bool empty() const;
// Writing utils
void init();
void init(const unsigned char*, long);
void addByte(unsigned char);
void addWord(int);
void addDWord(long);
void addString(const char*);
void addStringT(const char*);
void addBytes(const unsigned char*, int);
void addBuff(const bufferStore &, long maxLen=-1);
private:
void checkAllocd(long newLen);
long len;
long lenAllocd;
long start;
unsigned char* buff;
enum c { MIN_LEN = 300 };
};
inline bool bufferStore::empty() const {
return (len-start) == 0;
}
#endif
|