]> git.tdb.fi Git - libs/core.git/blob - source/io/handle.h
3e06c71de5500e095195102da434dc0dc3aec273
[libs/core.git] / source / io / handle.h
1 #ifndef MSP_IO_HANDLE_H_
2 #define MSP_IO_HANDLE_H_
3
4 #include <cstddef>
5
6 namespace Msp {
7 namespace IO {
8
9 class Handle
10 {
11 public:
12         struct Private;
13
14 private:
15         Private *priv = 0;
16
17 public:
18         Handle();
19         Handle(const Handle &);
20         Handle &operator=(const Handle &);
21         ~Handle();
22
23         Private &operator*() { return *priv; }
24         const Private &operator*() const { return *priv; }
25
26         /** This is effectively a boolean conversion, but avoids accidental
27         conversion to OS native handles.  Unix-based systems use int and win32 uses
28         void *; const void * is not implicitly convertible to either. */
29         operator const void *() const;
30 };
31
32
33 void sys_set_blocking(Handle &, bool);
34 void sys_set_inherit(Handle &, bool);
35 std::size_t sys_read(Handle &, char *, std::size_t);
36 std::size_t sys_write(Handle &, const char *, std::size_t);
37 void sys_close(Handle &);
38
39 } // namespace IO
40 } // namespace Msp
41
42 #endif