- Main Page
- Related Pages
- Modules
- Classes
- Files

# Flags.h

Go to the documentation of this file.

    00001 #ifndef FDO_XML_FLAGS_H
    00002 #define FDO_XML_FLAGS_H
    00003
    00004 //
    00005 // Copyright (C) 2004-2006  Autodesk, Inc.
    00006 //
    00007 // This library is free software; you can redistribute it and/or
    00008 // modify it under the terms of version 2.1 of the GNU Lesser
    00009 // General Public License as published by the Free Software Foundation.
    00010 //
    00011 // This library is distributed in the hope that it will be useful,
    00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014 // Lesser General Public License for more details.
    00015 //
    00016 // You should have received a copy of the GNU Lesser General Public
    00017 // License along with this library; if not, write to the Free Software
    00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    00019 //
    00020
    00021 #include <FdoStd.h>
    00022
    00023 class FdoPhysicalSchemaMappingCollection;
    00024
    00025 /// \brief
    00026 /// FdoXmlFlags defines various options for serializing and deserializing
    00027 /// FDO element to and from XML Documents.
    00028 class FdoXmlFlags : public FdoIDisposable
    00029 {
    00030 public:
    00031     /// \brief
    00032     /// The FdoXmlFlags::ErrorLevel determines how strict the error reporting
    00033     /// is when a Feature Schema is read from an XML Document. For each errorLevel a
    00034     /// certain level of round-trip fidelity is guaranteed if the read succeeds.
    00035     /// \param ErrorLevel_VeryLow
    00036     /// the read succeeds even if no level of
    00037     /// round-trip fidelity is maintained. If the Feature Schema is read successfully
    00038     /// from document A and then written to document B, any instance document that
    00039     /// conforms to the document A schema may or may not conform to the document B
    00040     /// schema. A document that does not conform to the A schema may or may not
    00041     /// conform to the B schema. This errorLevel is useful for reading schemas from
    00042     /// external sources into FDO when it doesn’t matter how much the schemas are
    00043     /// altered during the read.
    00044     ///
    00045     enum ErrorLevel {
    00046             /// The read fails with an exception when the Feature Schema cannot be read without alteration.
    00047         /// If the Feature Schema is read successfully from document A and then written to document B,
    00048             /// documents A and B are guaranteed to be identical.
    00049         /// This errorLevel should be used when no alterations to the Feature Schema can be tolerated
    00050         ErrorLevel_High,
    00051             /// Fails if the Feature Schema cannot be read
    00052             /// without changing the domain of its conforming instance documents.
    00053         /// If the Feature Schema is read successfully from document A
    00054         /// and then written to document B,
    00055             /// any instance document that conforms to the document A schema
    00056             /// will also conform to the document B schema.
    00057         /// Any instance document that does not conform to A does not conform to B.
    00058         /// However, documents A and B will not necessarily be identical.
    00059         ErrorLevel_Normal,
    00060             /// Similar to ErrorLevel_Normal except that the
    00061             /// instance document domain is allowed to grow.
    00062         /// If the Feature Schema is read
    00063             /// successfully from document A and then written to document B,
    00064         /// any instance document that conforms to the document A schema will also conform to the document B schema.
    00065         /// However a document that does not conform to the A schema
    00066             /// may or may not conform to the B schema.
    00067         ErrorLevel_Low,
    00068             /// The read succeeds even if no level of round-trip fidelity is maintained.
    00069         /// If the Feature Schema is read successfully from document A and then written to document B,
    00070         /// any instance document thatconforms to the document A schema
    00071         /// may or may not conform to the document B schema.
    00072             /// A document that does not conform to the A schema may or may not conform to the B schema.
    00073         /// This errorLevel is useful for reading schemas from external sources into FDO
    00074         /// when it doesn’t matter how much the schemas are altered during the read.
    00075         ErrorLevel_VeryLow
    00076     };
    00077
    00078     /// \brief
    00079     /// Constructs an FdoXmlFlags object.
    00080     ///
    00081     /// \param url
    00082     /// Input When writing  Feature Schemas, this specifies the
    00083     /// prefix for the target namespace for any schemas that are written. The XML
    00084     /// format for Feature Schemas is OGC GML, so a targetNamespace for the
    00085     /// xs:schema element is required. This namespace will be http://[url]/[schema_name].
    00086     /// \param errorLevel
    00087     /// Input The error level for reading feature schemas.
    00088     /// \param nameAdjust
    00089     /// Input true: apply name adjustment to all elements.
    00090     /// false: apply name adjustment only to elements with fdo:nameAdjust="true"
    00091     ///
    00092     /// \return
    00093     /// Returns FdoXmlFlags
    00094     ///
    00095     FDO_API static FdoXmlFlags* Create(
    00096         FdoString* url = L"fdo.osgeo.org/schemas/feature",
    00097         ErrorLevel errorLevel = ErrorLevel_Normal,
    00098         FdoBoolean nameAdjust = true
    00099     );
    00100
    00101     /// \brief
    00102     /// Sets the target namespace prefix, see FdoXmlFlags::Create().
    00103     ///
    00104     /// \param url
    00105     /// Input the target namespace prefix.
    00106     ///
    00107     FDO_API void SetUrl( FdoString* url );
    00108
    00109     /// \brief
    00110     /// Gets the target namespace prefix, see FdoXmlFlags::Create().
    00111     ///
    00112     /// \return
    00113     /// Returns the target namespace prefix.
    00114     ///
    00115     FDO_API FdoString* GetUrl() const;
    00116
    00117     /// \brief
    00118     /// Sets the error level, see FdoXmlFlags::Create().
    00119     ///
    00120     /// \param errorLevel
    00121     /// Input the error level.
    00122     ///
    00123     FDO_API void SetErrorLevel( ErrorLevel errorLevel );
    00124
    00125     /// \brief
    00126     /// Gets the current error level, see FdoXmlFlags::Create().
    00127     ///
    00128     /// \return
    00129     /// Returns the error level.
    00130     ///
    00131     FDO_API ErrorLevel GetErrorLevel() const;
    00132
    00133     /// \brief
    00134     /// Sets the name adjustment flag, see FdoXmlFlags::Create().
    00135     ///
    00136     /// \param nameAdjust
    00137     /// Input the name adjustment flag.
    00138     ///
    00139     FDO_API void SetNameAdjust( FdoBoolean nameAdjust );
    00140
    00141     /// \brief
    00142     /// Gets the name adjustment flag, see FdoXmlFlags::Create().
    00143     ///
    00144     /// \return
    00145     /// Returns the name adjustment flag.
    00146     ///
    00147     FDO_API FdoBoolean GetNameAdjust() const;
    00148
    00149     /// \brief
    00150     /// Sets the Schema Name as Prefix flag. This flag controls how
    00151     /// an FDO Feature Schema name is generated when the schema is read
    00152     /// from GML.
    00153     ///
    00154     /// \param schemaNameAsPrefix
    00155     /// Input when true, the Feature Schema
    00156     /// name is set to the prefix from the xmlns namespace declaration for
    00157     /// the schema's targetNamespace. The target namespace prefix flag on this
    00158     /// object is ignored
    00159     /// in this case. If no suitable namespace declaration can be found,
    00160     /// the Feature Schema name is set as if this flag were false.
    00161     /// Schemas cannot be round-tripped when this flag is true. Therefore, it
    00162     /// may only be set to true when the current ErrorLevel is VeryLow.
    00163     /// Caution must be observed when using this flag. Unpredictable results
    00164     /// can occur if a GML Schema uses different prefixes for its
    00165     /// targetNamespace in different parts of the schema.
    00166     ///
    00167     FDO_API void SetSchemaNameAsPrefix( FdoBoolean schemaNameAsPrefix );
    00168
    00169     /// \brief
    00170     /// Gets the Schema Name as Prefix flag.
    00171     ///
    00172     /// \return
    00173     /// Returns the Schema Name as Prefix flag.
    00174     ///
    00175     FDO_API FdoBoolean GetSchemaNameAsPrefix() const;
    00176
    00177     /// \brief
    00178     /// Sets the Use GML ID flag.
    00179     ///
    00180     /// \param schemaNameAsPrefix
    00181     /// Input when true, the feature id ( fid in GML 2, gml:id in GML 3)
    00182     /// becomes the identity property of all feature classes.
    00183     ///
    00184     FDO_API void SetUseGmlId( FdoBoolean schemaNameAsPrefix );
    00185
    00186     /// \brief
    00187     /// Gets the Use GML ID flag.
    00188     ///
    00189     /// \return
    00190     /// Returns the Use GML ID flag.
    00191     ///
    00192     FDO_API FdoBoolean GetUseGmlId() const;
    00193
    00194     /// \brief
    00195     /// Sets the Schema Mapping Overrides for translating schemas
    00196     /// between GML and FDO.
    00197     ///
    00198     /// \param mappings
    00199     /// Input the Schema Mapping Overrides. This collection
    00200     /// can contain an FdoXmlSchemaMapping element for each Feature Schema that
    00201     /// may be written or read. When a Feature Schema is read or written to or
    00202     /// from GML, this collection is checked for an FdoXmlSchemaMapping item named
    00203     /// the same as the feature schema. If present, the hints in this item
    00204     /// affect how the feature schema is read or written. The Schema Mapping
    00205     /// Overrides also control how features are read since they
    00206     /// can override the default correspondences between feature class names
    00207     /// and their GML element names.
    00208     ///
    00209     FDO_API void SetSchemaMappings( FdoPhysicalSchemaMappingCollection* mappings );
    00210
    00211     /// \brief
    00212     /// Gets the current Schema Mapping Overrides.
    00213     ///
    00214     /// \return
    00215     /// Returns FdoXmlSchemaMappingCollection*.
    00216     ///
    00217     FDO_API FdoPhysicalSchemaMappingCollection* GetSchemaMappings() const;
    00218
    00219 protected:
    00220     /// default constructor to keep linux from complaining
    00221     FdoXmlFlags() {}
    00222     FDO_API FdoXmlFlags( FdoString* url, ErrorLevel errorLevel, FdoBoolean nameAdjust );
    00223     FDO_API virtual ~FdoXmlFlags();
    00224
    00225 /// \cond DOXYGEN-IGNORE
    00226     //Deletes myself
    00227     FDO_API virtual void Dispose();
    00228 /// \endcond
    00229
    00230 private:
    00231     ErrorLevel mErrorLevel;
    00232     FdoStringP mUrl;
    00233     FdoBoolean mNameAdjust;
    00234     FdoBoolean mSchemaNameAsPrefix;
    00235     FdoBoolean mUseGmlId;
    00236     FdoPhysicalSchemaMappingCollection* mSchemaMappings;
    00237
    00238 /// \cond DOXYGEN-IGNORE
    00239 private:
    00240     FdoBoolean mElementDefaultNullability;
    00241 public:
    00242     void SetElementDefaultNullability( FdoBoolean pValue )
    00243     {
    00244         mElementDefaultNullability = pValue;
    00245     }
    00246
    00247     FdoBoolean GetElementDefaultNullability() const
    00248     {
    00249         return mElementDefaultNullability;
    00250     }
    00251 /// \endcond
    00252 };
    00253
    00254 /// \ingroup (typedefs)
    00255 /// \brief
    00256 /// FdoXmlFlagsP is a FdoPtr on FdoXmlFlags, provided for convenience.
    00257 typedef FdoPtr<FdoXmlFlags> FdoXmlFlagsP;
    00258
    00259 #endif
    00260
    00261

Please send us your comment about this page