Skip to content
Permalink
Browse files

SIP wrappers for QgsProviderMetadata

  • Loading branch information
elpaso committed Apr 19, 2018
1 parent 9d66eb8 commit 839a88903896441d09664bbf49bb36114d72a81f
Showing with 90 additions and 1 deletion.
  1. +48 −0 python/core/auto_generated/qgsprovidermetadata.sip.in
  2. +42 −1 src/core/qgsprovidermetadata.h
@@ -36,6 +36,54 @@ library object.

QgsProviderMetadata( const QString &_key, const QString &_description, const QString &_library );

QgsProviderMetadata( const QString &key, const QString &description, SIP_PYCALLABLE / AllowNone / );
%Docstring
Metadata for provider with direct provider creation function pointer, where
no library is involved.

.. versionadded:: 3.0

.. note::

not available in Python bindings
%End
%MethodCode

// Make sure the callable doesn't get garbage collected
Py_INCREF( a2 );

Py_BEGIN_ALLOW_THREADS

sipCpp = new QgsProviderMetadata( *a0, *a1, [a2]( const QString &dataSource ) -> QgsDataProvider*
{
QgsDataProvider *provider;
provider = nullptr;
PyObject *sipResObj;
SIP_BLOCK_THREADS

sipResObj = sipCallMethod( NULL, a2, "N", new QString( dataSource ), sipType_QString, NULL );
Py_DECREF( a2 );
if ( sipResObj )
{
// Py_DECREF(sipResObj);
if ( sipCanConvertToType( sipResObj, sipType_QgsDataProvider, SIP_NOT_NONE ) )
{
int state0;
int sipIsErr = 0;
provider = reinterpret_cast<QgsDataProvider *>( sipConvertToType( sipResObj, sipType_QgsDataProvider, NULL, SIP_NOT_NONE, &state0, &sipIsErr ) );
if ( sipIsErr != 0 )
{
provider = nullptr;
}
}
}
SIP_UNBLOCK_THREADS
return provider;
} );

Py_END_ALLOW_THREADS

%End

QString key() const;
%Docstring
@@ -61,7 +61,48 @@ class CORE_EXPORT QgsProviderMetadata
* \note not available in Python bindings
* \since QGIS 3.0
*/
SIP_SKIP QgsProviderMetadata( const QString &key, const QString &description, const QgsProviderMetadata::CreateDataProviderFunction &createFunc );
#ifndef SIP_RUN
QgsProviderMetadata( const QString &key, const QString &description, const QgsProviderMetadata::CreateDataProviderFunction &createFunc );
#else
QgsProviderMetadata( const QString &key, const QString &description, SIP_PYCALLABLE / AllowNone / );
% MethodCode

// Make sure the callable doesn't get garbage collected
Py_INCREF( a2 );

Py_BEGIN_ALLOW_THREADS

sipCpp = new QgsProviderMetadata( *a0, *a1, [a2]( const QString &dataSource ) -> QgsDataProvider*
{
QgsDataProvider *provider;
provider = nullptr;
PyObject *sipResObj;
SIP_BLOCK_THREADS

sipResObj = sipCallMethod( NULL, a2, "N", new QString( dataSource ), sipType_QString, NULL );
Py_DECREF( a2 );
if ( sipResObj )
{
// Py_DECREF(sipResObj);
if ( sipCanConvertToType( sipResObj, sipType_QgsDataProvider, SIP_NOT_NONE ) )
{
int state0;
int sipIsErr = 0;
provider = reinterpret_cast<QgsDataProvider *>( sipConvertToType( sipResObj, sipType_QgsDataProvider, NULL, SIP_NOT_NONE, &state0, &sipIsErr ) );
if ( sipIsErr != 0 )
{
provider = nullptr;
}
}
}
SIP_UNBLOCK_THREADS
return provider;
} );

Py_END_ALLOW_THREADS

% End
#endif

/**
* This returns the unique key associated with the provider

0 comments on commit 839a889

Please sign in to comment.
You can’t perform that action at this time.