2017-04-30 21:58:30 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsfield.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2007-01-09 02:39:15 +00:00
class QgsField
{
2017-04-30 21:58:30 +02:00
%Docstring
Encapsulate a field in an attribute table or data source.
QgsField stores metadata about an attribute field, including name, type
length, and if applicable, precision.
.. note::
2007-01-09 02:39:15 +00:00
2017-04-30 21:58:30 +02:00
QgsField objects are implicitly shared.
2007-01-09 02:39:15 +00:00
%End
2017-04-30 21:58:30 +02:00
%TypeHeaderCode
#include "qgsfield.h"
%End
2015-10-11 22:42:28 +02:00
public:
2016-10-19 13:42:06 +10:00
2017-04-30 21:58:30 +02:00
QgsField( const QString &name = QString(),
2012-09-24 02:28:15 +02:00
QVariant::Type type = QVariant::Invalid,
2017-04-30 21:58:30 +02:00
const QString &typeName = QString(),
2012-09-24 02:28:15 +02:00
int len = 0,
int prec = 0,
2017-04-30 21:58:30 +02:00
const QString &comment = QString(),
2016-09-06 15:03:16 +02:00
QVariant::Type subType = QVariant::Invalid );
2017-04-30 21:58:30 +02:00
%Docstring
Constructor. Constructs a new QgsField object.
\param name Field name
\param type Field variant type, currently supported: String / Int / Double
\param typeName Field type (e.g., char, varchar, text, int, serial, double).
Field types are usually unique to the source and are stored exactly
as returned from the data store.
\param len Field length
\param prec Field precision. Usually decimal places but may also be
used in conjunction with other fields types (e.g., variable character fields)
\param comment Comment for the field
\param subType If the field is a collection, its element's type. When
all the elements don't need to have the same type, leave
this to QVariant.Invalid.
%End
QgsField( const QgsField &other );
%Docstring
Copy constructor
%End
2007-01-09 02:39:15 +00:00
2015-05-01 20:28:39 +10:00
2015-05-03 17:03:37 +10:00
virtual ~QgsField();
2007-01-09 02:39:15 +00:00
2017-04-30 21:58:30 +02:00
bool operator==( const QgsField &other ) const;
%Docstring
:rtype: bool
%End
bool operator!=( const QgsField &other ) const;
%Docstring
:rtype: bool
%End
2007-01-09 02:39:15 +00:00
2015-10-27 14:03:00 +11:00
QString name() const;
2017-04-30 21:58:30 +02:00
%Docstring
Returns the name of the field.
.. seealso:: setName()
.. seealso:: displayName()
:rtype: str
%End
2007-01-09 02:39:15 +00:00
2016-08-30 12:12:47 +10:00
QString displayName() const;
2017-04-30 21:58:30 +02:00
%Docstring
Returns the name to use when displaying this field. This will be the
field alias if set, otherwise the field name.
.. seealso:: name()
.. seealso:: alias()
.. versionadded:: 3.0
:rtype: str
%End
2016-08-30 12:12:47 +10:00
2012-09-24 02:28:15 +02:00
QVariant::Type type() const;
2017-04-30 21:58:30 +02:00
%Docstring
Gets variant type of the field as it will be retrieved from data source
:rtype: QVariant.Type
%End
2012-09-24 02:28:15 +02:00
2016-09-06 15:03:16 +02:00
QVariant::Type subType() const;
2017-04-30 21:58:30 +02:00
%Docstring
If the field is a collection, gets its element's type.
When all the elements don't need to have the same type, this returns
QVariant.Invalid.
.. versionadded:: 3.0
:rtype: QVariant.Type
%End
2016-09-06 15:03:16 +02:00
2015-10-27 14:03:00 +11:00
QString typeName() const;
2017-04-30 21:58:30 +02:00
%Docstring
Gets the field type. Field types vary depending on the data source. Examples
are char, int, double, blob, geometry, etc. The type is stored exactly as
the data store reports it, with no attempt to standardize the value.
:return: QString containing the field type
:rtype: str
%End
2007-01-09 02:39:15 +00:00
2012-09-24 02:28:15 +02:00
int length() const;
2017-04-30 21:58:30 +02:00
%Docstring
Gets the length of the field.
:return: int containing the length of the field
:rtype: int
%End
2007-01-09 02:39:15 +00:00
2012-09-24 02:28:15 +02:00
int precision() const;
2017-04-30 21:58:30 +02:00
%Docstring
Gets the precision of the field. Not all field types have a related precision.
:return: int containing the precision or zero if not applicable to the field type.
:rtype: int
%End
2007-01-09 02:39:15 +00:00
2015-10-27 14:03:00 +11:00
QString comment() const;
2017-04-30 21:58:30 +02:00
%Docstring
Returns the field comment
:rtype: str
%End
2007-01-09 02:39:15 +00:00
2016-08-16 16:22:29 +02:00
bool isNumeric() const;
2017-04-30 21:58:30 +02:00
%Docstring
Returns if this field is numeric. Any integer or floating point type
will return true for this.
2016-08-16 16:22:29 +02:00
2017-04-30 21:58:30 +02:00
.. versionadded:: 2.18
:rtype: bool
%End
void setName( const QString &name );
%Docstring
Set the field name.
\param name Name of the field
%End
2012-09-24 02:28:15 +02:00
void setType( QVariant::Type type );
2017-04-30 21:58:30 +02:00
%Docstring
Set variant type.
%End
2007-01-09 02:39:15 +00:00
2016-09-06 15:03:16 +02:00
void setSubType( QVariant::Type subType );
2017-04-30 21:58:30 +02:00
%Docstring
If the field is a collection, set its element's type.
When all the elements don't need to have the same type, set this to
QVariant.Invalid.
.. versionadded:: 3.0
%End
2016-09-06 15:03:16 +02:00
2017-04-30 21:58:30 +02:00
void setTypeName( const QString &typeName );
%Docstring
Set the field type.
\param typeName Field type
%End
2007-01-09 02:39:15 +00:00
2012-09-24 02:28:15 +02:00
void setLength( int len );
2017-04-30 21:58:30 +02:00
%Docstring
Set the field length.
\param len Length of the field
%End
2007-01-09 02:39:15 +00:00
2015-05-01 20:28:39 +10:00
void setPrecision( int precision );
2017-04-30 21:58:30 +02:00
%Docstring
Set the field precision.
\param precision Precision of the field
%End
void setComment( const QString &comment );
%Docstring
Set the field comment
%End
2007-01-09 02:39:15 +00:00
2016-08-30 12:12:47 +10:00
QString defaultValueExpression() const;
2017-04-30 21:58:30 +02:00
%Docstring
Returns the expression used when calculating the default value for the field.
:return: expression evaluated when calculating default values for field, or an
empty string if no default is set
.. versionadded:: 3.0
.. seealso:: setDefaultValueExpression()
:rtype: str
%End
void setDefaultValueExpression( const QString &expression );
%Docstring
Sets an expression to use when calculating the default value for the field.
\param expression expression to evaluate when calculating default values for field. Pass
an empty expression to clear the default.
.. versionadded:: 3.0
.. seealso:: defaultValueExpression()
%End
const QgsFieldConstraints &constraints() const;
%Docstring
Returns constraints which are present for the field.
.. versionadded:: 3.0
.. seealso:: setConstraints()
:rtype: QgsFieldConstraints
%End
void setConstraints( const QgsFieldConstraints &constraints );
%Docstring
Sets constraints which are present for the field.
.. versionadded:: 3.0
.. seealso:: constraints()
%End
2016-08-30 12:12:47 +10:00
QString alias() const;
2017-04-30 21:58:30 +02:00
%Docstring
Returns the alias for the field (the friendly displayed name of the field ),
or an empty string if there is no alias.
.. seealso:: setAlias()
.. versionadded:: 3.0
:rtype: str
%End
void setAlias( const QString &alias );
%Docstring
Sets the alias for the field (the friendly displayed name of the field ).
\param alias field alias, or empty string to remove an existing alias
.. seealso:: alias()
.. versionadded:: 3.0
%End
QString displayString( const QVariant &v ) const;
%Docstring
Formats string for display
:rtype: str
%End
2016-08-30 12:12:47 +10:00
2017-04-30 21:58:30 +02:00
bool convertCompatible( QVariant &v ) const;
%Docstring
Converts the provided variant to a compatible format
\param v The value to convert
:return: True if the conversion was successful
:rtype: bool
%End
2014-10-06 10:17:05 +02:00
%MethodCode
PyObject *sipParseErr = NULL;
{
2017-04-30 21:58:30 +02:00
QVariant *a0;
2014-10-06 10:17:05 +02:00
int a0State = 0;
const QgsField *sipCpp;
2017-04-30 21:58:30 +02:00
if ( sipParseArgs( &sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
2014-10-06 10:17:05 +02:00
{
bool sipRes;
Py_BEGIN_ALLOW_THREADS
try
{
QgsDebugMsg( a0->toString() );
2017-04-30 21:58:30 +02:00
sipRes = sipCpp->convertCompatible( *a0 );
2014-10-06 10:17:05 +02:00
QgsDebugMsg( a0->toString() );
}
2017-04-30 21:58:30 +02:00
catch ( ... )
2014-10-06 10:17:05 +02:00
{
Py_BLOCK_THREADS
2017-04-30 21:58:30 +02:00
sipReleaseType( a0, sipType_QVariant, a0State );
sipRaiseUnknownException();
return NULL;
2014-10-06 10:17:05 +02:00
}
Py_END_ALLOW_THREADS
2017-04-30 21:58:30 +02:00
PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
sipReleaseType( a0, sipType_QVariant, a0State );
2014-10-06 10:17:05 +02:00
if ( !sipRes )
{
2017-04-30 21:58:30 +02:00
PyErr_SetString( PyExc_ValueError,
QString( "Value %1 (%2) could not be converted to field type %3." ).arg( a0->toString(), a0->typeName() ).arg( sipCpp->type() ).toUtf8().constData() );
sipError = sipErrorFail;
2014-10-06 10:17:05 +02:00
}
return res;
}
}
2017-04-30 21:58:30 +02:00
// Raise an exception if the arguments couldn't be parsed.
sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
2014-10-06 10:17:05 +02:00
2017-04-30 21:58:30 +02:00
return 0;
2014-10-06 10:17:05 +02:00
%End
2016-05-20 09:48:18 +10:00
operator QVariant() const;
2017-04-30 21:58:30 +02:00
%Docstring
Allows direct construction of QVariants from fields.
%End
void setEditorWidgetSetup( const QgsEditorWidgetSetup &v );
%Docstring
Set the editor widget setup for the field.
\param v The value to set
%End
QgsEditorWidgetSetup editorWidgetSetup() const;
%Docstring
Get the editor widget setup for the field.
Defaults may be set by the provider and can be overridden
by manual field configuration.
:return: the value
:rtype: QgsEditorWidgetSetup
%End
2016-05-20 09:48:18 +10:00
2007-01-09 02:39:15 +00:00
}; // class QgsField
2016-10-19 13:42:06 +10:00
2017-04-30 21:58:30 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsfield.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/