Virtual Testbed
Ship dynamics simulator for extreme conditions
file_stream.hh
1 #ifndef VTESTBED_ASSETS_FILE_STREAM_HH
2 #define VTESTBED_ASSETS_FILE_STREAM_HH
3 
4 #include <fstream>
5 
6 namespace vtb {
7 
8  namespace assets {
9 
11  public:
12  inline explicit
13  File_input_stream(const std::string& filename): std::ifstream(filename) {
14  if (!is_open()) {
15  throw std::invalid_argument("failed to open \"" + filename + "\"");
16  }
18  exceptions(std::ios::failbit | std::ios::badbit);
19  }
20  };
21 
23  public:
24  inline explicit
25  File_output_stream(const std::string& filename): std::ofstream(filename) {
26  if (!is_open()) {
27  throw std::invalid_argument("failed to open \"" + filename + "\"");
28  }
30  exceptions(std::ios::failbit | std::ios::badbit);
31  }
32  };
33 
34  }
35 
36 }
37 
38 #endif // vim:filetype=cpp
T classic(T... args)
T imbue(T... args)
T exceptions(T... args)
Main namespace.
Definition: convert.hh:9
T is_open(T... args)