![]() |
Mapper
0.9.0
API documentation
|
Base class for all importers. More...
#include <file_import_export.h>
Public Member Functions | |
Importer (const QString &path, Map *map, MapView *view) | |
Creates a new Importer with the given input path, map, and view. More... | |
~Importer () override | |
Destroys this Importer. More... | |
bool | loadSymbolsOnly () const noexcept |
Returns true if only symbols (and colors) are to be imported. More... | |
void | setLoadSymbolsOnly (bool value) |
If set to true, importers shall import only symbols (and colors). More... | |
bool | doImport () |
Imports the map and view. More... | |
![]() | |
ImportExport (QIODevice *device=nullptr) | |
Creates a new importer or exporter with the given IO device. More... | |
ImportExport (const ImportExport &)=delete | |
ImportExport (ImportExport &&)=delete | |
virtual | ~ImportExport () |
Destroys an importer or exporter. More... | |
virtual bool | supportsQIODevice () const noexcept |
Returns true when the importer/exporter supports QIODevice. More... | |
QIODevice * | device () const noexcept |
Returns the input device if it has been set or created. More... | |
void | setDevice (QIODevice *device) |
Sets a custom input device to be used for import. More... | |
void | setOption (const QString &name, const QVariant &value) |
Sets an option in this importer or exporter. More... | |
QVariant | option (const QString &name) const |
Retrieves the value of an option in this instance. More... | |
void | addWarning (const QString &str) |
Adds a string to the current list of warnings. More... | |
const std::vector< QString > & | warnings () const noexcept |
Returns the current list of warnings collected by this object. More... | |
Protected Member Functions | |
virtual void | prepare () |
Event handler called from doImport() to prepare the import process. More... | |
virtual bool | importImplementation ()=0 |
Actual implementation of the import. More... | |
virtual void | validate () |
Event handler called from doImport() to complete to postprocess imported data. More... | |
virtual void | importFailed () |
Event handler called from doImport() to complete to cleanup a failed import attempt. More... | |
Protected Attributes | |
const QString | path |
The input path. More... | |
Map *const | map |
The Map to import or export. More... | |
MapView *const | view |
The MapView to import or export. More... | |
Base class for all importers.
An Importer has the following lifecycle:
Creates a new Importer with the given input path, map, and view.
|
overridedefault |
Destroys this Importer.
bool OpenOrienteering::Importer::doImport | ( | ) |
Imports the map and view.
This is the function which is normally called to perform import. It must return false on errors and true on success. All error and warning messages must be logged in ImportExport::warnings()
.
In case of an error, the last warning can be assumed to be the error message. (The list of warnings won't be empty then.)
If the importer supports input from QIODevice, this function will open a QFile with the given path and make it available via device().
|
protectedvirtual |
Event handler called from doImport() to complete to cleanup a failed import attempt.
Overriding functions must call the the default implementation.
|
protectedpure virtual |
Actual implementation of the import.
This function shall read the input and populate the map and view from it. Importers which support input from QIODevice should use the device(). They must not open or close this device.
If information might be lost in the process, a message shall be recorded by calling addWarning() with a translated, useful description of the issue. If a fatal error is encountered, then this method may either throw an exception, or log an error message with addWarning() and return false. The line between errors and warnings is somewhat of a judgement call on the part of the author, but generally an Importer should not succeed unless the map is populated sufficiently to be useful.
Implemented in OpenOrienteering::OgrFileImport, OpenOrienteering::OcdFileImport, OpenOrienteering::OcdFileImport, OpenOrienteering::XMLFileImporter, and OpenOrienteering::OCAD8FileImport.
|
inlinenoexcept |
Returns true if only symbols (and colors) are to be imported.
|
protectedvirtual |
Event handler called from doImport() to prepare the import process.
This function is called only when opening the input succeeded. However, the input is not passed to this function by intention: It is meant to be used also by importers which do not use QIODevice.
Overriding functions must call the the default implementation.
void OpenOrienteering::Importer::setLoadSymbolsOnly | ( | bool | value | ) |
If set to true, importers shall import only symbols (and colors).
|
protectedvirtual |
Event handler called from doImport() to complete to postprocess imported data.
Overriding functions must call the the default implementation early. It validates the object and symbols, and looks for templates. It may throw FileFormatException.
|
protected |
The input path.