NAMD
fstream_namd.h
Go to the documentation of this file.
1 
2 #ifndef FSTREAM_NAMD_H
3 #define FSTREAM_NAMD_H
4 
5 #include <iostream>
6 #include <sstream>
7 
8 class ofstream_namd : public std::ostringstream {
9 
10 private:
11  int fd;
12  std::string fname;
13 
14 public:
15 
16  ofstream_namd() : fd(0) { ; }
17 
18  explicit ofstream_namd(const char *_fname, std::ios_base::openmode _mode = std::ios_base::out) : fd(0) {
19  open(_fname, _mode);
20  }
21 
22  explicit ofstream_namd(const char *_fname, const char *_ext) : fd(0) {
23  open(_fname, _ext);
24  }
25 
26  void open(const char *_fname, std::ios_base::openmode _mode = std::ios_base::out);
27 
28  void open(const char *_fname, const char *_ext);
29 
30  bool is_open() const { return ! ! fd; }
31 
33 
34  void close();
35 
37  if ( fd ) close();
38  }
39 
40  bool good() const { return true; }
41  bool fail() const { return false; }
42  bool bad() const { return false; }
43  bool operator!() const { return false; }
44  operator bool() const { return true; }
45  void clear() { ; }
46 
47 };
48 
49 #endif // FSTREAM_NAMD_H
50 
bool operator!() const
Definition: fstream_namd.h:43
ofstream_namd & flush()
Definition: fstream_namd.C:17
bool bad() const
Definition: fstream_namd.h:42
ofstream_namd(const char *_fname, std::ios_base::openmode _mode=std::ios_base::out)
Definition: fstream_namd.h:18
bool fail() const
Definition: fstream_namd.h:41
ofstream_namd(const char *_fname, const char *_ext)
Definition: fstream_namd.h:22
bool is_open() const
Definition: fstream_namd.h:30
bool good() const
Definition: fstream_namd.h:40
void open(const char *_fname, std::ios_base::openmode _mode=std::ios_base::out)
Definition: fstream_namd.C:11