Abstract base class for file input classes.
More...
#include <CoinFileIO.hpp>
|
(Note that these are not member functions.)
|
bool | fileAbsPath (const std::string &path) |
| Test if the given string looks like an absolute file path. More...
|
|
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. More...
|
|
Abstract base class for file input classes.
Definition at line 40 of file CoinFileIO.hpp.
CoinFileInput::CoinFileInput |
( |
const std::string & |
fileName | ) |
|
Constructor (don't use this, use the create method instead).
- Parameters
-
fileName | The name of the file used by this object. |
virtual CoinFileInput::~CoinFileInput |
( |
| ) |
|
|
virtual |
static bool CoinFileInput::haveGzipSupport |
( |
| ) |
|
|
static |
static bool CoinFileInput::haveBzip2Support |
( |
| ) |
|
|
static |
static CoinFileInput* CoinFileInput::create |
( |
const std::string & |
fileName | ) |
|
|
static |
Factory method, that creates a CoinFileInput (more precisely a subclass of it) for the file specified.
This method reads the first few bytes of the file and determines if this is a compressed or a plain file and returns the correct subclass to handle it. If the file does not exist or uses a compression not compiled in an exception is thrown.
- Parameters
-
fileName | The file that should be read. |
virtual int CoinFileInput::read |
( |
void * |
buffer, |
|
|
int |
size |
|
) |
| |
|
pure virtual |
Read a block of data from the file, similar to fread.
- Parameters
-
buffer | Address of a buffer to store the data into. |
size | Number of bytes to read (buffer should be large enough). |
- Returns
- Number of bytes read.
Implemented in CoinPlainFileInput.
virtual char* CoinFileInput::gets |
( |
char * |
buffer, |
|
|
int |
size |
|
) |
| |
|
pure virtual |
Reads up to (size-1) characters an stores them into the buffer, similar to fgets.
Reading ends, when EOF or a newline occurs or (size-1) characters have been read. The resulting string is terminated with '\0'. If reading ends due to an encoutered newline, the '
' is put into the buffer, before the '\0' is appended.
- Parameters
-
buffer | The buffer to put the string into. |
size | The size of the buffer in characters. |
- Returns
- buffer on success, or 0 if no characters have been read.
Implemented in CoinPlainFileInput.
bool fileAbsPath |
( |
const std::string & |
path | ) |
|
|
related |
Test if the given string looks like an absolute file path.
The criteria are:
- unix: string begins with `/'
- windows: string begins with `\' or with `drv:' (drive specifier)
bool fileCoinReadable |
( |
std::string & |
name, |
|
|
const std::string & |
dfltPrefix = std::string("") |
|
) |
| |
|
related |
Test if the file is readable, using likely versions of the file name, and return the name that worked.
The file name is constructed from name
using the following rules:
-
An absolute path is not modified.
-
If the name begins with `~', an attempt is made to replace `~' with the value of the environment variable HOME.
-
If a default prefix (
dfltPrefix
) is provided, it is prepended to the name.
If the constructed file name cannot be opened, and CoinUtils was built with support for compressed files, fileCoinReadable will try any standard extensions for supported compressed files.
The value returned in name
is the file name that actually worked.
The documentation for this class was generated from the following file: