1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689
|
/******************************************************************************
* $Id: ogr_sqlite.h 25694 2013-03-01 17:26:40Z rouault $
*
* Project: OpenGIS Simple Features Reference Implementation
* Purpose: Private definitions for OGR/SQLite driver.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2004, Frank Warmerdam <warmerdam@pobox.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#ifndef _OGR_SQLITE_H_INCLUDED
#define _OGR_SQLITE_H_INCLUDED
#include "ogrsf_frmts.h"
#include "cpl_error.h"
#include <map>
#include <set>
#ifdef HAVE_SPATIALITE
#ifdef SPATIALITE_AMALGAMATION
/*
/ using an AMALGAMATED version of SpatiaLite
/ a private internal copy of SQLite is included:
/ so we are required including the SpatiaLite's
/ own header
/
/ IMPORTANT NOTICE: using AMALAGATION is only
/ useful on Windows (to skip DLL hell related oddities)
*/
#include <spatialite/sqlite3.h>
#else
/*
/ You MUST NOT use AMALGAMATION on Linux or any
/ other "sane" operating system !!!!
*/
#include "sqlite3.h"
#endif
#else
#include "sqlite3.h"
#endif
#if SQLITE_VERSION_NUMBER >= 3006000
#define HAVE_SQLITE_VFS
#define HAVE_SQLITE3_PREPARE_V2
#endif
#define UNINITIALIZED_SRID -2
int OGRSQLiteIsSpatialiteLoaded();
int OGRSQLiteGetSpatialiteVersionNumber();
/************************************************************************/
/* Format used to store geometry data in the database. */
/************************************************************************/
enum OGRSQLiteGeomFormat
{
OSGF_None = 0,
OSGF_WKT = 1,
OSGF_WKB = 2,
OSGF_FGF = 3,
OSGF_SpatiaLite = 4
};
/************************************************************************/
/* SpatiaLite's own Geometry type IDs. */
/************************************************************************/
enum OGRSpatialiteGeomType
{
// 2D [XY]
OGRSplitePointXY = 1,
OGRSpliteLineStringXY = 2,
OGRSplitePolygonXY = 3,
OGRSpliteMultiPointXY = 4,
OGRSpliteMultiLineStringXY = 5,
OGRSpliteMultiPolygonXY = 6,
OGRSpliteGeometryCollectionXY = 7,
// 3D [XYZ]
OGRSplitePointXYZ = 1001,
OGRSpliteLineStringXYZ = 1002,
OGRSplitePolygonXYZ = 1003,
OGRSpliteMultiPointXYZ = 1004,
OGRSpliteMultiLineStringXYZ = 1005,
OGRSpliteMultiPolygonXYZ = 1006,
OGRSpliteGeometryCollectionXYZ = 1007,
// 2D with Measure [XYM]
OGRSplitePointXYM = 2001,
OGRSpliteLineStringXYM = 2002,
OGRSplitePolygonXYM = 2003,
OGRSpliteMultiPointXYM = 2004,
OGRSpliteMultiLineStringXYM = 2005,
OGRSpliteMultiPolygonXYM = 2006,
OGRSpliteGeometryCollectionXYM = 2007,
// 3D with Measure [XYZM]
OGRSplitePointXYZM = 3001,
OGRSpliteLineStringXYZM = 3002,
OGRSplitePolygonXYZM = 3003,
OGRSpliteMultiPointXYZM = 3004,
OGRSpliteMultiLineStringXYZM = 3005,
OGRSpliteMultiPolygonXYZM = 3006,
OGRSpliteGeometryCollectionXYZM = 3007,
// COMPRESSED: 2D [XY]
OGRSpliteComprLineStringXY = 1000002,
OGRSpliteComprPolygonXY = 1000003,
OGRSpliteComprMultiPointXY = 1000004,
OGRSpliteComprMultiLineStringXY = 1000005,
OGRSpliteComprMultiPolygonXY = 1000006,
OGRSpliteComprGeometryCollectionXY = 1000007,
// COMPRESSED: 3D [XYZ]
OGRSpliteComprLineStringXYZ = 1001002,
OGRSpliteComprPolygonXYZ = 1001003,
OGRSpliteComprMultiPointXYZ = 1001004,
OGRSpliteComprMultiLineStringXYZ = 1001005,
OGRSpliteComprMultiPolygonXYZ = 1001006,
OGRSpliteComprGeometryCollectionXYZ = 1001007,
// COMPRESSED: 2D with Measure [XYM]
OGRSpliteComprLineStringXYM = 1002002,
OGRSpliteComprPolygonXYM = 1002003,
OGRSpliteComprMultiPointXYM = 1002004,
OGRSpliteComprMultiLineStringXYM = 1002005,
OGRSpliteComprMultiPolygonXYM = 1002006,
OGRSpliteComprGeometryCollectionXYM = 1002007,
// COMPRESSED: 3D with Measure [XYZM]
OGRSpliteComprLineStringXYZM = 1003002,
OGRSpliteComprPolygonXYZM = 1003003,
OGRSpliteComprMultiPointXYZM = 1003004,
OGRSpliteComprMultiLineStringXYZM = 1003005,
OGRSpliteComprMultiPolygonXYZM = 1003006,
OGRSpliteComprGeometryCollectionXYZM = 1003007
};
/************************************************************************/
/* OGRSQLiteLayer */
/************************************************************************/
class OGRSQLiteDataSource;
class OGRSQLiteLayer : public OGRLayer
{
private:
static OGRErr createFromSpatialiteInternal(const GByte *pabyData,
OGRGeometry **ppoReturn,
int nBytes,
OGRwkbByteOrder eByteOrder,
int* pnBytesConsumed,
int nRecLevel);
static int CanBeCompressedSpatialiteGeometry(const OGRGeometry *poGeometry);
static int ComputeSpatiaLiteGeometrySize(const OGRGeometry *poGeometry,
int bHasM, int bSpatialite2D,
int bUseComprGeom );
static int GetSpatialiteGeometryCode(const OGRGeometry *poGeometry,
int bHasM, int bSpatialite2D,
int bUseComprGeom,
int bAcceptMultiGeom);
static int ExportSpatiaLiteGeometryInternal(const OGRGeometry *poGeometry,
OGRwkbByteOrder eByteOrder,
int bHasM, int bSpatialite2D,
int bUseComprGeom,
GByte* pabyData );
protected:
OGRFeatureDefn *poFeatureDefn;
// Layer spatial reference system, and srid.
OGRSpatialReference *poSRS;
int nSRSId;
int iNextShapeId;
sqlite3_stmt *hStmt;
int bDoStep;
OGRSQLiteDataSource *poDS;
int bTriedAsSpatiaLite;
CPLString osGeomColumn;
OGRSQLiteGeomFormat eGeomFormat;
char *pszFIDColumn;
int *panFieldOrdinals;
int iFIDCol;
int iGeomCol;
int bHasSpatialIndex;
int bHasM;
int bIsVirtualShape;
void BuildFeatureDefn( const char *pszLayerName,
sqlite3_stmt *hStmt,
const std::set<CPLString>& aosGeomCols);
void ClearStatement();
virtual OGRErr ResetStatement() = 0;
int bUseComprGeom;
char **papszCompressedColumns;
public:
OGRSQLiteLayer();
virtual ~OGRSQLiteLayer();
virtual void Finalize();
virtual void ResetReading();
virtual OGRFeature *GetNextRawFeature();
virtual OGRFeature *GetNextFeature();
virtual OGRFeature *GetFeature( long nFeatureId );
virtual OGRFeatureDefn *GetLayerDefn() { return poFeatureDefn; }
virtual OGRSpatialReference *GetSpatialRef();
virtual const char *GetFIDColumn();
virtual const char *GetGeometryColumn();
virtual int TestCapability( const char * );
virtual OGRErr StartTransaction();
virtual OGRErr CommitTransaction();
virtual OGRErr RollbackTransaction();
virtual void InvalidateCachedFeatureCountAndExtent() { }
virtual int IsTableLayer() { return FALSE; }
virtual int HasSpatialIndex() { return bHasSpatialIndex; }
virtual CPLString GetSpatialWhere(OGRGeometry* poFilterGeom) { return ""; }
static OGRErr ImportSpatiaLiteGeometry( const GByte *, int,
OGRGeometry ** );
static OGRErr ImportSpatiaLiteGeometry( const GByte *, int,
OGRGeometry **, int *pnSRID );
static OGRErr ExportSpatiaLiteGeometry( const OGRGeometry *,
GInt32, OGRwkbByteOrder,
int, int, int bUseComprGeom, GByte **, int * );
};
/************************************************************************/
/* OGRSQLiteTableLayer */
/************************************************************************/
class OGRSQLiteTableLayer : public OGRSQLiteLayer
{
int bLaunderColumnNames;
int bSpatialite2D;
CPLString osWHERE;
CPLString osQuery;
int bHasCheckedSpatialIndexTable;
int bDeferedSpatialIndexCreation;
OGRwkbGeometryType eGeomType;
char *pszTableName;
char *pszEscapedTableName;
CPLString osLayerName;
int bLayerDefnError;
sqlite3_stmt *hInsertStmt;
CPLString osLastInsertStmt;
void ClearInsertStmt();
void BuildWhere(void);
virtual OGRErr ResetStatement();
OGRErr AddColumnAncientMethod( OGRFieldDefn& oField);
void InitFieldListForRecrerate(char* & pszNewFieldList,
char* & pszFieldListForSelect,
int nExtraSpace = 0);
OGRErr RecreateTable(const char* pszFieldListForSelect,
const char* pszNewFieldList,
const char* pszGenericErrorMessage);
OGRErr BindValues( OGRFeature *poFeature,
sqlite3_stmt* hStmt,
int bBindNullValues );
int CheckSpatialIndexTable();
CPLErr EstablishFeatureDefn();
int bStatisticsNeedsToBeFlushed;
OGREnvelope oCachedExtent;
int bCachedExtentIsValid;
GIntBig nFeatureCount; /* if -1, means not up-to-date */
void LoadStatistics();
void LoadStatisticsSpatialite4DB();
CPLString FieldDefnToSQliteFieldDefn( OGRFieldDefn* poFieldDefn );
public:
OGRSQLiteTableLayer( OGRSQLiteDataSource * );
~OGRSQLiteTableLayer();
CPLErr Initialize( const char *pszTableName,
const char *pszGeomCol,
int bMustIncludeGeomColName,
OGRwkbGeometryType eGeomType,
const char *pszGeomFormat,
OGRSpatialReference *poSRS,
int nSRSId = UNINITIALIZED_SRID,
int bHasSpatialIndex = FALSE,
int bHasM = FALSE,
int bIsVirtualShapeIn = FALSE);
virtual const char* GetName();
virtual OGRwkbGeometryType GetGeomType() { return (eGeomType != wkbUnknown) ? eGeomType : OGRLayer::GetGeomType(); }
virtual int GetFeatureCount( int );
virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce);
virtual OGRFeatureDefn *GetLayerDefn();
int HasLayerDefnError() { GetLayerDefn(); return bLayerDefnError; }
virtual void SetSpatialFilter( OGRGeometry * );
virtual OGRErr SetAttributeFilter( const char * );
virtual OGRErr SetFeature( OGRFeature *poFeature );
virtual OGRErr DeleteFeature( long nFID );
virtual OGRErr CreateFeature( OGRFeature *poFeature );
virtual OGRErr CreateField( OGRFieldDefn *poField,
int bApproxOK = TRUE );
virtual OGRErr DeleteField( int iField );
virtual OGRErr ReorderFields( int* panMap );
virtual OGRErr AlterFieldDefn( int iField, OGRFieldDefn* poNewFieldDefn, int nFlags );
virtual OGRFeature *GetNextFeature();
virtual OGRFeature *GetFeature( long nFeatureId );
virtual int TestCapability( const char * );
// follow methods are not base class overrides
void SetLaunderFlag( int bFlag )
{ bLaunderColumnNames = bFlag; }
void SetUseCompressGeom( int bFlag )
{ bUseComprGeom = bFlag; }
void SetDeferedSpatialIndexCreation( int bFlag )
{ bDeferedSpatialIndexCreation = bFlag; }
void SetCompressedColumns( const char* pszCompressedColumns );
int CreateSpatialIndex();
void CreateSpatialIndexIfNecessary();
void InitFeatureCount();
int DoStatisticsNeedToBeFlushed();
void ForceStatisticsToBeFlushed();
int AreStatisticsValid();
int SaveStatistics();
virtual void InvalidateCachedFeatureCountAndExtent();
virtual int IsTableLayer() { return TRUE; }
virtual int HasSpatialIndex();
virtual CPLString GetSpatialWhere(OGRGeometry* poFilterGeom);
};
/************************************************************************/
/* OGRSQLiteViewLayer */
/************************************************************************/
class OGRSQLiteViewLayer : public OGRSQLiteLayer
{
CPLString osWHERE;
CPLString osQuery;
int bHasCheckedSpatialIndexTable;
char *pszViewName;
char *pszEscapedTableName;
char *pszEscapedUnderlyingTableName;
int bLayerDefnError;
CPLString osUnderlyingTableName;
CPLString osUnderlyingGeometryColumn;
OGRSQLiteLayer *poUnderlyingLayer;
OGRSQLiteLayer *GetUnderlyingLayer();
void BuildWhere(void);
virtual OGRErr ResetStatement();
CPLErr EstablishFeatureDefn();
public:
OGRSQLiteViewLayer( OGRSQLiteDataSource * );
~OGRSQLiteViewLayer();
virtual const char* GetName() { return pszViewName; }
virtual OGRwkbGeometryType GetGeomType();
CPLErr Initialize( const char *pszViewName,
const char *pszViewGeometry,
const char *pszViewRowid,
const char *pszTableName,
const char *pszGeometryColumn);
virtual OGRFeatureDefn *GetLayerDefn();
int HasLayerDefnError() { GetLayerDefn(); return bLayerDefnError; }
virtual OGRFeature *GetNextFeature();
virtual int GetFeatureCount( int );
virtual void SetSpatialFilter( OGRGeometry * );
virtual OGRErr SetAttributeFilter( const char * );
virtual OGRFeature *GetFeature( long nFeatureId );
virtual int TestCapability( const char * );
virtual OGRSpatialReference *GetSpatialRef();
virtual CPLString GetSpatialWhere(OGRGeometry* poFilterGeom);
};
/************************************************************************/
/* OGRSQLiteSelectLayer */
/************************************************************************/
class OGRSQLiteSelectLayer : public OGRSQLiteLayer
{
CPLString osSQLBase;
CPLString osSQLCurrent;
int bEmptyLayer;
int bSpatialFilterInSQL;
virtual OGRErr ResetStatement();
OGRSQLiteLayer *GetBaseLayer(size_t& i);
int RebuildSQLWithSpatialClause();
int bAllowResetReadingEvenIfIndexAtZero;
public:
OGRSQLiteSelectLayer( OGRSQLiteDataSource *,
CPLString osSQL,
sqlite3_stmt *,
int bUseStatementForGetNextFeature,
int bEmptyLayer );
virtual void ResetReading();
virtual OGRFeature *GetNextFeature();
virtual int GetFeatureCount( int );
virtual void SetSpatialFilter( OGRGeometry * );
virtual int TestCapability( const char * );
virtual OGRErr GetExtent(OGREnvelope *psExtent, int bForce);
};
/************************************************************************/
/* OGRSQLiteSingleFeatureLayer */
/************************************************************************/
class OGRSQLiteSingleFeatureLayer : public OGRLayer
{
private:
int nVal;
char *pszVal;
OGRFeatureDefn *poFeatureDefn;
int iNextShapeId;
public:
OGRSQLiteSingleFeatureLayer( const char* pszLayerName,
int nVal );
OGRSQLiteSingleFeatureLayer( const char* pszLayerName,
const char *pszVal );
~OGRSQLiteSingleFeatureLayer();
virtual void ResetReading();
virtual OGRFeature *GetNextFeature();
virtual OGRFeatureDefn *GetLayerDefn();
virtual int TestCapability( const char * );
};
/************************************************************************/
/* OGRSQLiteDataSource */
/************************************************************************/
class OGRSQLiteDataSource : public OGRDataSource
{
OGRSQLiteLayer **papoLayers;
int nLayers;
char *pszName;
sqlite3 *hDB;
int bUpdate;
int nSoftTransactionLevel;
// We maintain a list of known SRID to reduce the number of trips to
// the database to get SRSes.
int nKnownSRID;
int *panSRID;
OGRSpatialReference **papoSRS;
void AddSRIDToCache(int nId, OGRSpatialReference * poSRS );
int bHaveGeometryColumns;
int bIsSpatiaLiteDB;
int bSpatialite4Layout;
int nUndefinedSRID;
virtual void DeleteLayer( const char *pszLayer );
const char* GetSRTEXTColName();
int OpenOrCreateDB(int flags);
int InitWithEPSG();
int SetSynchronous();
int SetCacheSize();
int OpenVirtualTable(const char* pszName, const char* pszSQL);
#ifdef HAVE_SQLITE_VFS
sqlite3_vfs* pMyVFS;
#endif
VSILFILE* fpMainFile; /* Set by the VFS layer when it opens the DB */
/* Must *NOT* be closed by the datasource explicitly. */
GIntBig nFileTimestamp;
int bLastSQLCommandIsUpdateLayerStatistics;
std::map<CPLString, OGREnvelope> oMapSQLEnvelope;
std::map< CPLString, std::set<CPLString> > aoMapTableToSetOfGeomCols;
void SaveStatistics();
public:
OGRSQLiteDataSource();
~OGRSQLiteDataSource();
int Open( const char *, int bUpdateIn );
int Create( const char *, char **papszOptions );
int OpenTable( const char *pszTableName,
const char *pszGeomCol = NULL,
int bMustIncludeGeomColName = FALSE,
OGRwkbGeometryType eGeomType = wkbUnknown,
const char *pszGeomFormat = NULL,
OGRSpatialReference *poSRS = NULL,
int nSRID = UNINITIALIZED_SRID,
int bHasSpatialIndex = FALSE,
int bHasM = FALSE,
int bIsVirtualShapeIn = FALSE );
int OpenView( const char *pszViewName,
const char *pszViewGeometry,
const char *pszViewRowid,
const char *pszTableName,
const char *pszGeometryColumn);
virtual const char *GetName() { return pszName; }
virtual int GetLayerCount() { return nLayers; }
virtual OGRLayer *GetLayer( int );
virtual OGRLayer *GetLayerByName( const char* );
virtual OGRLayer *CreateLayer( const char *pszLayerName,
OGRSpatialReference *poSRS,
OGRwkbGeometryType eType,
char **papszOptions );
virtual OGRErr DeleteLayer(int);
virtual int TestCapability( const char * );
virtual OGRLayer * ExecuteSQL( const char *pszSQLCommand,
OGRGeometry *poSpatialFilter,
const char *pszDialect );
virtual void ReleaseResultSet( OGRLayer * poLayer );
OGRErr SoftStartTransaction();
OGRErr SoftCommit();
OGRErr SoftRollback();
OGRErr FlushSoftTransaction();
sqlite3 *GetDB() { return hDB; }
char *LaunderName( const char * );
int FetchSRSId( OGRSpatialReference * poSRS );
OGRSpatialReference*FetchSRS( int nSRID );
int GetUpdate() const { return bUpdate; }
void SetUpdate(int bUpdateIn) { bUpdate = bUpdateIn; }
void SetName(const char* pszNameIn);
void NotifyFileOpened (const char* pszFilename,
VSILFILE* fp);
const OGREnvelope* GetEnvelopeFromSQL(const CPLString& osSQL);
void SetEnvelopeForSQL(const CPLString& osSQL, const OGREnvelope& oEnvelope);
const std::set<CPLString>& GetGeomColsForTable(const char* pszTableName)
{ return aoMapTableToSetOfGeomCols[pszTableName]; }
GIntBig GetFileTimestamp() const { return nFileTimestamp; }
int IsSpatialiteDB() const { return bIsSpatiaLiteDB; }
int HasSpatialite4Layout() const { return bSpatialite4Layout; }
int GetUndefinedSRID() const { return nUndefinedSRID; }
void ReloadLayers();
};
/************************************************************************/
/* OGRSQLiteDriver */
/************************************************************************/
class OGRSQLiteDriver : public OGRSFDriver
{
public:
~OGRSQLiteDriver();
const char *GetName();
OGRDataSource *Open( const char *, int );
virtual OGRDataSource *CreateDataSource( const char *pszName,
char ** = NULL );
virtual OGRErr DeleteDataSource( const char *pszName );
int TestCapability( const char * );
};
/* To escape literals. The returned string doesn't contain the surrounding single quotes */
CPLString OGRSQLiteEscape( const char *pszLiteral );
/* To escape table or field names. The returned string doesn't contain the surrounding double quotes */
CPLString OGRSQLiteEscapeName( const char* pszName );
CPLString OGRSQLiteParamsUnquote(const char* pszVal);
CPLString OGRSQLiteFieldDefnToSQliteFieldDefn( OGRFieldDefn* poFieldDefn );
int OGRSQLITEStringToDateTimeField( OGRFeature* poFeature, int iField,
const char* pszValue );
#ifdef HAVE_SQLITE_VFS
typedef void (*pfnNotifyFileOpenedType)(void* pfnUserData, const char* pszFilename, VSILFILE* fp);
sqlite3_vfs* OGRSQLiteCreateVFS(pfnNotifyFileOpenedType pfn, void* pfnUserData);
#endif
void OGRSQLiteRegisterInflateDeflate(sqlite3* hDB);
#endif /* ndef _OGR_SQLITE_H_INCLUDED */
|