![]() |
Earth Observation Mission CFI Software FileHandlling Software User Manual |
![]() |
00001 //-------------------------------------------------------- 00002 // Earth Observation Mission CFI Software. Version 4.19 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 00025 namespace EECFI 00026 { 00051 00052 class XF_DECL XmlFile:public CfiClass 00053 { 00054 public: 00055 00057 XmlFile(); 00058 00060 explicit XmlFile(const std::string &fileNam) ; 00061 00063 ~XmlFile() EXCEPT; 00064 00065 // Methods for creating, reading and writing 00066 00068 void create() ; 00069 00071 void read(const std::string &fileNam) ; 00072 00074 void write() ; 00075 00077 void write(const std::string &fileNam) ; 00078 00080 void clean() ; 00081 00082 // Methods for navigating the tree 00083 00085 void root() ; 00086 00088 void next() ; 00089 00091 void nextSibling() ; 00092 00094 void toElement(const std::string &element) ; 00095 00097 void toPath(const std::string &path) ; 00098 00100 std::string currentElementName() const; 00101 00103 std::string currentPathName() const; 00104 00105 // Methods for reading data 00106 00108 std::string getElementValueAsString(const std::string &element) ; 00109 00111 long getElementValueAsInt(const std::string &element) ; 00112 00114 double getElementValueAsReal(const std::string &element) ; 00115 00117 std::vector<std::string> & getElementArrayAsString(const std::string &element, 00118 std::vector<std::string> &outVector) ; 00119 00121 std::vector<long> & getElementArrayAsInt(const std::string &element, 00122 std::vector<long> &outVector) ; 00123 00125 std::vector<double> & getElementArrayAsReal(const std::string &element, 00126 std::vector<double> &outVector) ; 00127 00129 std::string getAttributeValueAsString(const std::string &element, 00130 const std::string &attribute) ; 00131 00133 long getAttributeValueAsInt(const std::string &element, 00134 const std::string &attribute) ; 00135 00137 double getAttributeValueAsReal(const std::string &element, 00138 const std::string &attribute) ; 00139 00141 std::string getPathValueAsString(const std::string &path) ; 00142 00144 long getPathValueAsInt(const std::string &path) ; 00145 00147 double getPathValueAsReal(const std::string &path) ; 00148 00150 std::vector<std::string> & getPathArrayAsString(const std::string &node, 00151 std::vector<std::string> &outVector) ; 00152 00154 std::vector<long> & getPathArrayAsInt(const std::string &node, 00155 std::vector<long> &outVector) ; 00156 00158 std::vector<double> & getPathArrayAsReal(const std::string &node, 00159 std::vector<double> &outVector) ; 00160 00161 // Methods for adding and removing nodes 00162 00164 void createRoot(const std::string &element) ; 00165 00167 void addChild(const std::string &parent, 00168 const std::string &child) ; 00169 00171 void addNext(const std::string ¤t, 00172 const std::string &next) ; 00173 00175 void addPrevious(const std::string ¤t, 00176 const std::string &previous) ; 00177 00179 void addAttribute(const std::string &element, 00180 const std::string &attribute) ; 00181 00183 void copyNode(const std::string &destPath, 00184 const std::string &sourceXmlFile, 00185 const std::string &sourcePath) ; 00186 00188 void removeNode(const std::string &path) ; 00189 00190 // Methods for setting values 00191 00193 void setValue(const std::string &path, 00194 const std::string &value, 00195 const std::string &format) ; 00196 00198 void setValue(const std::string &path, 00199 const long value, 00200 const std::string &format) ; 00201 00203 void setValue(const std::string &path, 00204 const double value, 00205 const std::string &format) ; 00206 00207 // Methods for adding nodes with values 00208 00210 void addChild(const std::string &parent, 00211 const std::string &child, 00212 const std::string &value, 00213 const std::string &format) ; 00214 00216 void addChild(const std::string &parent, 00217 const std::string &hild, 00218 const long value, 00219 const std::string &format) ; 00220 00222 void addChild(const std::string &parent, 00223 const std::string &child, 00224 const double value, 00225 const std::string &format) ; 00226 00228 void addNext(const std::string ¤t, 00229 const std::string &next, 00230 const std::string &value, 00231 const std::string &format) ; 00232 00234 void addNext(const std::string ¤t, 00235 const std::string &next, 00236 const long value, 00237 const std::string &format) ; 00238 00240 void addNext(const std::string ¤t, 00241 const std::string &next, 00242 const double value, 00243 const std::string &format) ; 00244 00246 void addPrevious(const std::string ¤t, 00247 const std::string &previous, 00248 const std::string &value, 00249 const std::string &format) ; 00250 00252 void addPrevious(const std::string ¤t, 00253 const std::string &previous, 00254 const long value, 00255 const std::string &format) ; 00256 00258 void addPrevious(const std::string ¤t, 00259 const std::string &previous, 00260 const double value, 00261 const std::string &format) ; 00262 00264 void addAttribute(const std::string &element, 00265 const std::string &attribute, 00266 const std::string &value, 00267 const std::string &format) ; 00268 00270 void addAttribute(const std::string &element, 00271 const std::string &attribute, 00272 const long value, 00273 const std::string &format) ; 00274 00276 void addAttribute(const std::string &element, 00277 const std::string &attribute, 00278 const double value, 00279 const std::string &format) ; 00280 00281 // Methods for searching elements by value 00282 00284 std::string findValueInElement(const std::string &element, 00285 const std::string &value) ; 00286 00288 std::string findValueInPath(const std::string &path, 00289 const std::string &value) ; 00290 00291 // Methods for handling the file header 00292 00294 void createHeader(long fileExtensionType) ; 00295 00297 void createHeader(FixedHeader &xmlHeader) ; 00298 00300 std::string createFileName(long satelliteId, 00301 const std::string &fileClass, 00302 const std::string &fileType, 00303 const std::string &instanceId, 00304 long fileExtensionType) const; 00305 00307 FileNameItems getFileNameItems(std::string &fileNam) const; 00308 00310 void setFixedHeaderItem(const std::string &itemName, 00311 const std::string &itemValue) ; 00312 00314 void setFixedHeaderItems(const std::string &fileNam, 00315 const std::string &fileDescription, 00316 const std::string ¬es, 00317 const std::string &mission, 00318 const std::string &fileClass, 00319 const std::string &filetype, 00320 const std::string &validityStart, 00321 const std::string &validityStop, 00322 const long fileVersion, 00323 const std::string &system, 00324 const std::string &creator, 00325 const std::string &creatorVersion, 00326 const std::string &creationDate) ; 00327 00329 std::string getFixedHeaderItem(const std::string &itemName) ; 00330 00332 FixedHeader getFixedHeader() ; 00333 00335 long getId() const; 00336 00338 std::string getFileName() const; 00339 00341 void setSchema( const std::string &schemaName, bool setAll); 00342 00344 void removeSchema( bool removeAll); 00345 00347 std::vector<std::string>& getStringValuesFromList(const std::string &listPath, 00348 const std::string &element, 00349 std::vector <std::string> &outVector) ; 00350 00351 protected: 00352 00353 private: 00354 long id; 00355 std::string fileName; 00356 00357 00358 };//class XmlFile 00359 }//namespace EECFI 00360 00361 #endif