aboutsummaryrefslogtreecommitdiff
path: root/lib/base/buffer.h
blob: 9108ba8b4b2bf5f3665b6445dfebac4914bc1a8f (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 __src_lib_base_buffer_h
#define __src_lib_base_buffer_h

#include <asm/types.h>
#include <list>

/**
 * IO buffer.
 */
class eIOBuffer
{
	int allocationsize;
	struct eIOBufferData
	{
		__u8 *data;
		int len;
	};
	std::list<eIOBufferData> buffer;
	void removeblock();
	eIOBufferData &addblock();
	int ptr;
public:
	eIOBuffer(int allocationsize): allocationsize(allocationsize), ptr(0)
	{
	}
	~eIOBuffer();
	int size() const;
	int empty() const;
	void clear();
	int peek(void *dest, int len) const;
	void skip(int len);
	int read(void *dest, int len);
	void write(const void *source, int len);
	int fromfile(int fd, int len);
	int tofile(int fd, int len);

	int searchchr(char ch) const;
};

#endif