Skip to content

Commit dbedd7e

Browse files
authored
Merge pull request #4683 from rldhont/server-string-list-exceptions
[Server] bulk enhancements: string, list and exceptions
2 parents 38d905f + ad14373 commit dbedd7e

17 files changed

+94
-84
lines changed

src/server/qgsinterpolationlayerbuilder.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ QgsMapLayer *QgsInterpolationLayerBuilder::createMapLayer( const QDomElement &el
5252
}
5353

5454
QDomNodeList interpolationList = elem.elementsByTagName( QStringLiteral( "Interpolation" ) );
55-
if ( interpolationList.size() < 1 )
55+
if ( interpolationList.isEmpty() )
5656
{
5757
QgsDebugMsg( "No Interpolation element found" );
5858
return nullptr;
@@ -68,7 +68,7 @@ QgsMapLayer *QgsInterpolationLayerBuilder::createMapLayer( const QDomElement &el
6868
QgsInterpolator::LayerData currentLayerData;
6969
currentLayerData.vectorLayer = mVectorLayer;
7070
QDomNodeList propertyNameList = interpolationElem.elementsByTagName( QStringLiteral( "PropertyName" ) );
71-
if ( propertyNameList.size() < 1 )
71+
if ( propertyNameList.isEmpty() )
7272
{
7373
currentLayerData.zCoordInterpolation = true;
7474
}
@@ -110,7 +110,7 @@ QgsMapLayer *QgsInterpolationLayerBuilder::createMapLayer( const QDomElement &el
110110
int nCols, nRows;
111111

112112
QDomNodeList resolutionNodeList = elem.elementsByTagName( QStringLiteral( "Resolution" ) );
113-
if ( resolutionNodeList.size() < 1 )
113+
if ( resolutionNodeList.isEmpty() )
114114
{
115115
//use default values...
116116
nCols = 100;

src/server/qgsserver.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ QFileInfo QgsServer::defaultProjectFile()
124124
{
125125
QgsMessageLog::logMessage( projectFiles.at( x ).absoluteFilePath(), QStringLiteral( "Server" ), QgsMessageLog::INFO );
126126
}
127-
if ( projectFiles.size() < 1 )
127+
if ( projectFiles.isEmpty() )
128128
{
129129
return QFileInfo();
130130
}

src/server/services/wcs/qgswcsdescribecoverage.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ namespace QgsWcs
8787
QStringList coveNameList;
8888
if ( !coveNames.isEmpty() )
8989
{
90-
coveNameList = coveNames.split( QStringLiteral( "," ) );
90+
coveNameList = coveNames.split( ',' );
9191
for ( int i = 0; i < coveNameList.size(); ++i )
9292
{
9393
coveNameList.replace( i, coveNameList.at( i ).trimmed() );
@@ -111,7 +111,7 @@ namespace QgsWcs
111111
QString name = layer->name();
112112
if ( !layer->shortName().isEmpty() )
113113
name = layer->shortName();
114-
name = name.replace( QLatin1String( " " ), QLatin1String( "_" ) );
114+
name = name.replace( ' ', '_' );
115115

116116
if ( coveNameList.size() == 0 || coveNameList.contains( name ) )
117117
{

src/server/services/wcs/qgswcsutils.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace QgsWcs
4545
QString name = layer->name();
4646
if ( !layer->shortName().isEmpty() )
4747
name = layer->shortName();
48-
name = name.replace( QLatin1String( " " ), QLatin1String( "_" ) );
48+
name = name.replace( ' ', '_' );
4949
QDomText nameText = doc.createTextNode( name );
5050
nameElem.appendChild( nameText );
5151
layerElem.appendChild( nameElem );
@@ -260,15 +260,15 @@ namespace QgsWcs
260260

261261
QgsRectangle parseBbox( const QString &bboxStr )
262262
{
263-
QStringList lst = bboxStr.split( QStringLiteral( "," ) );
263+
QStringList lst = bboxStr.split( ',' );
264264
if ( lst.count() != 4 )
265265
return QgsRectangle();
266266

267267
double d[4];
268268
bool ok;
269269
for ( int i = 0; i < 4; i++ )
270270
{
271-
lst[i].replace( QLatin1String( " " ), QLatin1String( "+" ) );
271+
lst[i].replace( ' ', '+' );
272272
d[i] = lst[i].toDouble( &ok );
273273
if ( !ok )
274274
return QgsRectangle();

src/server/services/wfs/qgswfsdescribefeaturetype.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ namespace QgsWfs
9090
if ( docChildElem.tagName() == QLatin1String( "TypeName" ) )
9191
{
9292
QString typeName = docChildElem.text().trimmed();
93-
if ( typeName.contains( QLatin1String( ":" ) ) )
94-
typeNameList << typeName.section( QStringLiteral( ":" ), 1, 1 );
93+
if ( typeName.contains( ':' ) )
94+
typeNameList << typeName.section( ':', 1, 1 );
9595
else
9696
typeNameList << typeName;
9797
}
@@ -103,12 +103,12 @@ namespace QgsWfs
103103
QString typeNames = request.parameter( QStringLiteral( "TYPENAME" ) );
104104
if ( !typeNames.isEmpty() )
105105
{
106-
QStringList typeNameSplit = typeNames.split( QStringLiteral( "," ) );
106+
QStringList typeNameSplit = typeNames.split( ',' );
107107
for ( int i = 0; i < typeNameSplit.size(); ++i )
108108
{
109109
QString typeName = typeNameSplit.at( i ).trimmed();
110-
if ( typeName.contains( QLatin1String( ":" ) ) )
111-
typeNameList << typeName.section( QStringLiteral( ":" ), 1, 1 );
110+
if ( typeName.contains( ':' ) )
111+
typeNameList << typeName.section( ':', 1, 1 );
112112
else
113113
typeNameList << typeName;
114114
}
@@ -127,7 +127,7 @@ namespace QgsWfs
127127
QString name = layer->name();
128128
if ( !layer->shortName().isEmpty() )
129129
name = layer->shortName();
130-
name = name.replace( QLatin1String( " " ), QLatin1String( "_" ) );
130+
name = name.replace( ' ', '_' );
131131

132132
if ( !typeNameList.isEmpty() && !typeNameList.contains( name ) )
133133
{
@@ -168,7 +168,7 @@ namespace QgsWfs
168168
QString typeName = layer->name();
169169
if ( !layer->shortName().isEmpty() )
170170
typeName = layer->shortName();
171-
typeName = typeName.replace( QLatin1String( " " ), QLatin1String( "_" ) );
171+
typeName = typeName.replace( ' ', '_' );
172172

173173
//xsd:element
174174
QDomElement elementElem = doc.createElement( QStringLiteral( "element" )/*xsd:element*/ );

src/server/services/wfs/qgswfsgetfeature.cpp

+27-27
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ namespace QgsWfs
121121
QString name = layer->name();
122122
if ( !layer->shortName().isEmpty() )
123123
name = layer->shortName();
124-
name = name.replace( QLatin1String( " " ), QLatin1String( "_" ) );
124+
name = name.replace( ' ', '_' );
125125

126126
if ( typeNameList.contains( name ) )
127127
{
@@ -387,7 +387,7 @@ namespace QgsWfs
387387
// parse FEATUREID
388388
if ( parameters.contains( QStringLiteral( "FEATUREID" ) ) )
389389
{
390-
QStringList fidList = parameters.value( QStringLiteral( "FEATUREID" ) ).split( QStringLiteral( "," ) );
390+
QStringList fidList = parameters.value( QStringLiteral( "FEATUREID" ) ).split( ',' );
391391
// Verifying the 1:1 mapping between FEATUREID and PROPERTYNAME
392392
if ( !propertyNameList.isEmpty() && propertyNameList.size() != fidList.size() )
393393
{
@@ -417,13 +417,13 @@ namespace QgsWfs
417417
propertyName = *propertyNameIt;
418418
}
419419
// testing typename in the WFS featureID
420-
if ( !fid.contains( QLatin1String( "." ) ) )
420+
if ( !fid.contains( '.' ) )
421421
{
422422
throw QgsRequestNotWellFormedException( QStringLiteral( "FEATUREID has to have TYPENAME in the values" ) );
423423
}
424424

425-
QString typeName = fid.section( QStringLiteral( "." ), 0, 0 );
426-
fid = fid.section( QStringLiteral( "." ), 1, 1 );
425+
QString typeName = fid.section( '.', 0, 0 );
426+
fid = fid.section( '.', 1, 1 );
427427
if ( !typeNameList.contains( typeName ) )
428428
{
429429
typeNameList << typeName;
@@ -467,23 +467,23 @@ namespace QgsWfs
467467
{
468468
QStringList propertyList;
469469

470-
QStringList attrList = propertyName.split( QStringLiteral( "," ) );
470+
QStringList attrList = propertyName.split( ',' );
471471
QStringList::const_iterator alstIt;
472472
for ( alstIt = attrList.begin(); alstIt != attrList.end(); ++alstIt )
473473
{
474474
QString fieldName = *alstIt;
475475
fieldName = fieldName.trimmed();
476-
if ( fieldName.contains( QLatin1String( ":" ) ) )
476+
if ( fieldName.contains( ':' ) )
477477
{
478-
fieldName = fieldName.section( QStringLiteral( ":" ), 1, 1 );
478+
fieldName = fieldName.section( ':', 1, 1 );
479479
}
480-
if ( fieldName.contains( QLatin1String( "/" ) ) )
480+
if ( fieldName.contains( '/' ) )
481481
{
482-
if ( fieldName.section( QStringLiteral( "/" ), 0, 0 ) != typeName )
482+
if ( fieldName.section( '/', 0, 0 ) != typeName )
483483
{
484484
throw QgsRequestNotWellFormedException( QStringLiteral( "PropertyName text '%1' has to contain TypeName '%2'" ).arg( fieldName ).arg( typeName ) );
485485
}
486-
fieldName = fieldName.section( QStringLiteral( "/" ), 1, 1 );
486+
fieldName = fieldName.section( '/', 1, 1 );
487487
}
488488
propertyList.append( fieldName );
489489
}
@@ -513,7 +513,7 @@ namespace QgsWfs
513513
throw QgsRequestNotWellFormedException( QStringLiteral( "TYPENAME is mandatory except if FEATUREID is used" ) );
514514
}
515515

516-
typeNameList = parameters.value( QStringLiteral( "TYPENAME" ) ).split( QStringLiteral( "," ) );
516+
typeNameList = parameters.value( QStringLiteral( "TYPENAME" ) ).split( ',' );
517517
// Verifying the 1:1 mapping between TYPENAME and PROPERTYNAME
518518
if ( !propertyNameList.isEmpty() && typeNameList.size() != propertyNameList.size() )
519519
{
@@ -549,23 +549,23 @@ namespace QgsWfs
549549
{
550550
QStringList propertyList;
551551

552-
QStringList attrList = propertyName.split( QStringLiteral( "," ) );
552+
QStringList attrList = propertyName.split( ',' );
553553
QStringList::const_iterator alstIt;
554554
for ( alstIt = attrList.begin(); alstIt != attrList.end(); ++alstIt )
555555
{
556556
QString fieldName = *alstIt;
557557
fieldName = fieldName.trimmed();
558-
if ( fieldName.contains( QLatin1String( ":" ) ) )
558+
if ( fieldName.contains( ':' ) )
559559
{
560-
fieldName = fieldName.section( QStringLiteral( ":" ), 1, 1 );
560+
fieldName = fieldName.section( ':', 1, 1 );
561561
}
562-
if ( fieldName.contains( QLatin1String( "/" ) ) )
562+
if ( fieldName.contains( '/' ) )
563563
{
564-
if ( fieldName.section( QStringLiteral( "/" ), 0, 0 ) != typeName )
564+
if ( fieldName.section( '/', 0, 0 ) != typeName )
565565
{
566566
throw QgsRequestNotWellFormedException( QStringLiteral( "PropertyName text '%1' has to contain TypeName '%2'" ).arg( fieldName ).arg( typeName ) );
567567
}
568-
fieldName = fieldName.section( QStringLiteral( "/" ), 1, 1 );
568+
fieldName = fieldName.section( '/', 1, 1 );
569569
}
570570
propertyList.append( fieldName );
571571
}
@@ -660,7 +660,7 @@ namespace QgsWfs
660660
bool ok;
661661
for ( int i = 0; i < 4; i++ )
662662
{
663-
corners[i].replace( QLatin1String( " " ), QLatin1String( "+" ) );
663+
corners[i].replace( ' ', '+' );
664664
d[i] = corners[i].toDouble( &ok );
665665
if ( !ok )
666666
{
@@ -769,9 +769,9 @@ namespace QgsWfs
769769
getFeatureQuery parseQueryElement( QDomElement &queryElem )
770770
{
771771
QString typeName = queryElem.attribute( QStringLiteral( "typeName" ), QLatin1String( "" ) );
772-
if ( typeName.contains( QLatin1String( ":" ) ) )
772+
if ( typeName.contains( ':' ) )
773773
{
774-
typeName = typeName.section( QStringLiteral( ":" ), 1, 1 );
774+
typeName = typeName.section( ':', 1, 1 );
775775
}
776776

777777
QgsFeatureRequest featureRequest;
@@ -785,17 +785,17 @@ namespace QgsWfs
785785
if ( queryChildElem.tagName() == QLatin1String( "PropertyName" ) )
786786
{
787787
QString fieldName = queryChildElem.text().trimmed();
788-
if ( fieldName.contains( QLatin1String( ":" ) ) )
788+
if ( fieldName.contains( ':' ) )
789789
{
790-
fieldName = fieldName.section( QStringLiteral( ":" ), 1, 1 );
790+
fieldName = fieldName.section( ':', 1, 1 );
791791
}
792-
if ( fieldName.contains( QLatin1String( "/" ) ) )
792+
if ( fieldName.contains( '/' ) )
793793
{
794-
if ( fieldName.section( QStringLiteral( "/" ), 0, 0 ) != typeName )
794+
if ( fieldName.section( '/', 0, 0 ) != typeName )
795795
{
796796
throw QgsRequestNotWellFormedException( QStringLiteral( "PropertyName text '%1' has to contain TypeName '%2'" ).arg( fieldName ).arg( typeName ) );
797797
}
798-
fieldName = fieldName.section( QStringLiteral( "/" ), 1, 1 );
798+
fieldName = fieldName.section( '/', 1, 1 );
799799
}
800800
propertyList.append( fieldName );
801801
}
@@ -878,7 +878,7 @@ namespace QgsWfs
878878
query.removeAllQueryItems( QStringLiteral( "_DC" ) );
879879

880880
query.addQueryItem( QStringLiteral( "REQUEST" ), QStringLiteral( "DescribeFeatureType" ) );
881-
query.addQueryItem( QStringLiteral( "TYPENAME" ), typeNames.join( QStringLiteral( "," ) ) );
881+
query.addQueryItem( QStringLiteral( "TYPENAME" ), typeNames.join( ',' ) );
882882
query.addQueryItem( QStringLiteral( "OUTPUTFORMAT" ), QStringLiteral( "XMLSCHEMA" ) );
883883

884884
mapUrl.setQuery( query );

src/server/services/wfs/qgswfstransaction.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ namespace QgsWfs
243243
QString name = layer->name();
244244
if ( !layer->shortName().isEmpty() )
245245
name = layer->shortName();
246-
name = name.replace( QLatin1String( " " ), QLatin1String( "_" ) );
246+
name = name.replace( ' ', '_' );
247247

248248
if ( !typeNameList.contains( name ) )
249249
{
@@ -779,7 +779,7 @@ namespace QgsWfs
779779
// parse FEATUREID
780780
if ( parameters.contains( QStringLiteral( "FEATUREID" ) ) )
781781
{
782-
QStringList fidList = parameters.value( QStringLiteral( "FEATUREID" ) ).split( QStringLiteral( "," ) );
782+
QStringList fidList = parameters.value( QStringLiteral( "FEATUREID" ) ).split( ',' );
783783

784784
QMap<QString, QgsFeatureIds> fidsMap;
785785

@@ -790,13 +790,13 @@ namespace QgsWfs
790790
QString fid = *fidIt;
791791
fid = fid.trimmed();
792792
// testing typename in the WFS featureID
793-
if ( !fid.contains( QLatin1String( "." ) ) )
793+
if ( !fid.contains( '.' ) )
794794
{
795795
throw QgsRequestNotWellFormedException( QStringLiteral( "FEATUREID has to have TYPENAME in the values" ) );
796796
}
797797

798-
QString typeName = fid.section( QStringLiteral( "." ), 0, 0 );
799-
fid = fid.section( QStringLiteral( "." ), 1, 1 );
798+
QString typeName = fid.section( '.', 0, 0 );
799+
fid = fid.section( '.', 1, 1 );
800800
if ( !typeNameList.contains( typeName ) )
801801
{
802802
typeNameList << typeName;
@@ -830,7 +830,7 @@ namespace QgsWfs
830830
throw QgsRequestNotWellFormedException( QStringLiteral( "TYPENAME is mandatory except if FEATUREID is used" ) );
831831
}
832832

833-
typeNameList = parameters.value( QStringLiteral( "TYPENAME" ) ).split( QStringLiteral( "," ) );
833+
typeNameList = parameters.value( QStringLiteral( "TYPENAME" ) ).split( ',' );
834834

835835
// Create actions based on TypeName
836836
QStringList::const_iterator typeNameIt = typeNameList.constBegin();
@@ -925,7 +925,7 @@ namespace QgsWfs
925925
bool ok;
926926
for ( int i = 0; i < 4; i++ )
927927
{
928-
corners[i].replace( QLatin1String( " " ), QLatin1String( "+" ) );
928+
corners[i].replace( ' ', '+' );
929929
d[i] = corners[i].toDouble( &ok );
930930
if ( !ok )
931931
{
@@ -1038,8 +1038,8 @@ namespace QgsWfs
10381038
transactionDelete parseDeleteActionElement( QDomElement &actionElem )
10391039
{
10401040
QString typeName = actionElem.attribute( QStringLiteral( "typeName" ) );
1041-
if ( typeName.contains( QLatin1String( ":" ) ) )
1042-
typeName = typeName.section( QStringLiteral( ":" ), 1, 1 );
1041+
if ( typeName.contains( ':' ) )
1042+
typeName = typeName.section( ':', 1, 1 );
10431043

10441044
QDomElement filterElem = actionElem.firstChild().toElement();
10451045
if ( filterElem.tagName() != QLatin1String( "Filter" ) )
@@ -1065,8 +1065,8 @@ namespace QgsWfs
10651065
transactionUpdate parseUpdateActionElement( QDomElement &actionElem )
10661066
{
10671067
QString typeName = actionElem.attribute( QStringLiteral( "typeName" ) );
1068-
if ( typeName.contains( QLatin1String( ":" ) ) )
1069-
typeName = typeName.section( QStringLiteral( ":" ), 1, 1 );
1068+
if ( typeName.contains( ':' ) )
1069+
typeName = typeName.section( ':', 1, 1 );
10701070

10711071
QDomNodeList propertyNodeList = actionElem.elementsByTagName( QStringLiteral( "Property" ) );
10721072
if ( propertyNodeList.size() != 1 )
@@ -1130,8 +1130,8 @@ namespace QgsWfs
11301130
for ( int i = 0; i < featureNodeList.count(); ++i )
11311131
{
11321132
QString tempTypeName = featureNodeList.at( i ).toElement().localName();
1133-
if ( tempTypeName.contains( QLatin1String( ":" ) ) )
1134-
tempTypeName = tempTypeName.section( QStringLiteral( ":" ), 1, 1 );
1133+
if ( tempTypeName.contains( ':' ) )
1134+
tempTypeName = tempTypeName.section( ':', 1, 1 );
11351135

11361136
if ( typeName.isEmpty() )
11371137
{

src/server/services/wfs/qgswfsutils.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ namespace QgsWfs
8585
fids.insert( fid.toInt() );
8686
}
8787

88-
if ( fids.size() > 0 )
88+
if ( !fids.isEmpty() )
8989
{
9090
request.setFilterFids( fids );
9191
}

src/server/services/wms/qgsdxfwriter.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ namespace QgsWms
3131
{
3232
QMap<QString, QString> options;
3333

34-
QStringList optionsList = optionString.split( QStringLiteral( ";" ) );
34+
QStringList optionsList = optionString.split( ';' );
3535
for ( auto optionsIt = optionsList.constBegin(); optionsIt != optionsList.constEnd(); ++optionsIt )
3636
{
37-
int equalIdx = optionsIt->indexOf( QLatin1String( ":" ) );
37+
int equalIdx = optionsIt->indexOf( ':' );
3838
if ( equalIdx > 0 && equalIdx < ( optionsIt->length() - 1 ) )
3939
{
4040
options.insert( optionsIt->left( equalIdx ).toUpper(),
@@ -54,7 +54,7 @@ namespace QgsWms
5454
QMap<QString, QString>::const_iterator layerAttributesIt = options.find( QStringLiteral( "LAYERATTRIBUTES" ) );
5555
if ( layerAttributesIt != options.constEnd() )
5656
{
57-
layerAttributes = options.value( QStringLiteral( "LAYERATTRIBUTES" ) ).split( QStringLiteral( "," ) );
57+
layerAttributes = options.value( QStringLiteral( "LAYERATTRIBUTES" ) ).split( ',' );
5858
}
5959

6060
//LAYERS and STYLES

0 commit comments

Comments
 (0)