Skip to content
Permalink
Browse files

QRegularExpression porting

  • Loading branch information
nyalldawson committed Mar 30, 2021
1 parent 4da1c36 commit 5883b8338b5c599fcf8e86046a5d5d2a530604d0
Showing with 19 additions and 13 deletions.
  1. +19 −13 src/providers/postgres/raster/qgspostgresrasterprovider.cpp
@@ -24,6 +24,8 @@
#include "qgsgdalutils.h"
#include "qgsstringutils.h"

#include <QRegularExpression>

const QString QgsPostgresRasterProvider::PG_RASTER_PROVIDER_KEY = QStringLiteral( "postgresraster" );
const QString QgsPostgresRasterProvider::PG_RASTER_PROVIDER_DESCRIPTION = QStringLiteral( "Postgres raster provider" );

@@ -1671,11 +1673,12 @@ bool QgsPostgresRasterProvider::loadFields()
}
else
{
QRegExp re( "numeric\\((\\d+),(\\d+)\\)" );
if ( re.exactMatch( formattedFieldType ) )
QRegularExpression re( QRegularExpression::anchoredPattern( QStringLiteral( "numeric\\((\\d+),(\\d+)\\)" ) ) );
const QRegularExpressionMatch match = re.match( formattedFieldType );
if ( match.hasMatch() )
{
fieldSize = re.cap( 1 ).toInt();
fieldPrec = re.cap( 2 ).toInt();
fieldSize = match.captured( 1 ).toInt();
fieldPrec = match.captured( 2 ).toInt();
}
else if ( formattedFieldType != QLatin1String( "numeric" ) )
{
@@ -1692,10 +1695,11 @@ bool QgsPostgresRasterProvider::loadFields()
{
fieldType = QVariant::String;

QRegExp re( "character varying\\((\\d+)\\)" );
if ( re.exactMatch( formattedFieldType ) )
const QRegularExpression re( QRegularExpression::anchoredPattern( QStringLiteral( "character varying\\((\\d+)\\)" ) ) );
const QRegularExpressionMatch match = re.match( formattedFieldType );
if ( match.hasMatch() )
{
fieldSize = re.cap( 1 ).toInt();
fieldSize = match.captured( 1 ).toInt();
}
else
{
@@ -1743,10 +1747,11 @@ bool QgsPostgresRasterProvider::loadFields()

fieldType = QVariant::String;

QRegExp re( "character\\((\\d+)\\)" );
if ( re.exactMatch( formattedFieldType ) )
const QRegularExpression re( QRegularExpression::anchoredPattern( QStringLiteral( "character\\((\\d+)\\)" ) ) );
const QRegularExpressionMatch match = re.match( formattedFieldType );
if ( match.hasMatch() )
{
fieldSize = re.cap( 1 ).toInt();
fieldSize = match.captured( 1 ).toInt();
}
else
{
@@ -1761,10 +1766,11 @@ bool QgsPostgresRasterProvider::loadFields()
{
fieldType = QVariant::String;

QRegExp re( "char\\((\\d+)\\)" );
if ( re.exactMatch( formattedFieldType ) )
const QRegularExpression re( QRegularExpression::anchoredPattern( QStringLiteral( "char\\((\\d+)\\)" ) ) );
const QRegularExpressionMatch match = re.match( formattedFieldType );
if ( match.hasMatch() )
{
fieldSize = re.cap( 1 ).toInt();
fieldSize = match.captured( 1 ).toInt();
}
else
{

0 comments on commit 5883b83

Please sign in to comment.