QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsunsetattributevalue.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsunsetattributevalue.h
3 ------------------------
4 begin : July 2022
5 copyright : (C) 2022 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSUNSETATTRIBUTEVALUE_H
19#define QGSUNSETATTRIBUTEVALUE_H
20
21#include "qgis_core.h"
22#include <QString>
23#include <QVariant>
24
31class CORE_EXPORT QgsUnsetAttributeValue
32{
33 public:
34
39
43 explicit QgsUnsetAttributeValue( const QString &defaultValueClause );
44
48 QString defaultValueClause() const { return mDefaultValueClause; }
49
53 inline bool operator==( const QgsUnsetAttributeValue & ) const { return true; }
54
58 inline bool operator!=( const QgsUnsetAttributeValue & ) const { return false; }
59
60#ifdef SIP_RUN
61 SIP_PYOBJECT __repr__();
62 % MethodCode
63 QString str;
64 if ( !sipCpp->defaultValueClause().isEmpty() )
65 str = QStringLiteral( "<QgsUnsetAttributeValue: %1>" ).arg( sipCpp->defaultValueClause() );
66 else
67 str = QStringLiteral( "<QgsUnsetAttributeValue>" );
68 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
69 % End
70#endif
71
73 operator QVariant() const
74 {
75 return QVariant::fromValue( *this );
76 }
77
78 private:
79
80 QString mDefaultValueClause;
81
82};
83
85
86
87inline bool CORE_EXPORT operator==( const QgsUnsetAttributeValue &value, const QString &other )
88{
89 return other == value.defaultValueClause();
90}
91
92inline bool operator!=( const QgsUnsetAttributeValue &value, const QString &other )
93{
94 return other != value.defaultValueClause();
95}
96
97#ifndef SIP_RUN
98inline bool operator==( const QString &other, const QgsUnsetAttributeValue &value )
99{
100 return other == value.defaultValueClause();
101}
102
103inline bool operator!=( const QString &other, const QgsUnsetAttributeValue &value )
104{
105 return other != value.defaultValueClause();
106}
107#endif
108
109#endif // QGSUNSETATTRIBUTEVALUE_H
110
111
Represents a default, "not-specified" value for a feature attribute.
bool operator==(const QgsUnsetAttributeValue &) const
QgsUnsetAttributeValues are always considered equal to each other, regardless of what the original pr...
QgsUnsetAttributeValue()=default
Constructor for a QgsUnsetAttributeValue.
bool operator!=(const QgsUnsetAttributeValue &) const
QgsUnsetAttributeValues are always considered equal to each other, regardless of what the original pr...
QString defaultValueClause() const
Returns the original data provider's default value clause.
#define str(x)
Definition: qgis.cpp:37
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
bool operator!=(const QgsUnsetAttributeValue &value, const QString &other)
bool CORE_EXPORT operator==(const QgsUnsetAttributeValue &value, const QString &other)