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

- File List
- File Members

# /home/coin/svn-release/Alps-1.5.2/CoinUtils/src/CoinFileIO.hpp

Go to the documentation of this file.

    00001 /* $Id: CoinFileIO.hpp 1439 2011-06-13 16:31:21Z stefan $ */
    00002 // Copyright (C) 2005, COIN-OR.  All Rights Reserved.
    00003 // This code is licensed under the terms of the Eclipse Public License (EPL).
    00004
    00005 #ifndef CoinFileIO_H
    00006 #define CoinFileIO_H
    00007
    00008 #include <string>
    00009
    00011 class CoinFileIOBase
    00012 {
    00013 public:
    00016   CoinFileIOBase (const std::string &fileName);
    00017
    00019   ~CoinFileIOBase ();
    00020
    00022   const char *getFileName () const;
    00023
    00025   inline std::string getReadType () const
    00026   { return readType_.c_str();}
    00027 protected:
    00028   std::string readType_;
    00029 private:
    00030   CoinFileIOBase ();
    00031   CoinFileIOBase (const CoinFileIOBase &);
    00032
    00033   std::string fileName_;
    00034 };
    00035
    00037 class CoinFileInput: public CoinFileIOBase
    00038 {
    00039 public:
    00041   static bool haveGzipSupport();
    00043   static bool haveBzip2Support();
    00044
    00052   static CoinFileInput *create (const std::string &fileName);
    00053
    00056   CoinFileInput (const std::string &fileName);
    00057
    00059   virtual ~CoinFileInput ();
    00060
    00065   virtual int read (void *buffer, int size) = 0;
    00066
    00076   virtual char *gets (char *buffer, int size) = 0;
    00077 };
    00078
    00080 class CoinFileOutput: public CoinFileIOBase
    00081 {
    00082 public:
    00083
    00085   enum Compression {
    00086     COMPRESS_NONE = 0,
    00087     COMPRESS_GZIP = 1,
    00088     COMPRESS_BZIP2 = 2
    00089   };
    00090
    00093   static bool compressionSupported (Compression compression);
    00094
    00105   static CoinFileOutput *create (const std::string &fileName,
    00106                                  Compression compression);
    00107
    00110   CoinFileOutput (const std::string &fileName);
    00111
    00113   virtual ~CoinFileOutput ();
    00114
    00119   virtual int write (const void * buffer, int size) = 0;
    00120
    00128   virtual bool puts (const char *s);
    00129
    00131   inline bool puts (const std::string &s)
    00132   {
    00133     return puts (s.c_str ());
    00134   }
    00135 };
    00136
    00144 bool fileAbsPath (const std::string &path) ;
    00145
    00164 bool fileCoinReadable(std::string &name,
    00165                       const std::string &dfltPrefix = std::string(""));
    00166 #endif