QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
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
36
40 explicit QgsUnsetAttributeValue( const QString &defaultValueClause );
41
45 QString defaultValueClause() const { return mDefaultValueClause; }
46
50 inline bool operator==( const QgsUnsetAttributeValue & ) const { return true; }
51
55 inline bool operator!=( const QgsUnsetAttributeValue & ) const { return false; }
56
57#ifdef SIP_RUN
58 SIP_PYOBJECT __repr__();
59 % MethodCode
60 QString str;
61 if ( !sipCpp->defaultValueClause().isEmpty() )
62 str = QStringLiteral( "<QgsUnsetAttributeValue: %1>" ).arg( sipCpp->defaultValueClause() );
63 else
64 str = QStringLiteral( "<QgsUnsetAttributeValue>" );
65 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
66 % End
67#endif
68
70 operator QVariant() const
71 {
72 return QVariant::fromValue( *this );
73 }
74
75 private:
76
77 QString mDefaultValueClause;
78
79};
80
82
83
84inline bool CORE_EXPORT operator==( const QgsUnsetAttributeValue &value, const QString &other )
85{
86 return other == value.defaultValueClause();
87}
88
89inline bool operator!=( const QgsUnsetAttributeValue &value, const QString &other )
90{
91 return other != value.defaultValueClause();
92}
93
94#ifndef SIP_RUN
95inline bool operator==( const QString &other, const QgsUnsetAttributeValue &value )
96{
97 return other == value.defaultValueClause();
98}
99
100inline bool operator!=( const QString &other, const QgsUnsetAttributeValue &value )
101{
102 return other != value.defaultValueClause();
103}
104#endif
105
106#endif // QGSUNSETATTRIBUTEVALUE_H
107
108
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
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:39
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
bool operator!=(const QgsUnsetAttributeValue &value, const QString &other)
bool CORE_EXPORT operator==(const QgsUnsetAttributeValue &value, const QString &other)