![]() |
Earth Explorer Mission CFI Software FileHandlling Software User Manual |
![]() |
00001 00005 00006 #ifndef _XMLFILE_H 00007 #define _XMLFILE_H 00008 00009 00011 #include <string> 00012 #include <vector> 00013 00014 #include "CfiClass.h" 00015 #include "CfiError.h" 00016 #include "FixedHeader.h" 00017 #include "FileHandlingData.h" 00018 00020 using namespace std; 00021 00022 namespace EECFI 00023 { 00048 00049 class XmlFile:public CfiClass 00050 { 00051 public: 00052 00054 XmlFile(); 00055 00057 XmlFile(string fileNam) throw (CfiError); 00058 00060 ~XmlFile() throw (CfiError); 00061 00062 // Methods for creating, reading and writing 00063 00065 void create() throw (CfiError); 00066 00068 void read(const string fileNam) throw (CfiError); 00069 00071 void write() throw (CfiError); 00072 00074 void write(const string fileNam) throw (CfiError); 00075 00077 void clean() throw (CfiError); 00078 00079 // Methods for navigating the tree 00080 00082 void root() throw (CfiError); 00083 00085 void next() throw (CfiError); 00086 00088 void nextSibling() const; 00089 00091 void toElement(const string element) throw (CfiError); 00092 00094 void toPath(const string path) throw (CfiError); 00095 00097 string currentElementName() throw (CfiError); 00098 00100 string currentPathName() throw (CfiError); 00101 00102 // Methods for reading data 00103 00105 string getElementValueAsString(const string element) throw (CfiError); 00106 00108 long getElementValueAsInt(const string element) throw (CfiError); 00109 00111 double getElementValueAsReal(const string element) throw (CfiError); 00112 00114 vector<string> & getElementArrayAsString(const string element, 00115 vector<string> &outVector) throw (CfiError); 00116 00118 vector<long> & getElementArrayAsInt(const string element, 00119 vector<long> &outVector) throw (CfiError); 00120 00122 vector<double> & getElementArrayAsReal(const string element, 00123 vector<double> &outVector) throw (CfiError); 00124 00126 string getAttributeValueAsString(const string element, 00127 const string attribute) throw (CfiError); 00128 00130 long getAttributeValueAsInt(const string element, 00131 const string attribute) throw (CfiError); 00132 00134 double getAttributeValueAsReal(const string element, 00135 const string attribute) throw (CfiError); 00136 00138 string getPathValueAsString(const string path) throw (CfiError); 00139 00141 long getPathValueAsInt(const string path) throw (CfiError); 00142 00144 double getPathValueAsReal(const string path) throw (CfiError); 00145 00147 vector<string> & getPathArrayAsString(const string node, 00148 vector<string> &outVector) throw (CfiError); 00149 00151 vector<long> & getPathArrayAsInt(const string node, 00152 vector<long> &outVector) throw (CfiError); 00153 00155 vector<double> & getPathArrayAsReal(const string node, 00156 vector<double> &outVector) throw (CfiError); 00157 00158 // Methods for adding and removing nodes 00159 00161 void createRoot(const string element) throw (CfiError); 00162 00164 void addChild(const string parent, 00165 const string child) throw (CfiError); 00166 00168 void addNext(const string current, 00169 const string next) throw (CfiError); 00170 00172 void addPrevious(const string current, 00173 const string previous) throw (CfiError); 00174 00176 void addAttribute(const string element, 00177 const string attribute) throw (CfiError); 00178 00180 void copyNode(const string destPath, 00181 const string sourceXmlFile, 00182 const string sourcePath) throw (CfiError); 00183 00185 void removeNode(const string path) throw (CfiError); 00186 00187 // Methods for setting values 00188 00190 void setValue(const string path, 00191 const string value, 00192 const string format) throw (CfiError); 00193 00195 void setValue(const string path, 00196 const long value, 00197 const string format) throw (CfiError); 00198 00200 void setValue(const string path, 00201 const double value, 00202 const string format) throw (CfiError); 00203 00204 // Methods for adding nodes with values 00205 00207 void addChild(const string parent, 00208 const string child, 00209 const string value, 00210 const string format) throw (CfiError); 00211 00213 void addChild(const string parent, 00214 const string child, 00215 const long value, 00216 const string format) throw (CfiError); 00217 00219 void addChild(const string parent, 00220 const string child, 00221 const double value, 00222 const string format) throw (CfiError); 00223 00225 void addNext(const string current, 00226 const string next, 00227 const string value, 00228 const string format) throw (CfiError); 00229 00231 void addNext(const string current, 00232 const string next, 00233 const long value, 00234 const string format) throw (CfiError); 00235 00237 void addNext(const string current, 00238 const string next, 00239 const double value, 00240 const string format) throw (CfiError); 00241 00243 void addPrevious(const string current, 00244 const string previous, 00245 const string value, 00246 const string format) throw (CfiError); 00247 00249 void addPrevious(const string current, 00250 const string previous, 00251 const long value, 00252 const string format) throw (CfiError); 00253 00255 void addPrevious(const string current, 00256 const string previous, 00257 const double value, 00258 const string format) throw (CfiError); 00259 00261 void addAttribute(const string element, 00262 const string attribute, 00263 const string value, 00264 const string format) throw (CfiError); 00265 00267 void addAttribute(const string element, 00268 const string attribute, 00269 const long value, 00270 const string format) throw (CfiError); 00271 00273 void addAttribute(const string element, 00274 const string attribute, 00275 const double value, 00276 const string format) throw (CfiError); 00277 00278 // Methods for searching elements by value 00279 00281 string findValueInElement(const string element, 00282 const string value) throw (CfiError); 00283 00285 string findValueInPath(const string path, 00286 const string value) throw (CfiError); 00287 00288 // Methods for handling the file header 00289 00291 void createHeader(long fileExtensionType) throw (CfiError); 00292 00294 void createHeader(FixedHeader &xmlHeader) throw (CfiError); 00295 00297 string createFileName(long satelliteId, 00298 string fileClass, 00299 string fileType, 00300 string instanceId, 00301 long fileExtensionType) throw (CfiError); 00302 00304 FileNameItems getFileNameItems(string fileNam) throw (CfiError); 00305 00307 void setFixedHeaderItem(const string itemName, 00308 const string itemValue) throw (CfiError); 00309 00311 void setFixedHeaderItems(const string fileNam, 00312 const string fileDescription, 00313 const string notes, 00314 const string mission, 00315 const string fileClass, 00316 const string filetype, 00317 const string validityStart, 00318 const string validityStop, 00319 const long fileVersion, 00320 const string system, 00321 const string creator, 00322 const string creatorVersion, 00323 const string creationDate) throw (CfiError); 00324 00326 string getFixedHeaderItem(const string itemName) throw (CfiError); 00327 00329 FixedHeader getFixedHeader() throw (CfiError); 00330 00332 long getId() const; 00333 00335 string getFileName() const; 00336 00338 void setSchema( const string schemaName, bool setAll); 00339 00341 void removeSchema( bool removeAll); 00342 00344 vector<string>& getStringValuesFromList(const string listPath, 00345 const string element, 00346 vector <string> &outVector) throw (CfiError); 00347 00348 protected: 00349 00350 private: 00351 long id; 00352 string fileName; 00353 00354 00355 };//class XmlFile 00356 }//namespace EECFI 00357 00358 #endif