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