File: Stream.h

package info (click to toggle)
storm-lang 0.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,028 kB
  • sloc: ansic: 261,471; cpp: 140,432; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (45 lines) | stat: -rw-r--r-- 932 bytes parent folder | download | duplicates (3)
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
#pragma once
#include "Object.h"
#include "Bitmask.h"

// A basic stream class.
class Stream : NoCopy {
public:
	enum Mode { mNone = 0x0, mRead = 0x1, mWrite = 0x2, mRandom = 0x3 };

	Stream();
	virtual ~Stream();

	// Clone this stream.
	virtual Stream *clone() const = 0;

	// Non-implemented reads and write simply assert.
	virtual nat read(nat size, void *to);
	virtual void write(nat size, const void *from);

	virtual nat64 pos() const = 0;
	virtual nat64 length() const = 0;
	virtual void seek(nat64 to) = 0;
	virtual bool more() const;

	virtual bool valid() const = 0;

	// See if any error has occurred.
	virtual bool error() const;

	// Clear the error flag.
	virtual void clearError();

	// Write an entire stream.
	void write(Stream *from);

protected:
	// Error during stream operation.
	bool hasError;

private:
	// Chunk size when copying streams.
	enum { copySize = 1 * 1024 };
};

BITMASK_OPERATORS(Stream::Mode);