20 #include "qgsversion.h"
22 #include <QCoreApplication>
28 #include "qgsconfig.h"
36 #define xstr(x) str(x)
74 string.remove( QLocale().groupSeparator() );
75 return QLocale().toDouble(
string, &ok );
81 string.remove( QLocale().groupSeparator() );
82 return QLocale().toInt(
string, &ok );
88 string.remove( QLocale().groupSeparator() );
89 return QLocale().toLongLong(
string, &ok );
96 QgsDebugMsg( QStringLiteral(
"Zero size requested" ) );
100 if ( ( size >> ( 8 *
sizeof( size ) - 1 ) ) != 0 )
102 QgsDebugMsg( QStringLiteral(
"qgsMalloc - bad size requested: %1" ).arg( size ) );
106 void *p = malloc( size );
109 QgsDebugMsg( QStringLiteral(
"Allocation of %1 bytes failed." ).arg( size ) );
122 if ( !lhs.isValid() )
123 return rhs.isValid();
124 else if ( lhs.isNull() )
125 return rhs.isValid() && !rhs.isNull();
126 else if ( !rhs.isValid() || rhs.isNull() )
129 switch ( lhs.type() )
132 return lhs.toInt() < rhs.toInt();
134 return lhs.toUInt() < rhs.toUInt();
135 case QVariant::LongLong:
136 return lhs.toLongLong() < rhs.toLongLong();
137 case QVariant::ULongLong:
138 return lhs.toULongLong() < rhs.toULongLong();
139 case QVariant::Double:
140 return lhs.toDouble() < rhs.toDouble();
142 return lhs.toChar() < rhs.toChar();
144 return lhs.toDate() < rhs.toDate();
146 return lhs.toTime() < rhs.toTime();
147 case QVariant::DateTime:
148 return lhs.toDateTime() < rhs.toDateTime();
150 return lhs.toBool() < rhs.toBool();
154 const QList<QVariant> &lhsl = lhs.toList();
155 const QList<QVariant> &rhsl = rhs.toList();
157 int i, n = std::min( lhsl.size(), rhsl.size() );
158 for ( i = 0; i < n && lhsl[i].type() == rhsl[i].type() &&
qgsVariantEqual( lhsl[i], rhsl[i] ); i++ )
162 return lhsl.size() < rhsl.size();
167 case QVariant::StringList:
169 const QStringList &lhsl = lhs.toStringList();
170 const QStringList &rhsl = rhs.toStringList();
172 int i, n = std::min( lhsl.size(), rhsl.size() );
173 for ( i = 0; i < n && lhsl[i] == rhsl[i]; i++ )
177 return lhsl.size() < rhsl.size();
179 return lhsl[i] < rhsl[i];
183 return QString::localeAwareCompare( lhs.toString(), rhs.toString() ) < 0;
194 if ( path.startsWith( QLatin1String(
"/vsizip/" ), Qt::CaseInsensitive ) )
195 return QStringLiteral(
"/vsizip/" );
196 else if ( path.endsWith( QLatin1String(
".shp.zip" ), Qt::CaseInsensitive ) )
199 if ( GDALIdentifyDriverEx( path.toUtf8().constData(), GDAL_OF_VECTOR,
nullptr,
nullptr ) )
201 return QStringLiteral(
"/vsizip/" );
203 else if ( path.endsWith( QLatin1String(
".zip" ), Qt::CaseInsensitive ) )
204 return QStringLiteral(
"/vsizip/" );
205 else if ( path.startsWith( QLatin1String(
"/vsitar/" ), Qt::CaseInsensitive ) ||
206 path.endsWith( QLatin1String(
".tar" ), Qt::CaseInsensitive ) ||
207 path.endsWith( QLatin1String(
".tar.gz" ), Qt::CaseInsensitive ) ||
208 path.endsWith( QLatin1String(
".tgz" ), Qt::CaseInsensitive ) )
209 return QStringLiteral(
"/vsitar/" );
210 else if ( path.startsWith( QLatin1String(
"/vsigzip/" ), Qt::CaseInsensitive ) ||
211 path.endsWith( QLatin1String(
".gz" ), Qt::CaseInsensitive ) )
212 return QStringLiteral(
"/vsigzip/" );
217 uint
qHash(
const QVariant &variant )
219 if ( !variant.isValid() || variant.isNull() )
220 return std::numeric_limits<uint>::max();
222 switch ( variant.type() )
225 return qHash( variant.toInt() );
227 return qHash( variant.toUInt() );
229 return qHash( variant.toBool() );
230 case QVariant::Double:
231 return qHash( variant.toDouble() );
232 case QVariant::LongLong:
233 return qHash( variant.toLongLong() );
234 case QVariant::ULongLong:
235 return qHash( variant.toULongLong() );
236 case QVariant::String:
237 return qHash( variant.toString() );
239 return qHash( variant.toChar() );
241 return qHash( variant.toList() );
242 case QVariant::StringList:
243 return qHash( variant.toStringList() );
244 case QVariant::ByteArray:
245 return qHash( variant.toByteArray() );
247 return qHash( variant.toDate() );
249 return qHash( variant.toTime() );
250 case QVariant::DateTime:
251 return qHash( variant.toDateTime() );
253 case QVariant::Locale:
254 case QVariant::RegularExpression:
255 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
256 case QVariant::RegExp:
258 return qHash( variant.toString() );
263 return std::numeric_limits<uint>::max();
268 return ( lhs.isNull() == rhs.isNull() && lhs == rhs ) || ( lhs.isNull() && rhs.isNull() && lhs.isValid() && rhs.isValid() );
273 return QStringLiteral(
"1:1000000,1:500000,1:250000,1:100000,1:50000,1:25000,"
274 "1:10000,1:5000,1:2500,1:1000,1:500" );
279 return QString::fromUtf8( VERSION );
291 return QString::fromUtf8( RELEASE_NAME );
301 return GEOSversion();
306 static const int version = QStringLiteral(
"%1%2%3" )
307 .arg( GEOS_VERSION_MAJOR, 2, 10, QChar(
'0' ) )
308 .arg( GEOS_VERSION_MINOR, 2, 10, QChar(
'0' ) )
316 return GEOS_VERSION_MAJOR;
321 return GEOS_VERSION_MINOR;
326 static const int version = atoi(
xstr( GEOS_VERSION_PATCH ) );
330 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
332 bool qMapLessThanKey<QVariantList>(
const QVariantList &key1,
const QVariantList &key2 )