]> git.tdb.fi Git - libs/core.git/blob - source/io/mode.h
Add move semantics to Variant
[libs/core.git] / source / io / mode.h
1 #ifndef MSP_IO_MODE_H_
2 #define MSP_IO_MODE_H_
3
4 #include <stdexcept>
5 #include <msp/core/mspcore_api.h>
6
7 namespace Msp {
8 namespace IO {
9
10 enum Mode
11 {
12         M_NONE = 0,
13         M_READ = 1,
14         M_WRITE = 2,
15         M_RDWR = M_READ|M_WRITE,
16         M_APPEND = 4,
17         M_NONBLOCK = 8,
18         M_INHERIT = 16
19 };
20
21 inline Mode operator|(Mode m, Mode n)
22 { return Mode(static_cast<int>(m)|static_cast<int>(n)); }
23
24 inline Mode operator&(Mode m, Mode n)
25 { return Mode(static_cast<int>(m)&static_cast<int>(n)); }
26
27 inline Mode operator~(Mode m)
28 { return Mode(~static_cast<int>(m)); }
29
30 inline void adjust_mode(Mode &m, Mode f, bool b)
31 { m = b ? (m|f) : (m&~f); }
32
33
34 class MSPCORE_API invalid_access: public std::logic_error
35 {
36 public:
37         invalid_access(Mode);
38 };
39
40 } // namespace IO
41 } // namespace Msp
42
43 #endif