aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bufferarray.h
blob: fbf26f11d5b38243ac6dd0b3f44712d0ff976acc (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
#ifndef _bufferarray_h
#define _bufferarray_h

#include "bool.h"
class bufferStore;

class bufferArray {
	public:
		bufferArray();
		bufferArray(const bufferArray &a);
		~bufferArray();
		bufferArray &operator =(const bufferArray &a);
		bool empty() const;

		// this is NOT a real push as with a FIFO but
		// appends the bufferStore.
		void pushBuffer(const bufferStore& b);
		bufferStore popBuffer(void);

		// new API (push() now behaves like a FIFO, more operators
		bufferStore &operator [](const unsigned long index);
		bufferArray &operator +(const bufferStore &);  // append
		bufferArray &operator +(const bufferArray &);  // append
		bufferArray &operator +=(const bufferStore &b); // append
		bufferStore pop(void);
		void push(const bufferStore& b);
		void append(const bufferStore& b);
		long length(void);
		void clear(void);

private:
		static const long ALLOC_MIN = 5;
		long len;
		long lenAllocd;
		bufferStore* buff;
};

inline bool bufferArray::empty() const { return len == 0; }

#endif