QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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.h"
22#include "qgis_core.h"
23
24#include <QString>
25#include <QVariant>
26
33class CORE_EXPORT QgsUnsetAttributeValue
34{
35 public:
36
38
42 explicit QgsUnsetAttributeValue( const QString &defaultValueClause );
43
47 QString defaultValueClause() const { return mDefaultValueClause; }
48
52 inline bool operator==( const QgsUnsetAttributeValue & ) const { return true; }
53
57 inline bool operator!=( const QgsUnsetAttributeValue & ) const { return false; }
58
59#ifdef SIP_RUN
60 SIP_PYOBJECT __repr__();
61 % MethodCode
62 QString str;
63 if ( !sipCpp->defaultValueClause().isEmpty() )
64 str = QStringLiteral( "<QgsUnsetAttributeValue: %1>" ).arg( sipCpp->defaultValueClause() );
65 else
66 str = QStringLiteral( "<QgsUnsetAttributeValue>" );
67 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
68 % End
69#endif
70
72 operator QVariant() const
73 {
74 return QVariant::fromValue( *this );
75 }
76
77 private:
78
79 QString mDefaultValueClause;
80
81};
82
84
85#ifndef SIP_RUN
86#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
87#pragma GCC diagnostic push
88#pragma GCC diagnostic ignored "-Wattributes"
89#elif defined(_MSC_VER)
90__pragma( warning( push ) )
91__pragma( warning( disable: 4273 ) )
92#endif
93#endif
94
95inline bool CORE_EXPORT operator==( const QgsUnsetAttributeValue &value, const QString &other )
96{
97 return other == value.defaultValueClause();
98}
99
100#ifndef SIP_RUN
101#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
102#pragma GCC diagnostic pop
103#elif defined(_MSC_VER)
104__pragma( warning( pop ) )
105#endif
106#endif
107
108inline bool operator!=( const QgsUnsetAttributeValue &value, const QString &other )
109{
110 return other != value.defaultValueClause();
111}
112
113#ifndef SIP_RUN
114inline bool operator==( const QString &other, const QgsUnsetAttributeValue &value )
115{
116 return other == value.defaultValueClause();
117}
118
119inline bool operator!=( const QString &other, const QgsUnsetAttributeValue &value )
120{
121 return other != value.defaultValueClause();
122}
123#endif
124
125#endif // QGSUNSETATTRIBUTEVALUE_H
126
127
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.
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
bool operator!=(const QgsUnsetAttributeValue &value, const QString &other)
bool CORE_EXPORT operator==(const QgsUnsetAttributeValue &value, const QString &other)