AvogadroLibs 1.97.0
|
Class to manage registration, searching and creation of file formats. More...
#include <fileformatmanager.h>
Public Member Functions | |
bool | readFile (Core::Molecule &molecule, const std::string &fileName, const std::string &fileExtension=std::string(), const std::string &options=std::string()) const |
bool | writeFile (const Core::Molecule &molecule, const std::string &fileName, const std::string &fileExtension=std::string(), const std::string &options=std::string()) const |
bool | readString (Core::Molecule &molecule, const std::string &string, const std::string &fileExtension, const std::string &options=std::string()) const |
bool | writeString (const Core::Molecule &molecule, std::string &string, const std::string &fileExtension, const std::string &options=std::string()) const |
bool | addFormat (FileFormat *format) |
bool | removeFormat (const std::string &identifier) |
FileFormat * | newFormatFromIdentifier (const std::string &identifier, FileFormat::Operations filter=FileFormat::None) const |
FileFormat * | newFormatFromMimeType (const std::string &mimeType, FileFormat::Operations filter=FileFormat::None) const |
FileFormat * | newFormatFromFileExtension (const std::string &extension, FileFormat::Operations filter=FileFormat::None) const |
std::vector< std::string > | identifiers (FileFormat::Operations filter=FileFormat::None) const |
std::vector< std::string > | mimeTypes (FileFormat::Operations filter=FileFormat::None) const |
std::vector< std::string > | fileExtensions (FileFormat::Operations filter=FileFormat::None) const |
std::vector< const FileFormat * > | fileFormats (FileFormat::Operations filter=FileFormat::None) const |
std::vector< const FileFormat * > | fileFormatsFromMimeType (const std::string &mimeType, FileFormat::Operations filter=FileFormat::None) const |
std::vector< const FileFormat * > | fileFormatsFromFileExtension (const std::string &extension, FileFormat::Operations filter=FileFormat::None) const |
std::string | error () const |
Static Public Member Functions | |
static FileFormatManager & | instance () |
static bool | registerFormat (FileFormat *format) |
Register a new file format with the format manager. More... | |
static bool | unregisterFormat (const std::string &identifier) |
Unregister a file format from the format manager. More... | |
<avogadro/io/fileformatmanager.h>
The file format manager is a singleton class that handles the runtime registration, search, creation and eventual destruction of file formats. It can be used to gain a listing of available formats, register new formats and retrieve the correct format to facilitate file IO.
All files IO can take place independent of this manager, but for automated registration and look up this is the preferred API. It is possible to use the convenience API without ever dealing directly with a format class.
|
static |
Get the singleton instance of the file format manager. This instance should not be deleted.
bool readFile | ( | Core::Molecule & | molecule, |
const std::string & | fileName, | ||
const std::string & | fileExtension = std::string() , |
||
const std::string & | options = std::string() |
||
) | const |
Load molecule
with the fileName
contents supplied, inferring the fileExtension
if it is empty. The options
can be used to modify the behavior of the file format.
bool writeFile | ( | const Core::Molecule & | molecule, |
const std::string & | fileName, | ||
const std::string & | fileExtension = std::string() , |
||
const std::string & | options = std::string() |
||
) | const |
Write molecule
to the fileName
supplied, inferring the fileExtension
if it is empty. The options
can be used to modify the behavior of the file format.
bool readString | ( | Core::Molecule & | molecule, |
const std::string & | string, | ||
const std::string & | fileExtension, | ||
const std::string & | options = std::string() |
||
) | const |
Load molecule
with the contents of string
, using the supplied fileExtension
to determine the format. The options
can be used to modify the behavior of the file format.
bool writeString | ( | const Core::Molecule & | molecule, |
std::string & | string, | ||
const std::string & | fileExtension, | ||
const std::string & | options = std::string() |
||
) | const |
Write molecule
to the string
, using the supplied fileExtension
to determine the format. The options
can be used to modify the behavior of the file format.
|
static |
format | An instance of the format to manage, the manager assumes ownership of the object passed in. |
|
static |
identifier | The identifier for the format to remove. |
bool addFormat | ( | FileFormat * | format | ) |
Add the supplied format
to the manager, registering its ID, MIME type, file extension and other relevant data for later lookup. The manager assumes ownership of the supplied object.
bool removeFormat | ( | const std::string & | identifier | ) |
Remove the format with the identifier identifier from the manager.
FileFormat * newFormatFromIdentifier | ( | const std::string & | identifier, |
FileFormat::Operations | filter = FileFormat::None |
||
) | const |
New instance of the format for the specified identifier
. Ownership is passed to the caller.
identifier | The unique identifier of the format. |
filter | Bitwise combination of FileFormat::Operation values that represents the minimum required capabilities. |
FileFormat * newFormatFromMimeType | ( | const std::string & | mimeType, |
FileFormat::Operations | filter = FileFormat::None |
||
) | const |
New instance of the format for the specified mimeType
. Ownership is passed to the caller.
mimeType | The MIME type (in lower case). |
filter | Bitwise combination of FileFormat::Operation values that represents the minimum required capabilities. |
FileFormat * newFormatFromFileExtension | ( | const std::string & | extension, |
FileFormat::Operations | filter = FileFormat::None |
||
) | const |
New instance of the format for the specified file extension
. Ownership is passed to the caller.
extension | The file extension (in lower case). |
filter | Bitwise combination of FileFormat::Operation values that represents the minimum required capabilities. |
std::vector< std::string > identifiers | ( | FileFormat::Operations | filter = FileFormat::None | ) | const |
Get a list of all loaded identifiers, optionally matching the specified filter.
filter | Bitwise combination of FileFormat::Operation values that represents the minimum required capabilities. |
std::vector< std::string > mimeTypes | ( | FileFormat::Operations | filter = FileFormat::None | ) | const |
Get a list of all loaded MIME types, optionally matching the specified filter.
filter | Bitwise combination of FileFormat::Operation values that represents the minimum required capabilities. |
std::vector< std::string > fileExtensions | ( | FileFormat::Operations | filter = FileFormat::None | ) | const |
Get a list of the file extensions supported, optionally matching the specified filter.
filter | Bitwise combination of FileFormat::Operation values that represents the minimum required capabilities. |
std::vector< const FileFormat * > fileFormats | ( | FileFormat::Operations | filter = FileFormat::None | ) | const |
Get a list of known FileFormat objects, optionally matching the specified filter.
filter | Bitwise combination of FileFormat::Operation values that represents the minimum required capabilities. |
std::vector< const FileFormat * > fileFormatsFromMimeType | ( | const std::string & | mimeType, |
FileFormat::Operations | filter = FileFormat::None |
||
) | const |
Get a list of known FileFormat objects that handle the specified MIME type, optionally matching a filter.
mimeType | MIME type. |
filter | Bitwise combination of FileFormat::Operation values that represents the minimum required capabilities. |
std::vector< const FileFormat * > fileFormatsFromFileExtension | ( | const std::string & | extension, |
FileFormat::Operations | filter = FileFormat::None |
||
) | const |
Get a list of known FileFormat objects that handle the specified file extension, optionally matching a filter.
extension | File extension. |
filter | Bitwise combination of FileFormat::Operation values that represents the minimum required capabilities. |
std::string error | ( | ) | const |
Get any errors that have been logged when loading formats.