FDO API Reference | Feature Data Objects |
00001 #ifndef FDO_XML_FEATUREWRITER_H_ 00002 #define FDO_XML_FEATUREWRITER_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 #ifdef _WIN32 00022 #pragma once 00023 #endif 00024 00025 #include <FdoStd.h> 00026 00027 class FdoXmlFeaturePropertyWriter; 00028 class FdoXmlFeatureFlags; 00029 class FdoXmlFeatureWriterCollection; 00030 00031 /// \brief 00032 /// FdoXmlFeatureWriter writes features to an XML document. The features are 00033 /// written in GML format. Each feature is written in 3 steps: 00034 /// <ol> 00035 /// <li> call SetClassDefintion() to define the feature's class name, 00036 /// schema name, and list of valid properties. 00037 /// <li> call SetProperty() for each feature property value to set. 00038 /// <li> call WriteFeature() to write the feature with the current 00039 /// property values. The feature's element name is derived from the 00040 /// class and schema name. 00041 /// </ol> 00042 /// WriteFeature() ensures that the properties are written in their proper order. This 00043 /// may have slight performance implications since this writer has to accumulate the 00044 /// property values before writing them. If performance is a concern then 00045 /// FdoXmlFeaturePropertyWriter should be used instead. 00046 class FdoXmlFeatureWriter : public FdoIDisposable 00047 { 00048 public: 00049 /// \brief 00050 /// Creates a Feature Writer for writing FDO features to XML. 00051 /// 00052 /// \param writer 00053 /// Input Feature Property Writer. Specifies the XML 00054 /// document that the features will be written to. 00055 /// \param flags 00056 /// Input options for controlling the writing of the features. If NULL then the 00057 /// flags passed to the document writer are used. 00058 /// 00059 /// \return 00060 /// Returns FdoXmlFeatureWriter 00061 /// 00062 FDO_API static FdoXmlFeatureWriter * Create( 00063 FdoXmlFeaturePropertyWriter* writer, 00064 FdoXmlFeatureFlags* flags = NULL 00065 ); 00066 00067 /// \brief 00068 /// Creates a Feature Writer for writing FDO features to XML. 00069 /// 00070 /// \param writer 00071 /// Input XML document writer. Specifies the XML document that the features will be written 00072 /// to . An FdoXmlFeaturePropertyWriter is automatically wrapped 00073 /// around this writer. This Feature Property Writer can be retrieved by calling 00074 /// GetFeaturePropertyWriter(). 00075 /// \param flags 00076 /// Input options for controlling the writing of the features. If NULL then the 00077 /// flags passed to the document writer are used. 00078 /// 00079 /// \return 00080 /// Returns FdoXmlFeatureWriter 00081 /// 00082 FDO_API static FdoXmlFeatureWriter * Create( 00083 FdoXmlWriter* writer, 00084 FdoXmlFeatureFlags* flags = NULL 00085 ); 00086 00087 /// \brief 00088 /// Gets the feature property writer that was passed to this object. 00089 /// 00090 /// \return 00091 /// Returns FdoXmlFeaturePropertyWriter 00092 /// 00093 FDO_API FdoXmlFeaturePropertyWriter* GetFeaturePropertyWriter(); 00094 00095 /// \brief 00096 /// Gets the class definition for the current feature being written. 00097 /// 00098 /// \return 00099 /// Returns FdoClassDefinition 00100 /// 00101 FDO_API FdoClassDefinition* GetClassDefinition(); 00102 00103 /// \brief 00104 /// Sets the class definition for the current feature being written. 00105 /// 00106 /// \param value 00107 /// Input the class definition 00108 /// 00109 /// \return 00110 /// Returns nothing 00111 /// 00112 FDO_API void SetClassDefinition(FdoClassDefinition* classDefinition); 00113 00114 /// \brief 00115 /// Sets a feature property. 00116 /// 00117 /// \param propertyValue 00118 /// Input the property name and value 00119 /// 00120 /// \return 00121 /// Returns nothing 00122 /// 00123 FDO_API void SetProperty(FdoPropertyValue* propertyValue); 00124 00125 /// \brief 00126 /// Gets a reference to an FdoXmlFeatureWriter to write the data contained 00127 /// in a collection object property. If the property is not an object property, an 00128 /// exception is thrown. 00129 /// 00130 /// \param propertyName 00131 /// Input the object property name. 00132 /// 00133 /// \return 00134 /// Returns the nested XML feature writer 00135 /// 00136 FDO_API FdoXmlFeatureWriter* GetObjectWriter(FdoString* propertyName); 00137 00138 /// \brief 00139 /// Gets a reference to an FdoXmlFeatureWriter to write the data contained 00140 /// in an association property. If the property is not an association property, an 00141 /// exception is thrown. 00142 /// 00143 /// \param propertyName 00144 /// Input the association property name. 00145 /// 00146 /// \return 00147 /// Returns the nested XML feature writer 00148 /// 00149 FDO_API FdoXmlFeatureWriter* GetAssociationWriter(FdoString* propertyName); 00150 00151 /// \brief 00152 /// Writes the current feature to the XML document. 00153 /// If all features being written are of the same class then SetClassDefinition() 00154 /// can be called once and the WriteFeature() can be call repeatedly. In other words, 00155 /// the current class definition persists across WriteFeature() calls. Similarly, 00156 /// Property Values also persist across WriteFeature() calls. If the next feature 00157 /// to write has a property with different value from current feature, then 00158 /// SetProperty() must be called, to change the value, before next call to 00159 /// WriteFeature(). 00160 /// 00161 /// \param elementTag 00162 /// The tag for the output feature/object. If elementTag is null, the class name 00163 /// will be used as the element tag. 00164 /// 00165 FDO_API virtual void WriteFeature(FdoString* elementTag = NULL); 00166 00167 protected: 00168 FdoXmlFeatureWriter(); 00169 FdoXmlFeatureWriter(FdoXmlFeaturePropertyWriter* writer, FdoXmlFeatureFlags* flags); 00170 FdoXmlFeatureWriter(FdoXmlWriter* writer, FdoXmlFeatureFlags* flags); 00171 virtual ~FdoXmlFeatureWriter(); 00172 virtual void Dispose(); 00173 void _writeFeature(FdoString* elementTag, 00174 FdoClassDefinition* classDef, 00175 FdoPropertyValueCollection* propertyValues, 00176 FdoStringCollection* objectPropertyNames, 00177 FdoXmlFeatureWriterCollection* objectPropertyWriters, 00178 FdoStringCollection* associationPropertyNames, 00179 FdoXmlFeatureWriterCollection* associationPropertyWriters); 00180 00181 00182 protected: 00183 FdoPtr<FdoXmlFeaturePropertyWriter> mPropertyWriter; 00184 FdoPtr<FdoXmlFeatureFlags> mFlags; 00185 FdoPtr<FdoClassDefinition> mClassDef; 00186 00187 FdoPtr<FdoPropertyValueCollection> mPropertyValues; 00188 00189 FdoPtr<FdoStringCollection> mObjectPropertyNames; 00190 FdoPtr<FdoXmlFeatureWriterCollection> mObjectPropertyWriters; 00191 00192 FdoPtr<FdoStringCollection> mAssociationPropertyNames; 00193 FdoPtr<FdoXmlFeatureWriterCollection> mAssociationPropertyWriters; 00194 00195 }; 00196 00197 /// \brief 00198 /// FdoXmlFeatureWriterP is a FdoPtr on FdoXmlFeatureWriter, provided for convenience. 00199 typedef FdoPtr<FdoXmlFeatureWriter> FdoXmlFeatureWriterP; 00200 00201 00202 #endif 00203 00204
Comments or suggestions? Send us feedback. |