Cbc  2.9.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Related Functions | List of all members
CoinFileInput Class Referenceabstract

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

#include <CoinFileIO.hpp>

+ Inheritance diagram for CoinFileInput:
+ Collaboration diagram for CoinFileInput:

Public Member Functions

 CoinFileInput (const std::string &fileName)
 Constructor (don't use this, use the create method instead). More...
 
virtual ~CoinFileInput ()
 Destructor. More...
 
virtual int read (void *buffer, int size)=0
 Read a block of data from the file, similar to fread. More...
 
virtual char * gets (char *buffer, int size)=0
 Reads up to (size-1) characters an stores them into the buffer, similar to fgets. More...
 
- Public Member Functions inherited from CoinFileIOBase
 CoinFileIOBase (const std::string &fileName)
 Constructor. More...
 
 ~CoinFileIOBase ()
 Destructor. More...
 
const char * getFileName () const
 Return the name of the file used by this object. More...
 
std::string getReadType () const
 Return the method of reading being used. More...
 

Static Public Member Functions

static bool haveGzipSupport ()
 indicates whether CoinFileInput supports gzip'ed files More...
 
static bool haveBzip2Support ()
 indicates whether CoinFileInput supports bzip2'ed files More...
 
static CoinFileInputcreate (const std::string &fileName)
 Factory method, that creates a CoinFileInput (more precisely a subclass of it) for the file specified. More...
 

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. 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...
 

Additional Inherited Members

- Protected Attributes inherited from CoinFileIOBase
std::string readType_
 

Detailed Description

Abstract base class for file input classes.

Definition at line 37 of file CoinFileIO.hpp.

Constructor & Destructor Documentation

CoinFileInput::CoinFileInput ( const std::string &  fileName)

Constructor (don't use this, use the create method instead).

Parameters
fileNameThe name of the file used by this object.
virtual CoinFileInput::~CoinFileInput ( )
virtual

Destructor.

Member Function Documentation

static bool CoinFileInput::haveGzipSupport ( )
static

indicates whether CoinFileInput supports gzip'ed files

static bool CoinFileInput::haveBzip2Support ( )
static

indicates whether CoinFileInput supports bzip2'ed files

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
fileNameThe 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
bufferAddress of a buffer to store the data into.
sizeNumber 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 '\0'. If reading ends due to an encoutered newline, the '
' is put into the buffer, before the '\0' is appended.

Parameters
bufferThe buffer to put the string into.
sizeThe 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: