cgma
CubitFile.hpp
Go to the documentation of this file.
00001 //- Class:          CubitFile
00002 //- Description:    Class with functions to get work with files
00003 
00004 #ifndef CUBITFILE_HPP
00005 #define CUBITFILE_HPP
00006 
00007 #include <stdio.h>
00008 #include "CubitString.hpp"
00009 #include "CGMUtilConfigure.h"
00010 
00011 // wrapper for C FILE*
00012 // Includes support for non-ascii filenames.
00013 // Automatically opens/closes the file.
00014 class CUBIT_UTIL_EXPORT CubitFile
00015 {
00016 public:
00017   // default constructor
00018   CubitFile();
00019 
00020   // constructor that also opens the file
00021   CubitFile(const CubitString& file, const char* mode);
00022 
00023   // closes the file, if open
00024   virtual ~CubitFile();
00025 
00026   // opens a file
00027   bool open(const CubitString& file, const char* mode);
00028 
00029   // closes the file
00030   void close();
00031 
00032   // Return the FILE* handle.
00033   // Returns NULL if status is not 'OK'.
00034   FILE* file() const;
00035 
00036   // returns whether FILE* is valid
00037   operator bool () const;
00038 
00039   // Return status of opening the file.
00040   // For example ENOENT for non-existant file.
00041   int error();
00042 
00043 protected:
00044   FILE* mFile;
00045   int mError;
00046 };
00047 
00048 
00049 #endif
00050 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines