Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add doc for QgsServerParameterDefinition
  • Loading branch information
pblottiere committed Jul 23, 2018
1 parent edeac1d commit fb75580
Show file tree
Hide file tree
Showing 2 changed files with 207 additions and 7 deletions.
118 changes: 111 additions & 7 deletions python/server/auto_generated/qgsserverparameters.sip.in
Expand Up @@ -12,41 +12,145 @@
class QgsServerParameterDefinition
{
%Docstring
*************************************************************************
Definition of a parameter with basic conversion methods

This program is free software; you can redistribute it and/or modify *
it under the terms of the GNU General Public License as published by *
the Free Software Foundation; either version 2 of the License, or *
(at your option) any later version. *

**************************************************************************
.. versionadded:: 3.4
%End

%TypeHeaderCode
#include "qgsserverparameters.h"
%End
public:

QgsServerParameterDefinition( const QVariant::Type type = QVariant::String,
const QVariant defaultValue = QVariant( "" ) );
%Docstring
Constructor for QgsServerParameterDefinition.

:param type: The type of the parameter
:param defaultValue: The default value of the parameter
%End

virtual ~QgsServerParameterDefinition();

QString typeName() const;
%Docstring
Returns the type of the parameter as a string.
%End

virtual bool isValid() const;
%Docstring
Returns true if the parameter is valid, false otherwise.
%End

QString toString() const;
%Docstring
Converts the parameter into a string.
%End

QStringList toStringList( char delimiter = ',' ) const;
%Docstring
Converts the parameter into a list of strings.

:param delimiter: The character used for delimiting

:return: A list of strings
%End

QList<int> toIntList( bool &ok, char delimiter = ',' ) const;
%Docstring
Converts the parameter into a list of integers.

:param ok: True if there's no error during the conversion, false otherwise
:param delimiter: The character used for delimiting

:return: A list of integers
%End

QList<double> toDoubleList( bool &ok, char delimiter = ',' ) const;
%Docstring
Converts the parameter into a list of doubles.

:param ok: True if there's no error during the conversion, false otherwise
:param delimiter: The character used for delimiting

:return: A list of doubles
%End

QList<QColor> toColorList( bool &ok, char delimiter = ',' ) const;
%Docstring
Converts the parameter into a list of colors.

:param ok: True if there's no error during the conversion, false otherwise
:param delimiter: The character used for delimiting

:return: A list of colors
%End

QList<QgsGeometry> toGeomList( bool &ok, char delimiter = ',' ) const;
%Docstring
Converts the parameter into a list of geometries.

:param ok: True if there's no error during the conversion, false otherwise
:param delimiter: The character used for delimiting

:return: A list of geometries
%End

QgsRectangle toRectangle( bool &ok ) const;
%Docstring
Converts the parameter into a rectangle.

:param ok: True if there's no error during the conversion, false otherwise

:return: A rectangle
%End

int toInt( bool &ok ) const;
%Docstring
Converts the parameter into an integer.

:param ok: True if there's no error during the conversion, false otherwise

:return: An integer
%End

double toDouble( bool &ok ) const;
%Docstring
Converts the parameter into a double.

:param ok: True if there's no error during the conversion, false otherwise

:return: A double
%End

bool toBool() const;
%Docstring
Converts the parameter into a boolean.

:param ok: True if there's no error during the conversion, false otherwise
:param delimiter: The character used for delimiting

:return: A boolean
%End

QColor toColor( bool &ok ) const;
%Docstring
Converts the parameter into a color.

:param ok: True if there's no error during the conversion, false otherwise
:param delimiter: The character used for delimiting

:return: A color
%End

static void raiseError( const QString &msg );
%Docstring
Raises an exception in case of an invalid parameters.

:param msg: The message describing the exception
\throws QgsBadRequestException Invalid parameter exception
%End

QVariant::Type mType;
QVariant mValue;
Expand Down
96 changes: 96 additions & 0 deletions src/server/qgsserverparameters.h
Expand Up @@ -26,29 +26,125 @@
#include "qgsgeometry.h"
#include "qgis_server.h"

/**
* \ingroup server
* \class QgsServerParameterDefinition
* \brief Definition of a parameter with basic conversion methods
* \since QGIS 3.4
*/
class SERVER_EXPORT QgsServerParameterDefinition
{
public:

/**
* Constructor for QgsServerParameterDefinition.
* \param type The type of the parameter
* \param defaultValue The default value of the parameter
*/
QgsServerParameterDefinition( const QVariant::Type type = QVariant::String,
const QVariant defaultValue = QVariant( "" ) );

/**
* Default destructor for QgsServerParameterDefinition.
*/
virtual ~QgsServerParameterDefinition() = default;

/**
* Returns the type of the parameter as a string.
*/
QString typeName() const;

/**
* Returns true if the parameter is valid, false otherwise.
*/
virtual bool isValid() const;

/**
* Converts the parameter into a string.
*/
QString toString() const;

/**
* Converts the parameter into a list of strings.
* \param delimiter The character used for delimiting
* \returns A list of strings
*/
QStringList toStringList( char delimiter = ',' ) const;

/**
* Converts the parameter into a list of integers.
* \param ok True if there's no error during the conversion, false otherwise
* \param delimiter The character used for delimiting
* \returns A list of integers
*/
QList<int> toIntList( bool &ok, char delimiter = ',' ) const;

/**
* Converts the parameter into a list of doubles.
* \param ok True if there's no error during the conversion, false otherwise
* \param delimiter The character used for delimiting
* \returns A list of doubles
*/
QList<double> toDoubleList( bool &ok, char delimiter = ',' ) const;

/**
* Converts the parameter into a list of colors.
* \param ok True if there's no error during the conversion, false otherwise
* \param delimiter The character used for delimiting
* \returns A list of colors
*/
QList<QColor> toColorList( bool &ok, char delimiter = ',' ) const;

/**
* Converts the parameter into a list of geometries.
* \param ok True if there's no error during the conversion, false otherwise
* \param delimiter The character used for delimiting
* \returns A list of geometries
*/
QList<QgsGeometry> toGeomList( bool &ok, char delimiter = ',' ) const;

/**
* Converts the parameter into a rectangle.
* \param ok True if there's no error during the conversion, false otherwise
* \returns A rectangle
*/
QgsRectangle toRectangle( bool &ok ) const;

/**
* Converts the parameter into an integer.
* \param ok True if there's no error during the conversion, false otherwise
* \returns An integer
*/
int toInt( bool &ok ) const;

/**
* Converts the parameter into a double.
* \param ok True if there's no error during the conversion, false otherwise
* \returns A double
*/
double toDouble( bool &ok ) const;

/**
* Converts the parameter into a boolean.
* \param ok True if there's no error during the conversion, false otherwise
* \param delimiter The character used for delimiting
* \returns A boolean
*/
bool toBool() const;

/**
* Converts the parameter into a color.
* \param ok True if there's no error during the conversion, false otherwise
* \param delimiter The character used for delimiting
* \returns A color
*/
QColor toColor( bool &ok ) const;

/**
* Raises an exception in case of an invalid parameters.
* \param msg The message describing the exception
* \throws QgsBadRequestException Invalid parameter exception
*/
static void raiseError( const QString &msg );

QVariant::Type mType;
Expand Down

0 comments on commit fb75580

Please sign in to comment.