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

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# CoinFileInput Class Reference

Abstract base class for file input classes. More...

`#include <CoinFileIO.hpp>`

Inheritance diagram for CoinFileInput:

[legend]
Collaboration diagram for CoinFileInput:

[legend]
List of all members.

## Public Member Functions
| CoinFileInput (const std::string &fileName)
| Constructor (don't use this, use the create method instead).
virtual | ~CoinFileInput ()
| Destructor.
virtual int | read (void *buffer, int size)=0
| Read a block of data from the file, similar to fread.
virtual char * | gets (char *buffer, int size)=0
| Reads up to (size-1) characters an stores them into the buffer, similar to fgets.
## Static Public Member Functions
static CoinFileInput * | create (const std::string &fileName)
| Factory method, that creates a CoinFileInput (more precisely a subclass of it) for the file specified.
## Related Functions
(Note that these are not member functions.)
bool | fileAbsPath (const std::string &path)
| Test if the given string looks like an absolute file path.
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.

## Detailed Description

Abstract base class for file input classes.

Definition at line 34 of file CoinFileIO.hpp.

## Constructor & Destructor Documentation

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]`

Destructor.

## Member Function Documentation

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.

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 ''. If reading ends due to an encoutered newline, the '
' is put into the buffer, before the '' 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.

## Friends And Related Function Documentation

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:

- /home/coin/SVN-release/Clp-1.5.0/CoinUtils/src/CoinFileIO.hpp