This file is indexed.

/usr/include/qgis/qgsgmlschema.h is in libqgis-dev 2.4.0-1+b1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
/***************************************************************************
     qgsgmlschema.h
     --------------------------------------
    Date                 : Sun Sep 16 12:19:55 AKDT 2007
    Copyright            : (C) 2007 by Gary E. Sherman
    Email                : sherman at mrcc dot com
 ***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef QGSGMLSCHEMA_H
#define QGSGMLSCHEMA_H

#include <expat.h>
#include "qgis.h"
#include "qgsapplication.h"
#include "qgsdataprovider.h"
#include "qgserror.h"
#include "qgsfeature.h"
#include "qgsfield.h"
#include "qgslogger.h"
#include "qgspoint.h"
#include <list>
#include <set>
#include <stack>
#include <QPair>
#include <QByteArray>
#include <QDomElement>
#include <QStringList>
#include <QStack>
class QgsRectangle;
class QgsCoordinateReferenceSystem;

/* Description of feature class in GML */
class CORE_EXPORT QgsGmlFeatureClass
{
  public:
    QgsGmlFeatureClass( );
    QgsGmlFeatureClass( QString name, QString path );

    ~QgsGmlFeatureClass();

    QList<QgsField> & fields() { return  mFields; }

    int fieldIndex( const QString & name );

    QString path() const { return mPath; }

    QStringList & geometryAttributes() { return mGeometryAttributes; }

  private:
    /* Feature class name:
     *  - element name without NS or known prefix/suffix (_feature)
     *  - typeName attribute name */
    QString mName;

    //QString mElementName;

    /* Dot separated path to element including the name */
    QString mPath;

    /* Fields */
    // Do not use QMap to keep original fields order. If it gets to performance,
    // add a field index map
    QList<QgsField> mFields;

    /* Geometry attribute */
    QStringList mGeometryAttributes;
};

class CORE_EXPORT QgsGmlSchema : public QObject
{
    Q_OBJECT
  public:
    QgsGmlSchema();

    ~QgsGmlSchema();

    /** Get fields info from XSD */
    bool parseXSD( const QByteArray &xml );

    /** Guess GML schema from data if XSD does not exist.
      * Currently only recognizes UMN Mapserver GetFeatureInfo GML response.
      * Supports only UTF-8, UTF-16, ISO-8859-1, US-ASCII XML encodings.
      * @param data GML data
      * @return true in case of success */
    bool guessSchema( const QByteArray &data );

    /** Get list of dot separated paths to feature classes parsed from GML or XSD */
    QStringList typeNames() const;

    /** Get fields for type/class name parsed from GML or XSD */
    QList<QgsField> fields( const QString & typeName );

    /** Get list of geometry attributes for type/class name */
    QStringList geometryAttributes( const QString & typeName );

    /** Get error if parseXSD() or guessSchema() failed */
    QgsError error() const { return mError; }

  private:

    enum ParseMode
    {
      none,
      boundingBox,
      featureMembers, // gml:featureMembers
      featureMember, // gml:featureMember
      feature,  // feature element containint attrs and geo (inside gml:featureMember)
      attribute,
      geometry
    };

    /**XML handler methods*/
    void startElement( const XML_Char* el, const XML_Char** attr );
    void endElement( const XML_Char* el );
    void characters( const XML_Char* chars, int len );
    static void start( void* data, const XML_Char* el, const XML_Char** attr )
    {
      static_cast<QgsGmlSchema*>( data )->startElement( el, attr );
    }
    static void end( void* data, const XML_Char* el )
    {
      static_cast<QgsGmlSchema*>( data )->endElement( el );
    }
    static void chars( void* data, const XML_Char* chars, int len )
    {
      static_cast<QgsGmlSchema*>( data )->characters( chars, len );
    }
    // Add attribute or reset its type according to value of current feature
    void addAttribute( const QString& name, const QString& value );

    //helper routines

    /**Reads attribute as string
      @return attribute value or an empty string if no such attribute*/
    QString readAttribute( const QString& attributeName, const XML_Char** attr ) const;

    /**Returns pointer to main window or 0 if it does not exist*/
    QWidget* findMainWindow() const;

    /** Get dom elements by path */
    QList<QDomElement> domElements( const QDomElement &element, const QString & path );

    /** Get dom element by path */
    QDomElement domElement( const QDomElement &element, const QString & path );

    /** Filter list of elements by attribute value */
    QList<QDomElement> domElements( QList<QDomElement> &elements, const QString & attr, const QString & attrVal );

    /** Get dom element by path and attribute value */
    QDomElement domElement( const QDomElement &element, const QString & path, const QString & attr, const QString & attrVal );

    /** Strip namespace from element name */
    QString stripNS( const QString & name );

    /** Find GML base type for complex type of given name
     * @param element input element
     * @param name complex type name
     * @return name of GML base type without NS, e.g. AbstractFeatureType or empty string if not passed on GML type
     */
    QString xsdComplexTypeGmlBaseType( const QDomElement &element, const QString & name );

    /** Get feature class information from complex type recursively */
    bool xsdFeatureClass( const QDomElement &element, const QString & typeName, QgsGmlFeatureClass & featureClass );


    /** Get safely (if empty) top from mode stack */
    ParseMode modeStackTop() { return mParseModeStack.isEmpty() ? none : mParseModeStack.top(); }

    /** Safely (if empty) pop from mode stack */
    ParseMode modeStackPop() { return mParseModeStack.isEmpty() ? none : mParseModeStack.pop(); }

    /**Keep track about the most important nested elements*/
    //std::stack<ParseMode> mParseModeStack;
    QStack<ParseMode> mParseModeStack;
    /**This contains the character data if an important element has been encountered*/
    QString mStringCash;
    QgsFeature* mCurrentFeature;
    QString mCurrentFeatureId;
    int mFeatureCount;
    QString mAttributeName;
    /**Coordinate separator for coordinate strings. Usually "," */
    QString mCoordinateSeparator;
    /**Tuple separator for coordinate strings. Usually " " */
    QString mTupleSeparator;

    /* Schema information guessed/parsed from GML in getSchema() */

    /** Depth level, root element is 0 */
    int mLevel;

    /** Skip all levels under this */
    int mSkipLevel;

    /** Path to current level */
    QStringList mParsePathStack;

    QString mCurrentFeatureName;

    // List of know geometries (Point, Multipoint,...)
    QStringList mGeometryTypes;

    /* Feature classes map with element paths as keys */
    QMap<QString, QgsGmlFeatureClass> mFeatureClassMap;

    /* Error set if something failed */
    QgsError mError;
};

#endif