![]() |
Mapper
0.9.0
API documentation
|
Base class for all exporters. More...
#include <file_import_export.h>
Public Member Functions | |
Exporter (const QString &path, const Map *map, const MapView *view) | |
Creates a new Exporter with the given path, map, and view. More... | |
~Exporter () override | |
Destroys the current Exporter. More... | |
bool | doExport () |
Exports 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 bool | exportImplementation ()=0 |
Actual implementation of the export. More... | |
Protected Attributes | |
const QString | path |
The output path. More... | |
const Map *const | map |
The Map to import or export. More... | |
const MapView *const | view |
The MapView to import or export. More... | |
Base class for all exporters.
An Exporter has the following lifecycle:
|
inline |
Creates a new Exporter with the given path, map, and view.
|
overridedefault |
Destroys the current Exporter.
bool OpenOrienteering::Exporter::doExport | ( | ) |
Exports the map and view.
This function calls exportImplementation() and catches exceptions thrown there. It returns false on errors and true on success. All error and warning messages are 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 exporter supports input from QIODevice but a device hasn't been set yet, this function will open a QSaveFile with the given path, make it available via device(), and commit the changes if exportImplementation() returns successfully.
|
protectedpure virtual |
Actual implementation of the export.
Exporters which support input from QIODevice shall use the device(). They must not open or close the device.
If information might be lost in the export, 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.
There is no default implementation.
Implemented in OpenOrienteering::OgrFileExport, OpenOrienteering::OCAD8FileExport, OpenOrienteering::OcdFileExport, OpenOrienteering::OcdFileExport, and OpenOrienteering::XMLFileExporter.
|
protected |
The output path.