fstream_namd.h

Go to the documentation of this file.
00001 
00002 #ifndef FSTREAM_NAMD_H
00003 #define FSTREAM_NAMD_H
00004 
00005 #include <iostream>
00006 #include <sstream>
00007 
00008 class ofstream_namd : public std::ostringstream {
00009 
00010 private:
00011   int fd;
00012   std::string fname;
00013 
00014 public:
00015 
00016   ofstream_namd() : fd(0) { ; }
00017 
00018   explicit ofstream_namd(const char *_fname, std::ios_base::openmode _mode = std::ios_base::out) : fd(0) {
00019     open(_fname, _mode);
00020   }
00021 
00022   explicit ofstream_namd(const char *_fname, const char *_ext) : fd(0) {
00023     open(_fname, _ext);
00024   }
00025 
00026   void open(const char *_fname, std::ios_base::openmode _mode = std::ios_base::out);
00027 
00028   void open(const char *_fname, const char *_ext);
00029 
00030   bool is_open() const { return ! ! fd; }
00031 
00032   ofstream_namd& flush();
00033 
00034   void close();
00035 
00036   ~ofstream_namd() {
00037     if ( fd ) close();
00038   }
00039 
00040   bool good() const { return true; }
00041   bool fail() const { return false; }
00042   bool bad() const { return false; }
00043   bool operator!() const { return false; }
00044   operator bool() const { return true; }
00045   void clear() { ; }
00046 
00047 };
00048 
00049 #endif  // FSTREAM_NAMD_H
00050 

Generated on Mon Nov 20 01:17:12 2017 for NAMD by  doxygen 1.4.7