LCOV - code coverage report
Current view: directory - ogr/ogrsf_frmts/nas - nasreaderp.h (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 9 6 66.7 %
Date: 2011-12-18 Functions: 8 5 62.5 %

       1                 : /******************************************************************************
       2                 :  * $Id: gmlreaderp.h 10645 2007-01-18 02:22:39Z warmerdam $
       3                 :  *
       4                 :  * Project:  NAS Reader
       5                 :  * Purpose:  Private Declarations for OGR NAS Reader code.
       6                 :  * Author:   Frank Warmerdam, warmerdam@pobox.com
       7                 :  *
       8                 :  ******************************************************************************
       9                 :  * Copyright (c) 2008, Frank Warmerdam
      10                 :  *
      11                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      12                 :  * copy of this software and associated documentation files (the "Software"),
      13                 :  * to deal in the Software without restriction, including without limitation
      14                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      15                 :  * and/or sell copies of the Software, and to permit persons to whom the
      16                 :  * Software is furnished to do so, subject to the following conditions:
      17                 :  * 
      18                 :  * The above copyright notice and this permission notice shall be included
      19                 :  * in all copies or substantial portions of the Software.
      20                 :  * 
      21                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      22                 :  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      23                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
      24                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      25                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      26                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
      27                 :  * DEALINGS IN THE SOFTWARE.
      28                 :  ****************************************************************************/
      29                 : 
      30                 : #ifndef _CPL_NASREADERP_H_INCLUDED
      31                 : #define _CPL_NASREADERP_H_INCLUDED
      32                 : 
      33                 : #include "gmlreader.h"
      34                 : #include "gmlreaderp.h"
      35                 : #include "ogr_api.h"
      36                 : #include "cpl_string.h"
      37                 : 
      38                 : IGMLReader *CreateNASReader();
      39                 : 
      40                 : class NASReader;
      41                 : class OGRNASRelationLayer;
      42                 : 
      43                 : CPL_C_START
      44                 : OGRGeometryH OGR_G_CreateFromGML3( const char *pszGML );
      45                 : CPL_C_END
      46                 : 
      47                 : /************************************************************************/
      48                 : /*                              NASHandler                              */
      49                 : /************************************************************************/
      50                 : class NASHandler : public DefaultHandler 
      51                 : {
      52                 :     NASReader  *m_poReader;
      53                 : 
      54                 :     char       *m_pszCurField;
      55                 : 
      56                 :     char       *m_pszGeometry;
      57                 :     int        m_nGeomAlloc;
      58                 :     int        m_nGeomLen;
      59                 : 
      60                 :     int        m_nGeometryDepth;
      61                 :     int        IsGeometryElement( const char * );
      62                 : 
      63                 :     int        m_nDepth;
      64                 :     int        m_nDepthFeature;
      65                 :     int        m_bIgnoreFeature;
      66                 : 
      67                 :     CPLString  m_osLastTypeName;
      68                 : 
      69                 : public:
      70                 :     NASHandler( NASReader *poReader );
      71                 :     virtual ~NASHandler();
      72                 :     
      73                 :     void startElement(
      74                 :         const   XMLCh* const    uri,
      75                 :         const   XMLCh* const    localname,
      76                 :         const   XMLCh* const    qname,
      77                 :         const   Attributes& attrs
      78                 :     );
      79                 :     void endElement(
      80                 :         const   XMLCh* const    uri,
      81                 :         const   XMLCh* const    localname,
      82                 :         const   XMLCh* const    qname
      83                 :     );
      84                 : #if XERCES_VERSION_MAJOR >= 3
      85                 :     void characters( const XMLCh *const chars,
      86                 :                      const XMLSize_t length );
      87                 : #else
      88                 :     void characters( const XMLCh *const chars,
      89                 :                      const unsigned int length );
      90                 : #endif
      91                 : 
      92                 :     void fatalError(const SAXParseException&);
      93                 : 
      94                 :     CPLString GetAttributes( const Attributes* attr );
      95                 : };
      96                 : 
      97                 : /************************************************************************/
      98                 : /*                             GMLReadState                             */
      99                 : /************************************************************************/
     100                 : 
     101                 : // for now, use existing gmlreadstate.
     102                 : #ifdef notdef 
     103                 : class GMLReadState
     104                 : {
     105                 :     void        RebuildPath();
     106                 : 
     107                 : public:
     108                 :     GMLReadState();
     109                 :     ~GMLReadState();
     110                 : 
     111                 :     void        PushPath( const char *pszElement );
     112                 :     void        PopPath();
     113                 : 
     114                 :     int         MatchPath( const char *pszPathInput );
     115                 :     const char  *GetPath() const { return m_pszPath; }
     116                 :     const char  *GetLastComponent() const;
     117                 : 
     118                 :     GMLFeature  *m_poFeature;
     119                 :     GMLReadState *m_poParentState;
     120                 : 
     121                 :     char        *m_pszPath; // element path ... | as separator.
     122                 : 
     123                 :     int         m_nPathLength;
     124                 :     char        **m_papszPathComponents;
     125                 : };
     126                 : #endif
     127                 : 
     128                 : /************************************************************************/
     129                 : /*                              NASReader                               */
     130                 : /************************************************************************/
     131                 : 
     132                 : class NASReader : public IGMLReader 
     133                 : {
     134                 : private:
     135                 :     int           m_bClassListLocked;
     136                 : 
     137                 :     int         m_nClassCount;
     138                 :     GMLFeatureClass **m_papoClass;
     139                 : 
     140                 :     char          *m_pszFilename;
     141                 : 
     142                 :     NASHandler    *m_poNASHandler;
     143                 :     SAX2XMLReader *m_poSAXReader;
     144                 :     int           m_bReadStarted;
     145                 :     XMLPScanToken m_oToFill;
     146                 : 
     147                 :     GMLReadState *m_poState;
     148                 : 
     149                 :     GMLFeature   *m_poCompleteFeature;
     150                 : 
     151                 :     int           SetupParser();
     152                 :     void          CleanupParser();
     153                 : 
     154                 :     char         *m_pszFilteredClassName;
     155                 : 
     156                 : public:
     157                 :                 NASReader();
     158                 :     virtual     ~NASReader();
     159                 : 
     160           69649 :     int              IsClassListLocked() const { return m_bClassListLocked; }
     161               5 :     void             SetClassListLocked( int bFlag )
     162               5 :         { m_bClassListLocked = bFlag; }
     163                 : 
     164                 :     void             SetSourceFile( const char *pszFilename );
     165                 :     const char      *GetSourceFileName();
     166                 : 
     167         1249720 :     int              GetClassCount() const { return m_nClassCount; }
     168                 :     GMLFeatureClass *GetClass( int i ) const;
     169                 :     GMLFeatureClass *GetClass( const char *pszName ) const;
     170                 : 
     171                 :     int              AddClass( GMLFeatureClass *poClass );
     172                 :     void             ClearClasses();
     173                 : 
     174                 :     GMLFeature       *NextFeature();
     175                 : 
     176                 :     int              LoadClasses( const char *pszFile = NULL );
     177                 :     int              SaveClasses( const char *pszFile = NULL );
     178                 : 
     179                 :     int              PrescanForSchema(int bGetExtents = TRUE );
     180                 :     int              PrescanForTemplate( void );
     181                 :     void             ResetReading();
     182                 : 
     183                 :     int              ParseXSD( const char *pszFile ) { return FALSE; }
     184                 : 
     185                 :     int              ResolveXlinks( const char *pszFile,
     186                 :                                     int* pbOutIsTempFile,
     187                 :                                     char **papszSkip = NULL,
     188                 :                                     const int bStrict = FALSE );
     189                 : 
     190                 :     int              HugeFileResolver( const char *pszFile,
     191                 :                                        int bSqliteIsTempFile,
     192                 :                                        int iSqliteCacheMB );
     193                 : 
     194                 : // --- 
     195                 : 
     196         4556455 :     GMLReadState     *GetState() const { return m_poState; }
     197                 :     void             PopState();
     198                 :     void             PushState( GMLReadState * );
     199                 : 
     200                 :     int         IsFeatureElement( const char *pszElement );
     201                 :     int         IsAttributeElement( const char *pszElement );
     202                 : 
     203                 :     void        PushFeature( const char *pszElement, 
     204                 :                              const Attributes &attrs );
     205                 : 
     206                 :     void        SetFeaturePropertyDirectly( const char *pszElement,
     207                 :                                     char *pszValue );
     208                 : 
     209               0 :     int         HasStoppedParsing() { return FALSE; }
     210                 : 
     211                 :     void        CheckForFID( const Attributes &attrs, char **ppszCurField );
     212                 :     void        CheckForRelations( const char *pszElement, 
     213                 :                                    const Attributes &attrs );
     214                 : 
     215               0 :     virtual const char* GetGlobalSRSName() { return NULL; }
     216                 : 
     217               0 :     virtual int         CanUseGlobalSRSName() { return FALSE; }
     218                 : 
     219                 :     int         SetFilteredClassName(const char* pszClassName);
     220           69652 :     const char* GetFilteredClassName() { return m_pszFilteredClassName; }
     221                 : };
     222                 : 
     223                 : #endif /* _CPL_NASREADERP_H_INCLUDED */

Generated by: LCOV version 1.7