16 #ifndef QGSPATHRESOLVER_H
17 #define QGSPATHRESOLVER_H
19 #include "qgis_core.h"
34 explicit QgsPathResolver(
const QString &baseFileName = QString(),
const QString &attachmentDir = QString() );
41 QString writePath(
const QString &filename )
const;
44 QString readPath(
const QString &filename )
const;
66 static QString setPathPreprocessor(
const std::function< QString(
const QString &filename )> &processor );
112 static QString setPathPreprocessor( SIP_PYCALLABLE / AllowNone / );
117 Py_BEGIN_ALLOW_THREADS
122 PyObject *s = sipCallMethod( NULL, a0,
"D", &arg, sipType_QString, NULL );
125 QString *t1 =
reinterpret_cast<QString *
>( sipConvertToType( s, sipType_QString, 0, SIP_NOT_NONE, &state, &sipIsError ) );
126 if ( sipIsError == 0 )
128 res = QString( *t1 );
130 sipReleaseType( t1, sipType_QString, state );
136 s = sipConvertFromNewType(
new QString(
id ), sipType_QString, 0 );
153 static bool removePathPreprocessor(
const QString &
id );
166 static void removePathPreprocessor(
const QString &
id );
170 PyErr_SetString( PyExc_KeyError, QStringLiteral(
"No processor with id %1 exists." ).arg( *a0 ).toUtf8().constData() );
197 static QString setPathWriter(
const std::function< QString(
const QString &filename )> &writer );
223 static QString setPathWriter( SIP_PYCALLABLE / AllowNone / );
228 Py_BEGIN_ALLOW_THREADS
233 PyObject *s = sipCallMethod( NULL, a0,
"D", &arg, sipType_QString, NULL );
236 QString *t1 =
reinterpret_cast<QString *
>( sipConvertToType( s, sipType_QString, 0, SIP_NOT_NONE, &state, &sipIsError ) );
237 if ( sipIsError == 0 )
239 res = QString( *t1 );
241 sipReleaseType( t1, sipType_QString, state );
247 s = sipConvertFromNewType(
new QString(
id ), sipType_QString, 0 );
263 static bool removePathWriter(
const QString &
id );
275 static void removePathWriter(
const QString &
id );
279 PyErr_SetString( PyExc_KeyError, QStringLiteral(
"No writer with id %1 exists." ).arg( *a0 ).toUtf8().constData() );
287 QString mBaseFileName;
289 QString mAttachmentDir;
Resolves relative paths into absolute paths and vice versa.
static bool removePathPreprocessor(const QString &id)
Removes the custom pre-processor function with matching id.
static QString setPathPreprocessor(const std::function< QString(const QString &filename)> &processor)
Sets a path pre-processor function, which allows for manipulation of paths and data sources prior to ...
static bool removePathWriter(const QString &id)
Removes the custom writer function with matching id.
static QString setPathWriter(const std::function< QString(const QString &filename)> &writer)
Sets a path writer function, which allows for manipulation of paths and data sources prior to writing...