Skip to content
Permalink
Browse files

Port conversion to/from script code to c++

  • Loading branch information
nyalldawson committed Jun 26, 2017
1 parent 178a415 commit d16f117b6c752435600a7c5ce9121c6b10418bec
@@ -553,6 +553,20 @@ class QgsProcessingParameters
:rtype: QgsProcessingParameterDefinition
%End

static QString descriptionFromName( const QString &name );
%Docstring
Creates an autogenerated parameter description from a parameter ``name``.
:rtype: str
%End

static QgsProcessingParameterDefinition *parameterFromScriptCode( const QString &code ) /Factory/;
%Docstring
Creates a new QgsProcessingParameterDefinition using the configuration from a
supplied script ``code`` string.
The caller takes responsibility for deleting the returned object.
:rtype: QgsProcessingParameterDefinition
%End

};


@@ -580,6 +594,12 @@ class QgsProcessingParameterBoolean : QgsProcessingParameterDefinition

virtual QString asScriptCode() const;


static QgsProcessingParameterBoolean *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterBoolean
%End
};

class QgsProcessingParameterCrs : QgsProcessingParameterDefinition
@@ -605,6 +625,13 @@ class QgsProcessingParameterCrs : QgsProcessingParameterDefinition

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;


static QgsProcessingParameterCrs *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterCrs
%End

};

class QgsProcessingParameterMapLayer : QgsProcessingParameterDefinition
@@ -630,6 +657,13 @@ class QgsProcessingParameterMapLayer : QgsProcessingParameterDefinition

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;


static QgsProcessingParameterMapLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterMapLayer
%End

};

class QgsProcessingParameterExtent : QgsProcessingParameterDefinition
@@ -656,6 +690,12 @@ class QgsProcessingParameterExtent : QgsProcessingParameterDefinition
virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;


static QgsProcessingParameterExtent *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterExtent
%End

};


@@ -681,6 +721,12 @@ class QgsProcessingParameterPoint : QgsProcessingParameterDefinition
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;


static QgsProcessingParameterPoint *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterPoint
%End

};

class QgsProcessingParameterFile : QgsProcessingParameterDefinition
@@ -744,6 +790,12 @@ class QgsProcessingParameterFile : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterFile *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition, Behavior behavior = File ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterFile
%End

};

class QgsProcessingParameterMatrix : QgsProcessingParameterDefinition
@@ -822,6 +874,12 @@ class QgsProcessingParameterMatrix : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterMatrix *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterMatrix
%End

};

class QgsProcessingParameterMultipleLayers : QgsProcessingParameterDefinition
@@ -884,6 +942,12 @@ class QgsProcessingParameterMultipleLayers : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterMultipleLayers *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterMultipleLayers
%End

};

class QgsProcessingParameterNumber : QgsProcessingParameterDefinition
@@ -965,6 +1029,12 @@ class QgsProcessingParameterNumber : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterNumber *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterNumber
%End

};

class QgsProcessingParameterRange : QgsProcessingParameterDefinition
@@ -1011,6 +1081,12 @@ class QgsProcessingParameterRange : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterRange *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterRange
%End

};

class QgsProcessingParameterRasterLayer : QgsProcessingParameterDefinition
@@ -1037,6 +1113,12 @@ class QgsProcessingParameterRasterLayer : QgsProcessingParameterDefinition
virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;


static QgsProcessingParameterRasterLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterRasterLayer
%End

};

class QgsProcessingParameterEnum : QgsProcessingParameterDefinition
@@ -1064,6 +1146,8 @@ class QgsProcessingParameterEnum : QgsProcessingParameterDefinition

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asScriptCode() const;


QStringList options() const;
%Docstring
@@ -1096,6 +1180,12 @@ class QgsProcessingParameterEnum : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterEnum *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterEnum
%End

};

class QgsProcessingParameterString : QgsProcessingParameterDefinition
@@ -1120,6 +1210,8 @@ class QgsProcessingParameterString : QgsProcessingParameterDefinition
virtual QString type() const;
virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asScriptCode() const;


