LTP GCOV extension - code coverage report
Current view: directory - ogr/ogrsf_frmts/nas - nasreaderp.h
Test: gdal_filtered.info
Date: 2010-07-12 Instrumented lines: 7
Code covered: 71.4 % Executed lines: 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                 : 
      37                 : IGMLReader *CreateNASReader();
      38                 : 
      39                 : class NASReader;
      40                 : class OGRNASRelationLayer;
      41                 : 
      42                 : CPL_C_START
      43                 : OGRGeometryH OGR_G_CreateFromGML3( const char *pszGML );
      44                 : CPL_C_END
      45                 : 
      46                 : /************************************************************************/
      47                 : /*                              NASHandler                              */
      48                 : /************************************************************************/
      49                 : class NASHandler : public DefaultHandler 
      50                 : {
      51                 :     NASReader  *m_poReader;
      52                 : 
      53                 :     char       *m_pszCurField;
      54                 : 
      55                 :     char       *m_pszGeometry;
      56                 :     int        m_nGeomAlloc;
      57                 :     int        m_nGeomLen;
      58                 : 
      59                 :     int        m_nGeometryDepth;
      60                 :     int        IsGeometryElement( const char * );
      61                 : 
      62                 : public:
      63                 :     NASHandler( NASReader *poReader );
      64                 :     virtual ~NASHandler();
      65                 :     
      66                 :     void startElement(
      67                 :         const   XMLCh* const    uri,
      68                 :         const   XMLCh* const    localname,
      69                 :         const   XMLCh* const    qname,
      70                 :         const   Attributes& attrs
      71                 :     );
      72                 :     void endElement(
      73                 :         const   XMLCh* const    uri,
      74                 :         const   XMLCh* const    localname,
      75                 :         const   XMLCh* const    qname
      76                 :     );
      77                 : #if XERCES_VERSION_MAJOR >= 3
      78                 :     void characters( const XMLCh *const chars,
      79                 :                      const XMLSize_t length );
      80                 : #else
      81                 :     void characters( const XMLCh *const chars,
      82                 :                      const unsigned int length );
      83                 : #endif
      84                 : 
      85                 :     void fatalError(const SAXParseException&);
      86                 : };
      87                 : 
      88                 : /************************************************************************/
      89                 : /*                             GMLReadState                             */
      90                 : /************************************************************************/
      91                 : 
      92                 : // for now, use existing gmlreadstate.
      93                 : #ifdef notdef 
      94                 : class GMLReadState
      95                 : {
      96                 :     void        RebuildPath();
      97                 : 
      98                 : public:
      99                 :     GMLReadState();
     100                 :     ~GMLReadState();
     101                 : 
     102                 :     void        PushPath( const char *pszElement );
     103                 :     void        PopPath();
     104                 : 
     105                 :     int         MatchPath( const char *pszPathInput );
     106                 :     const char  *GetPath() const { return m_pszPath; }
     107                 :     const char  *GetLastComponent() const;
     108                 : 
     109                 :     GMLFeature  *m_poFeature;
     110                 :     GMLReadState *m_poParentState;
     111                 : 
     112                 :     char        *m_pszPath; // element path ... | as separator.
     113                 : 
     114                 :     int         m_nPathLength;
     115                 :     char        **m_papszPathComponents;
     116                 : };
     117                 : #endif
     118                 : 
     119                 : /************************************************************************/
     120                 : /*                              NASReader                               */
     121                 : /************************************************************************/
     122                 : 
     123                 : class NASReader : public IGMLReader 
     124                 : {
     125                 : private:
     126                 :     int           m_bClassListLocked;
     127                 : 
     128                 :     int         m_nClassCount;
     129                 :     GMLFeatureClass **m_papoClass;
     130                 : 
     131                 :     char          *m_pszFilename;
     132                 : 
     133                 :     NASHandler    *m_poNASHandler;
     134                 :     SAX2XMLReader *m_poSAXReader;
     135                 :     int           m_bReadStarted;
     136                 :     XMLPScanToken m_oToFill;
     137                 : 
     138                 :     GMLReadState *m_poState;
     139                 : 
     140                 :     GMLFeature   *m_poCompleteFeature;
     141                 : 
     142                 :     int           SetupParser();
     143                 :     void          CleanupParser();
     144                 : 
     145                 : public:
     146                 :                 NASReader();
     147                 :     virtual     ~NASReader();
     148                 : 
     149           16647 :     int              IsClassListLocked() const { return m_bClassListLocked; }
     150               1 :     void             SetClassListLocked( int bFlag )
     151               1 :         { m_bClassListLocked = bFlag; }
     152                 : 
     153                 :     void             SetSourceFile( const char *pszFilename );
     154                 :     const char      *GetSourceFileName();
     155                 : 
     156          563075 :     int              GetClassCount() const { return m_nClassCount; }
     157                 :     GMLFeatureClass *GetClass( int i ) const;
     158                 :     GMLFeatureClass *GetClass( const char *pszName ) const;
     159                 : 
     160                 :     int              AddClass( GMLFeatureClass *poClass );
     161                 :     void             ClearClasses();
     162                 : 
     163                 :     GMLFeature       *NextFeature();
     164                 : 
     165                 :     int              LoadClasses( const char *pszFile = NULL );
     166                 :     int              SaveClasses( const char *pszFile = NULL );
     167                 : 
     168                 :     int              PrescanForSchema(int bGetExtents = TRUE );
     169                 :     void             ResetReading();
     170                 : 
     171               0 :     int              ParseXSD( const char *pszFile ) { return FALSE; }
     172                 : 
     173                 :     int              ResolveXlinks( const char *pszFile,
     174                 :                                     int* pbOutIsTempFile,
     175                 :                                     char **papszSkip = NULL,
     176                 :                                     const int bStrict = FALSE );
     177                 : 
     178                 : // --- 
     179                 : 
     180         2225512 :     GMLReadState     *GetState() const { return m_poState; }
     181                 :     void             PopState();
     182                 :     void             PushState( GMLReadState * );
     183                 : 
     184                 :     int         IsFeatureElement( const char *pszElement );
     185                 :     int         IsAttributeElement( const char *pszElement );
     186                 : 
     187                 :     void        PushFeature( const char *pszElement, 
     188                 :                              const Attributes &attrs );
     189                 : 
     190                 :     void        SetFeatureProperty( const char *pszElement,
     191                 :                                     const char *pszValue );
     192                 : 
     193                 : 
     194                 :     void       AnalysePropertyValue( GMLPropertyDefn *poDefn,
     195                 :                                      const char *pszValue, 
     196                 :                                      const char *pszOldValue );
     197                 : 
     198               0 :     int         HasStoppedParsing() { return FALSE; }
     199                 : 
     200                 :     void        CheckForRelations( const char *pszElement, 
     201                 :                                    const Attributes &attrs );
     202                 : };
     203                 : 
     204                 : #endif /* _CPL_NASREADERP_H_INCLUDED */

Generated by: LTP GCOV extension version 1.5