- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# /home/coin/SVN-release/Cgl-0.53.1/CoinUtils/src/CoinFileIO.hpp

Go to the documentation of this file.

    00001 // Copyright (C) 2005, COIN-OR.  All Rights Reserved.
    00002 #ifndef CoinFileIO_H
    00003 #define CoinFileIO_H
    00004
    00005 #include <string>
    00006
    00008 class CoinFileIOBase
    00009 {
    00010 public:
    00013   CoinFileIOBase (const std::string &fileName);
    00014
    00016   ~CoinFileIOBase ();
    00017
    00019   const char *getFileName () const;
    00020
    00022   inline std::string getReadType () const
    00023   { return readType_.c_str();}
    00024 protected:
    00025   std::string readType_;
    00026 private:
    00027   CoinFileIOBase ();
    00028   CoinFileIOBase (const CoinFileIOBase &);
    00029
    00030   std::string fileName_;
    00031 };
    00032
    00034 class CoinFileInput: public CoinFileIOBase
    00035 {
    00036 public:
    00044   static CoinFileInput *create (const std::string &fileName);
    00045
    00048   CoinFileInput (const std::string &fileName);
    00049
    00051   virtual ~CoinFileInput ();
    00052
    00057   virtual int read (void *buffer, int size) = 0;
    00058
    00068   virtual char *gets (char *buffer, int size) = 0;
    00069 };
    00070
    00072 class CoinFileOutput: public CoinFileIOBase
    00073 {
    00074 public:
    00075
    00077   enum Compression {
    00078     COMPRESS_NONE = 0,
    00079     COMPRESS_GZIP = 1,
    00080     COMPRESS_BZIP2 = 2
    00081   };
    00082
    00085   static bool compressionSupported (Compression compression);
    00086
    00097   static CoinFileOutput *create (const std::string &fileName,
    00098                                  Compression compression);
    00099
    00102   CoinFileOutput (const std::string &fileName);
    00103
    00105   virtual ~CoinFileOutput ();
    00106
    00111   virtual int write (const void * buffer, int size) = 0;
    00112
    00120   virtual bool puts (const char *s);
    00121
    00123   inline bool puts (const std::string &s)
    00124   {
    00125     return puts (s.c_str ());
    00126   }
    00127 };
    00128
    00136 bool fileAbsPath (const std::string &path) ;
    00137
    00156 bool fileCoinReadable(std::string &name,
    00157                       const std::string &dfltPrefix = std::string(""));
    00158 #endif