Lely core libraries  2.2.5
io.hpp
Go to the documentation of this file.
1 
24 #ifndef LELY_IO2_SYS_IO_HPP_
25 #define LELY_IO2_SYS_IO_HPP_
26 
27 #include <lely/io2/sys/io.h>
28 #include <lely/util/error.hpp>
29 
30 namespace lely {
31 namespace io {
32 
34 class IoGuard {
35  public:
36  IoGuard() {
37  if (io_init() == -1) util::throw_errc("IoGuard");
38  }
39 
40  IoGuard(const IoGuard&) = delete;
41  IoGuard& operator=(const IoGuard&) = delete;
42 
43  ~IoGuard() noexcept { io_fini(); }
44 };
45 
46 } // namespace io
47 } // namespace lely
48 
49 #endif // !LELY_IO2_SYS_IO_HPP_
io_fini
void io_fini(void)
Finalizes the I/O library and terminates the availability of the I/O functions.
Definition: io.c:38
io.h
io_init
int io_init(void)
Initializes the I/O library and makes the I/O functions available for use.
Definition: io.c:31
lely::io::IoGuard
A RAII-style wrapper around io_init() and io_fini().
Definition: io.hpp:34
error.hpp