AvogadroLibs 1.98.1
|
General API for file formats. More...
#include <avogadro/io/fileformat.h>
Public Types | |
enum | Operation { None = 0x0 , Read = 0x1 , Write = 0x2 , ReadWrite = Read | Write , MultiMolecule = 0x4 , Stream = 0x10 , String = 0x20 , File = 0x40 , All = ReadWrite | MultiMolecule | Stream | String | File } |
Flags defining supported operations. | |
typedef int | Operations |
Public Member Functions | |
virtual Operations | supportedOperations () const =0 |
bool | open (const std::string &fileName, Operation mode) |
Open the specified file in Read or Write mode. | |
Operation | mode () |
The mode the format is currently operating in. | |
bool | isMode (Operation isInMode) |
Check if the supplied mode(s) is being used. | |
void | close () |
Close any opened file handles. | |
bool | readMolecule (Core::Molecule &molecule) |
Read in a molecule, if there are no molecules to read molecule will be empty. This can be used to read in one or more molecules from a given file using repeated calls for each molecule. | |
bool | writeMolecule (const Core::Molecule &molecule) |
Write out a molecule. This can be used to write one or more molecules to a given file using repeated calls for each molecule. | |
virtual bool | read (std::istream &in, Core::Molecule &molecule)=0 |
Read the given in stream and load it into molecule . | |
virtual bool | write (std::ostream &out, const Core::Molecule &molecule)=0 |
Write to the given out stream the contents of molecule . | |
bool | readFile (const std::string &fileName, Core::Molecule &molecule) |
Read the given fileName and load it into molecule . | |
bool | writeFile (const std::string &fileName, const Core::Molecule &molecule) |
Write to the given fileName the contents of molecule . | |
bool | readString (const std::string &string, Core::Molecule &molecule) |
Read the given string and load it into molecule . | |
bool | writeString (std::string &string, const Core::Molecule &molecule) |
Write to the given string the contents of molecule . | |
std::string | error () const |
Get the error string, contains errors/warnings encountered. | |
std::string | fileName () const |
Get the file name (if known). | |
void | setOptions (const std::string &options) |
Set options for the file reader. | |
std::string | options () const |
Get the file format options, can be used to change file IO. | |
virtual void | clear () |
virtual FileFormat * | newInstance () const =0 |
virtual std::string | identifier () const =0 |
A unique identifier, used to retrieve formats programmatically. CML, XYZ, PDB etc. A runtime warning will be generated if the identifier is not unique. | |
virtual std::string | name () const =0 |
The name of the format, should be short such as Chemical Markup Language, XYZ format, Protein Databank etc. | |
virtual std::string | description () const =0 |
virtual std::string | specificationUrl () const =0 |
virtual std::vector< std::string > | fileExtensions () const =0 |
Get the file name extension(s) that the format supports reading. | |
virtual std::vector< std::string > | mimeTypes () const =0 |
Get the MIME type(s) that the format supports reading. | |
Static Public Member Functions | |
static bool | validateFileName (const std::string &fileName) |
Validates the given file name. | |
Protected Member Functions | |
void | appendError (const std::string &errorString, bool newLine=true) |
Append an error to the error string for the format. | |
This serves as the common base class for chemical file formats. Classes deriving from this one override the read and write virtual methods and operate on the given streams. Several other signatures are available for convenience. If there is an error reading or writing a file the string returned by error() will give more details.
|
pure virtual |
Implemented in CjsonFormat, CmlFormat, DcdFormat, GromacsFormat, LammpsTrajectoryFormat, LammpsDataFormat, MdlFormat, MMTFFormat, PdbFormat, TrrFormat, TurbomoleFormat, PoscarFormat, OutcarFormat, XyzFormat, GAMESSUSOutput, GaussianCube, GaussianFchk, GenericOutput, MoldenFile, MopacAux, NWChemJson, NWChemLog, and ORCAOutput.
|
static |
Checks if the filename contains any invalid characters (e.g. ..) Also checks if the filename contains a restricted name on Windows. e.g., CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, etc.
fileName | The name of the file to be validated. |
bool open | ( | const std::string & | fileName, |
Operation | mode | ||
) |
Operation mode | ( | ) |
bool isMode | ( | Operation | isInMode | ) |
isInMode | The mode(s) to test against |
bool readMolecule | ( | Core::Molecule & | molecule | ) |
molecule | The molecule the data will be read into. |
bool writeMolecule | ( | const Core::Molecule & | molecule | ) |
molecule | The molecule the data will be written from. |
|
pure virtual |
in | The input file stream. |
molecule | The molecule the data will be read into. |
Implemented in CjsonFormat, CmlFormat, GromacsFormat, MdlFormat, MMTFFormat, PdbFormat, GAMESSUSOutput, GaussianCube, GaussianFchk, GenericOutput, MoldenFile, MopacAux, NWChemJson, NWChemLog, ORCAOutput, PoscarFormat, OutcarFormat, DcdFormat, LammpsTrajectoryFormat, LammpsDataFormat, TrrFormat, TurbomoleFormat, and XyzFormat.
|
pure virtual |
out | The output stream to write the data to. |
molecule | The contents of this molecule will be written to output. |
Implemented in PdbFormat, GAMESSUSOutput, GaussianFchk, GenericOutput, MoldenFile, MopacAux, NWChemLog, ORCAOutput, CjsonFormat, CmlFormat, GromacsFormat, MdlFormat, MMTFFormat, GaussianCube, NWChemJson, PoscarFormat, OutcarFormat, DcdFormat, LammpsTrajectoryFormat, LammpsDataFormat, TrrFormat, TurbomoleFormat, and XyzFormat.
bool readFile | ( | const std::string & | fileName, |
Core::Molecule & | molecule | ||
) |
fileName | The full path to the file to be read in. |
molecule | The molecule the data will be read into. |
bool writeFile | ( | const std::string & | fileName, |
const Core::Molecule & | molecule | ||
) |
fileName | The full path to the file to be written. |
molecule | The contents of this molecule will be written to the file. |
bool readString | ( | const std::string & | string, |
Core::Molecule & | molecule | ||
) |
string | The string containing the molecule file contents. |
molecule | The molecule the data will be read into. |
bool writeString | ( | std::string & | string, |
const Core::Molecule & | molecule | ||
) |
string | The string to write the contents of the molecule into. |
molecule | The contents of this molecule will be written to the string. |
std::string error | ( | ) | const |
std::string fileName | ( | ) | const |
void setOptions | ( | const std::string & | options | ) |
options | The options, each reader chooses how to use/interpret them. |
std::string options | ( | ) | const |
|
virtual |
Clear the format and reset all state.
|
pure virtual |
Create a new instance of the file format class. Ownership passes to the caller.
Implemented in CjsonFormat, CmlFormat, DcdFormat, GromacsFormat, LammpsTrajectoryFormat, LammpsDataFormat, MdlFormat, MMTFFormat, PdbFormat, TrrFormat, TurbomoleFormat, PoscarFormat, OutcarFormat, XyzFormat, GAMESSUSOutput, GaussianCube, GaussianFchk, GenericOutput, MoldenFile, MopacAux, NWChemJson, NWChemLog, and ORCAOutput.
|
pure virtual |
Implemented in CjsonFormat, CmlFormat, DcdFormat, GromacsFormat, LammpsTrajectoryFormat, LammpsDataFormat, MdlFormat, MMTFFormat, PdbFormat, TrrFormat, TurbomoleFormat, PoscarFormat, OutcarFormat, XyzFormat, GAMESSUSOutput, GaussianCube, GaussianFchk, GenericOutput, MoldenFile, MopacAux, NWChemJson, NWChemLog, and ORCAOutput.
|
pure virtual |
Implemented in CjsonFormat, CmlFormat, DcdFormat, GromacsFormat, LammpsTrajectoryFormat, LammpsDataFormat, MdlFormat, MMTFFormat, PdbFormat, TrrFormat, TurbomoleFormat, PoscarFormat, OutcarFormat, XyzFormat, GAMESSUSOutput, GaussianCube, GaussianFchk, GenericOutput, MoldenFile, MopacAux, NWChemJson, NWChemLog, and ORCAOutput.
|
pure virtual |
A description of the format, along with any relevant help text for users.
Implemented in CjsonFormat, CmlFormat, DcdFormat, GromacsFormat, LammpsTrajectoryFormat, LammpsDataFormat, MdlFormat, MMTFFormat, PdbFormat, TrrFormat, TurbomoleFormat, PoscarFormat, OutcarFormat, XyzFormat, GAMESSUSOutput, GaussianCube, GaussianFchk, GenericOutput, MoldenFile, MopacAux, NWChemJson, NWChemLog, and ORCAOutput.
|
pure virtual |
The URL of the format specification if available (relevant web page/wiki otherwise).
Implemented in CjsonFormat, CmlFormat, DcdFormat, GromacsFormat, LammpsTrajectoryFormat, LammpsDataFormat, MdlFormat, MMTFFormat, PdbFormat, TrrFormat, TurbomoleFormat, PoscarFormat, OutcarFormat, XyzFormat, GAMESSUSOutput, GaussianCube, GaussianFchk, GenericOutput, MoldenFile, MopacAux, NWChemJson, NWChemLog, and ORCAOutput.
|
pure virtual |
Implemented in CjsonFormat, CmlFormat, DcdFormat, GromacsFormat, LammpsTrajectoryFormat, LammpsDataFormat, MdlFormat, MMTFFormat, PdbFormat, TrrFormat, TurbomoleFormat, PoscarFormat, OutcarFormat, XyzFormat, GAMESSUSOutput, GaussianCube, GaussianFchk, GenericOutput, MoldenFile, MopacAux, NWChemJson, NWChemLog, and ORCAOutput.
|
pure virtual |
Implemented in CjsonFormat, CmlFormat, DcdFormat, GromacsFormat, LammpsTrajectoryFormat, LammpsDataFormat, MdlFormat, MMTFFormat, PdbFormat, TrrFormat, TurbomoleFormat, PoscarFormat, OutcarFormat, XyzFormat, GAMESSUSOutput, GaussianCube, GaussianFchk, GenericOutput, MoldenFile, MopacAux, NWChemJson, NWChemLog, and ORCAOutput.
|
protected |
errorString | The error to be added. |
newLine | Add a new line after the error string? |