]> git.tdb.fi Git - libs/core.git/blob - source/io/seekable.h
Implement controls for file descriptor inheritance
[libs/core.git] / source / io / seekable.h
1 #ifndef MSP_IO_SEEKABLE_H_
2 #define MSP_IO_SEEKABLE_H_
3
4 #include <stdexcept>
5 #include <msp/core/inttypes.h>
6 #include "base.h"
7
8 namespace Msp {
9 namespace IO {
10
11 class Handle;
12
13 typedef Int64 SeekOffset;
14
15 enum SeekType
16 {
17         S_BEG,
18         S_CUR,
19         S_END
20 };
21
22
23 class bad_seek: public std::runtime_error
24 {
25 public:
26         bad_seek(SeekOffset, SeekType);
27         virtual ~bad_seek() throw() { }
28 };
29
30
31 class Seekable: public Base
32 {
33 protected:
34         Seekable() { }
35
36 public:
37         /** Changes the read/write offset.  Returns the new offset. */
38         virtual SeekOffset seek(SeekOffset, SeekType) = 0;
39         
40         /** Returns the current read/write offset. */
41         virtual SeekOffset tell() const = 0;
42 };
43
44
45 SeekOffset sys_seek(Handle &, SeekOffset, SeekType);
46
47 } // namespace IO
48 } // namespace Msp
49
50 #endif