Skip to content

Commit

Permalink
QRegularExpression porting
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 30, 2021
1 parent 4da1c36 commit 5883b83
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/providers/postgres/raster/qgspostgresrasterprovider.cpp
Expand Up @@ -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" );

Expand Down Expand Up @@ -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" ) )
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand Down

0 comments on commit 5883b83

Please sign in to comment.