Skip to content

Commit 13c9e1d

Browse files
committedAug 22, 2017
OGR provider: moved QgsCPLErrorHandler to its own header file
This is being reused in gpkg data items
1 parent ab2589b commit 13c9e1d

File tree

2 files changed

+49
-25
lines changed

2 files changed

+49
-25
lines changed
 
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/***************************************************************************
2+
qgscplerrorhandler.h - QgsCplErrorHandler
3+
4+
---------------------
5+
begin : Oct 29, 2003
6+
copyright : (C) 2003 by Gary E.Sherman
7+
email : sherman at mrcc.com
8+
***************************************************************************
9+
* *
10+
* This program is free software; you can redistribute it and/or modify *
11+
* it under the terms of the GNU General Public License as published by *
12+
* the Free Software Foundation; either version 2 of the License, or *
13+
* (at your option) any later version. *
14+
* *
15+
***************************************************************************/
16+
#ifndef QGSCPLERRORHANDLER_H
17+
#define QGSCPLERRORHANDLER_H
18+
19+
#include "gdal.h"
20+
#include "qgsmessagelog.h"
21+
22+
class QgsCPLErrorHandler
23+
{
24+
static void CPL_STDCALL showError( CPLErr errClass, int errNo, const char *msg )
25+
{
26+
if ( errNo != OGRERR_NONE )
27+
QgsMessageLog::logMessage( QObject::tr( "OGR[%1] error %2: %3" ).arg( errClass ).arg( errNo ).arg( msg ), QObject::tr( "OGR" ) );
28+
}
29+
30+
public:
31+
QgsCPLErrorHandler()
32+
{
33+
CPLPushErrorHandler( showError );
34+
}
35+
36+
~QgsCPLErrorHandler()
37+
{
38+
CPLPopErrorHandler();
39+
}
40+
41+
private:
42+
QgsCPLErrorHandler( const QgsCPLErrorHandler &other );
43+
QgsCPLErrorHandler &operator=( const QgsCPLErrorHandler &other );
44+
45+
};
46+
47+
48+
#endif // QGSCPLERRORHANDLER_H

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ email : sherman at mrcc.com
1616
***************************************************************************/
1717

1818
#include "qgsogrprovider.h"
19+
#include "qgscplerrorhandler.h"
1920
#include "qgsogrfeatureiterator.h"
2021
#include "qgslogger.h"
2122
#include "qgsmessagelog.h"
@@ -80,31 +81,6 @@ static const QString TEXT_PROVIDER_DESCRIPTION =
8081
8182
static OGRwkbGeometryType ogrWkbGeometryTypeFromName( const QString &typeName );
8283
83-
class QgsCPLErrorHandler
84-
{
85-
static void CPL_STDCALL showError( CPLErr errClass, int errNo, const char *msg )
86-
{
87-
if ( errNo != OGRERR_NONE )
88-
QgsMessageLog::logMessage( QObject::tr( "OGR[%1] error %2: %3" ).arg( errClass ).arg( errNo ).arg( msg ), QObject::tr( "OGR" ) );
89-
}
90-
91-
public:
92-
QgsCPLErrorHandler()
93-
{
94-
CPLPushErrorHandler( showError );
95-
}
96-
97-
~QgsCPLErrorHandler()
98-
{
99-
CPLPopErrorHandler();
100-
}
101-
102-
private:
103-
QgsCPLErrorHandler( const QgsCPLErrorHandler &other );
104-
QgsCPLErrorHandler &operator=( const QgsCPLErrorHandler &other );
105-
106-
};
107-
10884
10985
bool QgsOgrProvider::convertField( QgsField &field, const QTextCodec &encoding )
11086
{

0 commit comments

Comments
 (0)
Please sign in to comment.