Earth Observation Mission CFI Software FileHandlling Software User Manual |
00001 //-------------------------------------------------------- 00002 // Earth Observation Mission CFI Software. Version 4.4 00003 //-------------------------------------------------------- 00004 00009 00010 #ifndef _XMLFILE_H 00011 #define _XMLFILE_H 00012 00013 00015 #include <string> 00016 #include <vector> 00017 00018 #include "CfiClass.h" 00019 #include "CfiError.h" 00020 #include "FixedHeader.h" 00021 #include "FileHandlingData.h" 00022 00024 using namespace std; 00025 00026 namespace EECFI 00027 { 00052 00053 class XmlFile:public CfiClass 00054 { 00055 public: 00056 00058 XmlFile(); 00059 00061 XmlFile(string fileNam) throw (CfiError); 00062 00064 ~XmlFile() throw (CfiError); 00065 00066 // Methods for creating, reading and writing 00067 00069 void create() throw (CfiError); 00070 00072 void read(const string fileNam) throw (CfiError); 00073 00075 void write() throw (CfiError); 00076 00078 void write(const string fileNam) throw (CfiError); 00079 00081 void clean() throw (CfiError); 00082 00083 // Methods for navigating the tree 00084 00086 void root() throw (CfiError); 00087 00089 void next() throw (CfiError); 00090 00092 void nextSibling() const; 00093 00095 void toElement(const string element) throw (CfiError); 00096 00098 void toPath(const string path) throw (CfiError); 00099 00101 string currentElementName() throw (CfiError); 00102 00104 string currentPathName() throw (CfiError); 00105 00106 // Methods for reading data 00107 00109 string getElementValueAsString(const string element) throw (CfiError); 00110 00112 long getElementValueAsInt(const string element) throw (CfiError); 00113 00115 double getElementValueAsReal(const string element) throw (CfiError); 00116 00118 vector<string> & getElementArrayAsString(const string element, 00119 vector<string> &outVector) throw (CfiError); 00120 00122 vector<long> & getElementArrayAsInt(const string element, 00123 vector<long> &outVector) throw (CfiError); 00124 00126 vector<double> & getElementArrayAsReal(const string element, 00127 vector<double> &outVector) throw (CfiError); 00128 00130 string getAttributeValueAsString(const string element, 00131 const string attribute) throw (CfiError); 00132 00134 long getAttributeValueAsInt(const string element, 00135 const string attribute) throw (CfiError); 00136 00138 double getAttributeValueAsReal(const string element, 00139 const string attribute) throw (CfiError); 00140 00142 string getPathValueAsString(const string path) throw (CfiError); 00143 00145 long getPathValueAsInt(const string path) throw (CfiError); 00146 00148 double getPathValueAsReal(const string path) throw (CfiError); 00149 00151 vector<string> & getPathArrayAsString(const string node, 00152 vector<string> &outVector) throw (CfiError); 00153 00155 vector<long> & getPathArrayAsInt(const string node, 00156 vector<long> &outVector) throw (CfiError); 00157 00159 vector<double> & getPathArrayAsReal(const string node, 00160 vector<double> &outVector) throw (CfiError); 00161 00162 // Methods for adding and removing nodes 00163 00165 void createRoot(const string element) throw (CfiError); 00166 00168 void addChild(const string parent, 00169 const string child) throw (CfiError); 00170 00172 void addNext(const string current, 00173 const string next) throw (CfiError); 00174 00176 void addPrevious(const string current, 00177 const string previous) throw (CfiError); 00178 00180 void addAttribute(const string element, 00181 const string attribute) throw (CfiError); 00182 00184 void copyNode(const string destPath, 00185 const string sourceXmlFile, 00186 const string sourcePath) throw (CfiError); 00187 00189 void removeNode(const string path) throw (CfiError); 00190 00191 // Methods for setting values 00192 00194 void setValue(const string path, 00195 const string value, 00196 const string format) throw (CfiError); 00197 00199 void setValue(const string path, 00200 const long value, 00201 const string format) throw (CfiError); 00202 00204 void setValue(const string path, 00205 const double value, 00206 const string format) throw (CfiError); 00207 00208 // Methods for adding nodes with values 00209 00211 void addChild(const string parent, 00212 const string child, 00213 const string value, 00214 const string format) throw (CfiError); 00215 00217 void addChild(const string parent, 00218 const string child, 00219 const long value, 00220 const string format) throw (CfiError); 00221 00223 void addChild(const string parent, 00224 const string child, 00225 const double value, 00226 const string format) throw (CfiError); 00227 00229 void addNext(const string current, 00230 const string next, 00231 const string value, 00232 const string format) throw (CfiError); 00233 00235 void addNext(const string current, 00236 const string next, 00237 const long value, 00238 const string format) throw (CfiError); 00239 00241 void addNext(const string current, 00242 const string next, 00243 const double value, 00244 const string format) throw (CfiError); 00245 00247 void addPrevious(const string current, 00248 const string previous, 00249 const string value, 00250 const string format) throw (CfiError); 00251 00253 void addPrevious(const string current, 00254 const string previous, 00255 const long value, 00256 const string format) throw (CfiError); 00257 00259 void addPrevious(const string current, 00260 const string previous, 00261 const double value, 00262 const string format) throw (CfiError); 00263 00265 void addAttribute(const string element, 00266 const string attribute, 00267 const string value, 00268 const string format) throw (CfiError); 00269 00271 void addAttribute(const string element, 00272 const string attribute, 00273 const long value, 00274 const string format) throw (CfiError); 00275 00277 void addAttribute(const string element, 00278 const string attribute, 00279 const double value, 00280 const string format) throw (CfiError); 00281 00282 // Methods for searching elements by value 00283 00285 string findValueInElement(const string element, 00286 const string value) throw (CfiError); 00287 00289 string findValueInPath(const string path, 00290 const string value) throw (CfiError); 00291 00292 // Methods for handling the file header 00293 00295 void createHeader(long fileExtensionType) throw (CfiError); 00296 00298 void createHeader(FixedHeader &xmlHeader) throw (CfiError); 00299 00301 string createFileName(long satelliteId, 00302 string fileClass, 00303 string fileType, 00304 string instanceId, 00305 long fileExtensionType) throw (CfiError); 00306 00308 FileNameItems getFileNameItems(string fileNam) throw (CfiError); 00309 00311 void setFixedHeaderItem(const string itemName, 00312 const string itemValue) throw (CfiError); 00313 00315 void setFixedHeaderItems(const string fileNam, 00316 const string fileDescription, 00317 const string notes, 00318 const string mission, 00319 const string fileClass, 00320 const string filetype, 00321 const string validityStart, 00322 const string validityStop, 00323 const long fileVersion, 00324 const string system, 00325 const string creator, 00326 const string creatorVersion, 00327 const string creationDate) throw (CfiError); 00328 00330 string getFixedHeaderItem(const string itemName) throw (CfiError); 00331 00333 FixedHeader getFixedHeader() throw (CfiError); 00334 00336 long getId() const; 00337 00339 string getFileName() const; 00340 00342 void setSchema( const string schemaName, bool setAll); 00343 00345 void removeSchema( bool removeAll); 00346 00348 vector<string>& getStringValuesFromList(const string listPath, 00349 const string element, 00350 vector <string> &outVector) throw (CfiError); 00351 00352 protected: 00353 00354 private: 00355 long id; 00356 string fileName; 00357 00358 00359 };//class XmlFile 00360 }//namespace EECFI 00361 00362 #endif