Cgl 0.60.2

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CoinFileIO.hpp
Go to the documentation of this file.
1 /* $Id: CoinFileIO.hpp 2083 2019-01-06 19:38:09Z unxusr $ */
2 // Copyright (C) 2005, COIN-OR. All Rights Reserved.
3 // This code is licensed under the terms of the Eclipse Public License (EPL).
4
5 #ifndef CoinFileIO_H
6 #define CoinFileIO_H
7
8 #include <string>
9
11 class CoinFileIOBase {
12 public:
15 CoinFileIOBase(const std::string &fileName);
16
18 ~CoinFileIOBase();
19
21 const char *getFileName() const;
22
24 inline std::string getReadType() const
25 {
26 return readType_.c_str();
27 }
28
29 protected:
30 std::string readType_;
31
32 private:
33 CoinFileIOBase();
34 CoinFileIOBase(const CoinFileIOBase &);
35
36 std::string fileName_;
37 };
38
40 class CoinFileInput : public CoinFileIOBase {
41 public:
43 static bool haveGzipSupport();
45 static bool haveBzip2Support();
46
54 static CoinFileInput *create(const std::string &fileName);
55
58 CoinFileInput(const std::string &fileName);
59
61 virtual ~CoinFileInput();
62
67 virtual int read(void *buffer, int size) = 0;
68
78 virtual char *gets(char *buffer, int size) = 0;
79 };
80
82 class CoinPlainFileInput : public CoinFileInput {
83 public:
84 CoinPlainFileInput(const std::string &fileName);
86 CoinPlainFileInput(FILE *fp);
87 virtual ~CoinPlainFileInput();
88
89 virtual int read(void *buffer, int size);
90
91 virtual char *gets(char *buffer, int size);
92
93 private:
94 FILE *f_;
95 };
96
98 class CoinFileOutput : public CoinFileIOBase {
99 public:
101 enum Compression {
102 COMPRESS_NONE = 0,
103 COMPRESS_GZIP = 1,
104 COMPRESS_BZIP2 = 2
105 };
106
109 static bool compressionSupported(Compression compression);
110
121 static CoinFileOutput *create(const std::string &fileName,
122 Compression compression);
123
126 CoinFileOutput(const std::string &fileName);
127
129 virtual ~CoinFileOutput();
130
135 virtual int write(const void *buffer, int size) = 0;
136
144 virtual bool puts(const char *s);
145
147 inline bool puts(const std::string &s)
148 {
149 return puts(s.c_str());
150 }
151 };
152
160 bool fileAbsPath(const std::string &path);
161
180 bool fileCoinReadable(std::string &name,
181 const std::string &dfltPrefix = std::string(""));
182 #endif
183
184 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
185 */
CoinFileOutput::puts
virtual bool puts(const char *s)
Write a string to the file (like fputs).
CoinPlainFileInput::f_
FILE * f_
Definition: CoinFileIO.hpp:94
CoinFileOutput::puts
bool puts(const std::string &s)
Convenience method: just a &#39;puts(s.c_str())&#39;.
Definition: CoinFileIO.hpp:147
CoinFileInput::read
virtual int read(void *buffer, int size)=0
Read a block of data from the file, similar to fread.
CoinFileOutput::COMPRESS_BZIP2
bzip2 compression.
Definition: CoinFileIO.hpp:104
CoinFileOutput::~CoinFileOutput
virtual ~CoinFileOutput()
Destructor.
CoinFileInput::fileCoinReadable
bool fileCoinReadable(std::string &name, const std::string &dfltPrefix=std::string(""))
Test if the file is readable, using likely versions of the file name, and return the name that worked...
CoinFileInput::CoinFileInput
CoinFileInput(const std::string &fileName)
Constructor (don&#39;t use this, use the create method instead).
CoinFileOutput::COMPRESS_NONE
No compression.
Definition: CoinFileIO.hpp:102
CoinFileIOBase::CoinFileIOBase
CoinFileIOBase()
CoinFileIOBase
Base class for FileIO classes.
Definition: CoinFileIO.hpp:11
CoinPlainFileInput::~CoinPlainFileInput
virtual ~CoinPlainFileInput()
CoinFileIOBase::getFileName
const char * getFileName() const
Return the name of the file used by this object.
CoinFileOutput::CoinFileOutput
CoinFileOutput(const std::string &fileName)
Constructor (don&#39;t use this, use the create method instead).
CoinFileInput::fileAbsPath
bool fileAbsPath(const std::string &path)
Test if the given string looks like an absolute file path.
CoinFileOutput
Abstract base class for file output classes.
Definition: CoinFileIO.hpp:98
CoinFileOutput::Compression
Compression
The compression method.
Definition: CoinFileIO.hpp:101
CoinFileInput::haveBzip2Support
static bool haveBzip2Support()
indicates whether CoinFileInput supports bzip2&#39;ed files
CoinFileOutput::write
virtual int write(const void *buffer, int size)=0
Write a block of data to the file, similar to fwrite.
CoinFileIOBase::fileName_
std::string fileName_
Definition: CoinFileIO.hpp:36
CoinFileIOBase::readType_
std::string readType_
Definition: CoinFileIO.hpp:30
CoinFileOutput::compressionSupported
static bool compressionSupported(Compression compression)
Returns whether the specified compression method is supported (i.e.
CoinFileInput
Abstract base class for file input classes.
Definition: CoinFileIO.hpp:40
CoinPlainFileInput::CoinPlainFileInput
CoinPlainFileInput(const std::string &fileName)
CoinFileInput::gets
virtual char * gets(char *buffer, int size)=0
Reads up to (size-1) characters an stores them into the buffer, similar to fgets. ...
CoinFileOutput::create
static CoinFileOutput * create(const std::string &fileName, Compression compression)
Factory method, that creates a CoinFileOutput (more precisely a subclass of it) for the file specifie...
CoinFileInput::create
static CoinFileInput * create(const std::string &fileName)
Factory method, that creates a CoinFileInput (more precisely a subclass of it) for the file specified...
CoinPlainFileInput::gets
virtual char * gets(char *buffer, int size)
Reads up to (size-1) characters an stores them into the buffer, similar to fgets. ...
CoinFileIOBase::~CoinFileIOBase
~CoinFileIOBase()
Destructor.
CoinPlainFileInput::read
virtual int read(void *buffer, int size)
Read a block of data from the file, similar to fread.
CoinFileIOBase::getReadType
std::string getReadType() const
Return the method of reading being used.
Definition: CoinFileIO.hpp:24
CoinFileInput::~CoinFileInput
virtual ~CoinFileInput()
Destructor.
CoinPlainFileInput
This reads plain text files.
Definition: CoinFileIO.hpp:82
CoinFileInput::haveGzipSupport
static bool haveGzipSupport()
indicates whether CoinFileInput supports gzip&#39;ed files
CoinFileOutput::COMPRESS_GZIP
gzip compression.
Definition: CoinFileIO.hpp:103