bool multiLine() const;
%Docstring
@@ -1139,6 +1231,12 @@ class QgsProcessingParameterString : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterString *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterString
%End

};

class QgsProcessingParameterExpression : QgsProcessingParameterDefinition
@@ -1182,6 +1280,12 @@ class QgsProcessingParameterExpression : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterExpression *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterExpression
%End

};

class QgsProcessingParameterVectorLayer : QgsProcessingParameterDefinition
@@ -1209,6 +1313,12 @@ class QgsProcessingParameterVectorLayer : QgsProcessingParameterDefinition
virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;


static QgsProcessingParameterVectorLayer *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterVectorLayer
%End

};

class QgsProcessingParameterField : QgsProcessingParameterDefinition
@@ -1245,6 +1355,8 @@ class QgsProcessingParameterField : QgsProcessingParameterDefinition

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asScriptCode() const;


QString parentLayerParameter() const;
%Docstring
@@ -1290,6 +1402,12 @@ class QgsProcessingParameterField : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterField *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterField
%End

};

class QgsProcessingParameterFeatureSource : QgsProcessingParameterDefinition
@@ -1316,6 +1434,8 @@ class QgsProcessingParameterFeatureSource : QgsProcessingParameterDefinition

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asScriptCode() const;


QList< int > dataTypes() const;
%Docstring
@@ -1335,6 +1455,12 @@ class QgsProcessingParameterFeatureSource : QgsProcessingParameterDefinition
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterFeatureSource *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterFeatureSource
%End

};

class QgsProcessingDestinationParameter : QgsProcessingParameterDefinition
@@ -1427,6 +1553,8 @@ class QgsProcessingParameterFeatureSink : QgsProcessingDestinationParameter

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asScriptCode() const;

virtual QgsProcessingOutputDefinition *toOutputDefinition() const /Factory/;

virtual QString defaultFileExtension() const;
@@ -1459,6 +1587,12 @@ class QgsProcessingParameterFeatureSink : QgsProcessingDestinationParameter
virtual QString generateTemporaryDestination() const;


static QgsProcessingParameterFeatureSink *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterFeatureSink
%End

};


@@ -1486,6 +1620,8 @@ class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QString asScriptCode() const;

virtual QgsProcessingOutputDefinition *toOutputDefinition() const /Factory/;

virtual QString defaultFileExtension() const;
@@ -1516,6 +1652,13 @@ class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterVectorOutput *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterVectorOutput
%End


};

class QgsProcessingParameterRasterOutput : QgsProcessingDestinationParameter
@@ -1546,6 +1689,12 @@ class QgsProcessingParameterRasterOutput : QgsProcessingDestinationParameter

virtual QString defaultFileExtension() const;


static QgsProcessingParameterRasterOutput *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterRasterOutput
%End
};

class QgsProcessingParameterFileOutput : QgsProcessingDestinationParameter
@@ -1596,6 +1745,13 @@ class QgsProcessingParameterFileOutput : QgsProcessingDestinationParameter
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterFileOutput *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterFileOutput
%End


};

class QgsProcessingParameterFolderOutput : QgsProcessingDestinationParameter
@@ -1625,6 +1781,12 @@ class QgsProcessingParameterFolderOutput : QgsProcessingDestinationParameter
virtual QString defaultFileExtension() const;


static QgsProcessingParameterFolderOutput *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterFolderOutput
%End

};


@@ -42,8 +42,7 @@
from processing.core.parameters import (Parameter,
ParameterNumber,
ParameterExtent,
_splitParameterOptions,
_createDescriptiveName)
_splitParameterOptions)
from processing.core.outputs import OutputRaster

pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
@@ -105,7 +104,7 @@ def getAsScriptCode(self):
@classmethod
def fromScriptCode(self, line):
isOptional, name, definition = _splitParameterOptions(line)
descName = _createDescriptiveName(name)
descName = QgsProcessingParameters.descriptionFromName(name)
parent = definition.lower().strip()[len('interpolation data') + 1:]
return ParameterInterpolationData(name, descName, parent)

0 comments on commit d16f117

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