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