Class for input files
More...
#include <IFile.h>
Classes | |
class | Field |
Public Member Functions | |
IFile () | |
Constructor. More... | |
~IFile () | |
Destructor. More... | |
void | allowIgnoredFields () |
Allow some of the fields in the input to be ignored. More... | |
void | allowNoEOL () |
Allow files without EOL at the end. More... | |
void | close () |
Closes the file Should be used only for explicitely opened files. More... | |
FileBase & | enforceSuffix (const std::string &suffix) |
Enforce suffix. More... | |
bool | FieldExist (const std::string &s) |
Check if a field exist. More... | |
bool | FileExist (const std::string &path) |
Check if the file exists. More... | |
virtual FileBase & | flush () |
Flushes the file to disk. More... | |
FILE * | getFILE () const |
Get the underlying file pointer. More... | |
IFile & | getline (std::string &) |
Get a full line as a string. More... | |
std::string | getMode () const |
Retrieve the mode. More... | |
std::string | getPath () const |
Retrieve the path. More... | |
std::string | getSuffix () const |
Get the file suffix. More... | |
bool | isOpen () |
Check if a file is open. More... | |
FileBase & | link (FILE *) |
Link to an already open filed. More... | |
FileBase & | link (PlumedMain &) |
Link to a PlumedMain object Automatically links also the corresponding Communicator. More... | |
FileBase & | link (Communicator &) |
Link to a Communicator object. More... | |
FileBase & | link (Action &) |
Link to an Action object. More... | |
IFile & | open (const std::string &name) |
Opens the file. More... | |
operator bool () const | |
Check for error/eof. More... | |
void | reset (bool) |
Reset end of file. More... | |
IFile & | scanField (const std::string &, double &) |
Read a double field. More... | |
IFile & | scanField (const std::string &, int &) |
Read a int field. More... | |
IFile & | scanField (const std::string &, std::string &) |
Read a string field. More... | |
IFile & | scanField () |
Ends a field-formatted line. More... | |
IFile & | scanField (Value *val) |
Read in a value. More... | |
IFile & | scanFieldList (std::vector< std::string > &) |
Gets the list of all fields. More... | |
void | setHeavyFlush () |
Set heavyFlush flag. More... | |
Static Public Member Functions | |
static std::string | appendSuffix (const std::string &path, const std::string &suffix) |
Append suffix. More... | |
Protected Attributes | |
Action * | action |
pointer to corresponding action. NULL if not linked More... | |
bool | cloned |
Control closing on destructor. More... | |
Communicator * | comm |
communicator. NULL if not set More... | |
bool | eof |
Set to true when end of file is encountered. More... | |
bool | err |
Set to true when error is encountered. More... | |
FILE * | fp |
file pointer More... | |
void * | gzfp |
zip file pointer. More... | |
bool | heavyFlush |
Set to true if you want flush to be heavy (close/reopen) More... | |
std::string | mode |
mode of the opened file More... | |
std::string | path |
path of the opened file More... | |
PlumedMain * | plumed |
pointer to main plumed object. NULL if not linked More... | |
Private Member Functions | |
IFile & | advanceField () |
Advance to next field (= read one line) More... | |
unsigned | findField (const std::string &name) const |
Find field index by name. More... | |
size_t | llread (char *, size_t) |
Low-level read. More... | |
Private Attributes | |
std::vector< Field > | fields |
All the defined fields. More... | |
bool | ignoreFields |
Set to true if you want to allow fields to be ignored in the read in file. More... | |
bool | inMiddleOfField |
Flag set in the middle of a field reading. More... | |
bool | noEOL |
Set to true to allow files without end-of-line at the end. More... | |
Class for input files
This class provides features similar to those in the standard C "FILE*" type, but only for sequential input. See OFile for sequential output.
PLMD::IFile::IFile | ( | ) |
Constructor.
PLMD::IFile::~IFile | ( | ) |
Destructor.
|
private |
Advance to next field (= read one line)
void PLMD::IFile::allowIgnoredFields | ( | ) |
Allow some of the fields in the input to be ignored.
void PLMD::IFile::allowNoEOL | ( | ) |
Allow files without EOL at the end.
This in practice should be only used when opening plumed input files
|
staticinherited |
Append suffix.
It appends the desired suffix to the string. Notice that it conserves some suffix (e.g. gz/xtc/trr).
|
inherited |
Closes the file Should be used only for explicitely opened files.
|
inherited |
Enforce suffix.
Overrides the one set in PlumedMain&
bool PLMD::IFile::FieldExist | ( | const std::string & | s | ) |
Check if a field exist.
|
inherited |
Check if the file exists.
|
private |
Find field index by name.
|
virtualinherited |
Flushes the file to disk.
Reimplemented in PLMD::OFile.
|
inlineinherited |
Get the underlying file pointer.
It might be null even if the file is open, e.g. when the file was open as a gzipped file.
IFile & PLMD::IFile::getline | ( | std::string & | str | ) |
Get a full line as a string.
|
inlineinherited |
Retrieve the mode.
|
inlineinherited |
Retrieve the path.
|
inherited |
Get the file suffix.
|
inherited |
Check if a file is open.
|
inherited |
Link to an already open filed.
|
inherited |
Link to a PlumedMain object Automatically links also the corresponding Communicator.
|
inherited |
Link to a Communicator object.
Link to an Action object.
Automatically links also the corresponding PlumedMain and Communicator.
|
private |
Low-level read.
Note: in parallel, all processes read
|
virtual |
Opens the file.
Implements PLMD::FileBase.
|
inherited |
Check for error/eof.
void PLMD::IFile::reset | ( | bool | reset | ) |
Reset end of file.
IFile & PLMD::IFile::scanField | ( | const std::string & | name, |
double & | x | ||
) |
Read a double field.
IFile & PLMD::IFile::scanField | ( | const std::string & | name, |
int & | x | ||
) |
Read a int field.
IFile & PLMD::IFile::scanField | ( | const std::string & | name, |
std::string & | str | ||
) |
Read a string field.
IFile & PLMD::IFile::scanField | ( | ) |
Ends a field-formatted line.
Typically used as
if.scanField("a",a).scanField("b",b).scanField();
IFile & PLMD::IFile::scanFieldList | ( | std::vector< std::string > & | s | ) |
Gets the list of all fields.
|
inlineinherited |
Set heavyFlush flag.
|
protectedinherited |
pointer to corresponding action. NULL if not linked
|
protectedinherited |
Control closing on destructor.
If true, file will not be closed in destructor
|
protectedinherited |
communicator. NULL if not set
|
protectedinherited |
Set to true when end of file is encountered.
|
protectedinherited |
Set to true when error is encountered.
|
private |
All the defined fields.
|
protectedinherited |
file pointer
|
protectedinherited |
zip file pointer.
|
protectedinherited |
Set to true if you want flush to be heavy (close/reopen)
|
private |
Set to true if you want to allow fields to be ignored in the read in file.
|
private |
Flag set in the middle of a field reading.
|
protectedinherited |
mode of the opened file
|
private |
Set to true to allow files without end-of-line at the end.
|
protectedinherited |
path of the opened file
|
protectedinherited |
pointer to main plumed object. NULL if not linked
Hosted by GitHub | 1.8.14 |