![]() |
Mapper
0.9.0
API documentation
|
Provides a registry for file formats, and takes ownership of the supported format objects. More...
#include <file_format_registry.h>
Public Member Functions | |
FileFormatRegistry () noexcept | |
Creates an empty file format registry. More... | |
FileFormatRegistry (const FileFormatRegistry &)=delete | |
~FileFormatRegistry () | |
Destroys a file format registry. More... | |
FileFormatRegistry & | operator= (const FileFormatRegistry &)=delete |
const std::vector< FileFormat * > & | formats () const |
Returns an immutable list of the available file formats. More... | |
const FileFormat * | findFormat (std::function< bool(const FileFormat *)> predicate) const |
Finds a file format which satisfies the given predicate, or returns nullptr if no format is found. More... | |
const FileFormat * | findFormat (const char *id) const |
Finds a file format with the given internal ID, or returns nullptr if no format is found. More... | |
const FileFormat * | findFormatByFilter (const QString &filter, bool(FileFormat::*predicate)() const) const |
Finds a file format which implements the given filter, or returns nullptr if no format is found. More... | |
const FileFormat * | findFormatForFilename (const QString &filename, bool(FileFormat::*predicate)() const) const |
Finds a file format whose file extension matches the file extension of the given path, or returns nullptr if no matching format is found. More... | |
const FileFormat * | findFormatForData (const QString &path, FileFormat::FileTypes types) const |
Finds an import file format by looking at the existing data. More... | |
const char * | defaultFormat () const |
Returns the ID of default file format for this registry. More... | |
void | registerFormat (FileFormat *format) |
Registers a new file format. More... | |
std::unique_ptr< FileFormat > | unregisterFormat (const FileFormat *format) |
Unregisters a file format. More... | |
std::unique_ptr< Importer > | makeImporter (const QString &path, Map &map, MapView *view=nullptr) |
Creates an importer for the given path, if possible. More... | |
std::unique_ptr< Exporter > | makeExporter (const QString &path, const Map *map, const MapView *view) |
Creates an exporter for the given path, if possible. More... | |
Provides a registry for file formats, and takes ownership of the supported format objects.
|
noexcept |
Creates an empty file format registry.
|
delete |
OpenOrienteering::FileFormatRegistry::~FileFormatRegistry | ( | ) |
Destroys a file format registry.
|
inline |
Returns the ID of default file format for this registry.
This will automatically be set to the first registered format.
const FileFormat * OpenOrienteering::FileFormatRegistry::findFormat | ( | std::function< bool(const FileFormat *)> | predicate | ) | const |
Finds a file format which satisfies the given predicate, or returns nullptr if no format is found.
const FileFormat * OpenOrienteering::FileFormatRegistry::findFormat | ( | const char * | id | ) | const |
Finds a file format with the given internal ID, or returns nullptr if no format is found.
const FileFormat * OpenOrienteering::FileFormatRegistry::findFormatByFilter | ( | const QString & | filter, |
bool(FileFormat::*)() const | predicate | ||
) | const |
Finds a file format which implements the given filter, or returns nullptr if no format is found.
Only the file format's filter string before the closing ')' is taken into account for matching, i.e. the given parameter 'filter' may contain additional extensions following the original ones.
The predicate is intended to select either import or export formats.
const FileFormat * OpenOrienteering::FileFormatRegistry::findFormatForData | ( | const QString & | path, |
FileFormat::FileTypes | types | ||
) | const |
Finds an import file format by looking at the existing data.
const FileFormat * OpenOrienteering::FileFormatRegistry::findFormatForFilename | ( | const QString & | filename, |
bool(FileFormat::*)() const | predicate | ||
) | const |
Finds a file format whose file extension matches the file extension of the given path, or returns nullptr if no matching format is found.
The predicate is intended to select either import or export formats.
|
inline |
Returns an immutable list of the available file formats.
std::unique_ptr< Exporter > OpenOrienteering::FileFormatRegistry::makeExporter | ( | const QString & | path, |
const Map * | map, | ||
const MapView * | view | ||
) |
Creates an exporter for the given path, if possible.
std::unique_ptr< Importer > OpenOrienteering::FileFormatRegistry::makeImporter | ( | const QString & | path, |
Map & | map, | ||
MapView * | view = nullptr |
||
) |
Creates an importer for the given path, if possible.
|
delete |
void OpenOrienteering::FileFormatRegistry::registerFormat | ( | FileFormat * | format | ) |
Registers a new file format.
The registry takes ownership of the provided Format.
std::unique_ptr< FileFormat > OpenOrienteering::FileFormatRegistry::unregisterFormat | ( | const FileFormat * | format | ) |
Unregisters a file format.
Returns a non-const pointer to the file format and transfers ownership to the caller.