QGIS API Documentation 3.99.0-Master (d270888f95f)
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
27using namespace Qt::StringLiterals;
28
35class CORE_EXPORT QgsUnsetAttributeValue
36{
37 public:
38
40
44 explicit QgsUnsetAttributeValue( const QString &defaultValueClause );
45
49 QString defaultValueClause() const { return mDefaultValueClause; }
50
54 inline bool operator==( const QgsUnsetAttributeValue & ) const { return true; }
55
59 inline bool operator!=( const QgsUnsetAttributeValue & ) const { return false; }
60
61#ifdef SIP_RUN
62 SIP_PYOBJECT __repr__();
63 % MethodCode
64 QString str;
65 if ( !sipCpp->defaultValueClause().isEmpty() )
66 str = u"<QgsUnsetAttributeValue: %1>"_s.arg( sipCpp->defaultValueClause() );
67 else
68 str = u"<QgsUnsetAttributeValue>"_s;
69 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
70 % End
71#endif
72
74 operator QVariant() const
75 {
76 return QVariant::fromValue( *this );
77 }
78
79 private:
80
81 QString mDefaultValueClause;
82
83};
84
86
87#ifndef SIP_RUN
88#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
89#pragma GCC diagnostic push
90#pragma GCC diagnostic ignored "-Wattributes"
91#elif defined(_MSC_VER)
92__pragma( warning( push ) )
93__pragma( warning( disable: 4273 ) )
94#endif
95#endif
96
97inline bool CORE_EXPORT operator==( const QgsUnsetAttributeValue &value, const QString &other )
98{
99 return other == value.defaultValueClause();
100}
101
102#ifndef SIP_RUN
103#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
104#pragma GCC diagnostic pop
105#elif defined(_MSC_VER)
106__pragma( warning( pop ) )
107#endif
108#endif
109
110inline bool operator!=( const QgsUnsetAttributeValue &value, const QString &other )
111{
112 return other != value.defaultValueClause();
113}
114
115#ifndef SIP_RUN
116inline bool operator==( const QString &other, const QgsUnsetAttributeValue &value )
117{
118 return other == value.defaultValueClause();
119}
120
121inline bool operator!=( const QString &other, const QgsUnsetAttributeValue &value )
122{
123 return other != value.defaultValueClause();
124}
125#endif
126
127#endif // QGSUNSETATTRIBUTEVALUE_H
128
129
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)