![]() |
Earth Explorer Mission CFI Software FileHandlling Software User Manual |
![]() |
Public Member Functions | |
XmlFile () | |
Empty constructor. | |
XmlFile (string fileNam) throw (CfiError) | |
Construct object and init parser. | |
~XmlFile () throw (CfiError) | |
Class destructor. | |
void | create () throw (CfiError) |
Create an XML tree in memory. | |
void | read (const string fileNam) throw (CfiError) |
Read file from disk. | |
void | write () throw (CfiError) |
Write file to disk. | |
void | write (const string fileNam) throw (CfiError) |
Write file to disk with different name. | |
void | clean () throw (CfiError) |
Clean memory. | |
void | root () throw (CfiError) |
Go to root element. | |
void | next () throw (CfiError) |
Go to next element. | |
void | nextSibling () const |
Go to the next Sibling. | |
void | toElement (const string element) throw (CfiError) |
Go to element. | |
void | toPath (const string path) throw (CfiError) |
Go to path. | |
string | currentElementName () throw (CfiError) |
Get current element name. | |
string | currentPathName () throw (CfiError) |
Get current path name. | |
string | getElementValueAsString (const string element) throw (CfiError) |
Read element value as a string. | |
long | getElementValueAsInt (const string element) throw (CfiError) |
Read element value as an integer. | |
double | getElementValueAsReal (const string element) throw (CfiError) |
Read element value as a real number. | |
vector< string > & | getElementArrayAsString (const string element, vector< string > &outVector) throw (CfiError) |
Read array of values as strings. | |
vector< long > & | getElementArrayAsInt (const string element, vector< long > &outVector) throw (CfiError) |
Read array of values as integers. | |
vector< double > & | getElementArrayAsReal (const string element, vector< double > &outVector) throw (CfiError) |
Read array of values as real numbers. | |
string | getAttributeValueAsString (const string element, const string attribute) throw (CfiError) |
Read attribute value as a string. | |
long | getAttributeValueAsInt (const string element, const string attribute) throw (CfiError) |
Read attribute value as an integer. | |
double | getAttributeValueAsReal (const string element, const string attribute) throw (CfiError) |
Read attribute value as a real number. | |
string | getPathValueAsString (const string path) throw (CfiError) |
Read path node value as a string. | |
long | getPathValueAsInt (const string path) throw (CfiError) |
Read path node value as an integer. | |
double | getPathValueAsReal (const string path) throw (CfiError) |
Read path node value as a real number. | |
vector< string > & | getPathArrayAsString (const string node, vector< string > &outVector) throw (CfiError) |
Read string node array. | |
vector< long > & | getPathArrayAsInt (const string node, vector< long > &outVector) throw (CfiError) |
Read integer node array. | |
vector< double > & | getPathArrayAsReal (const string node, vector< double > &outVector) throw (CfiError) |
Read double node array. | |
void | createRoot (const string element) throw (CfiError) |
Create root element. | |
void | addChild (const string parent, const string child) throw (CfiError) |
Add child element. | |
void | addNext (const string current, const string next) throw (CfiError) |
Append sibling element after current one. | |
void | addPrevious (const string current, const string previous) throw (CfiError) |
Insert sibling element before current one. | |
void | addAttribute (const string element, const string attribute) throw (CfiError) |
Add attribute. | |
void | copyNode (const string destPath, const string sourceXmlFile, const string sourcePath) throw (CfiError) |
Copy a node of one XmlFile to parent node in this XmlFile. | |
void | removeNode (const string path) throw (CfiError) |
Remove node. | |
void | setValue (const string path, const string value, const string format) throw (CfiError) |
Set string node value with format. | |
void | setValue (const string path, const long value, const string format) throw (CfiError) |
Set integer node value with format. | |
void | setValue (const string path, const double value, const string format) throw (CfiError) |
Set real node value with format. | |
void | addChild (const string parent, const string child, const string value, const string format) throw (CfiError) |
Add a child element with a string value. | |
void | addChild (const string parent, const string child, const long value, const string format) throw (CfiError) |
Add a child element with an integer value. | |
void | addChild (const string parent, const string child, const double value, const string format) throw (CfiError) |
Add a child element with a real value. | |
void | addNext (const string current, const string next, const string value, const string format) throw (CfiError) |
Append an element after the current one with a string value. | |
void | addNext (const string current, const string next, const long value, const string format) throw (CfiError) |
Append an element after the current one with an integer value. | |
void | addNext (const string current, const string next, const double value, const string format) throw (CfiError) |
Append an element after the current one with a real value. | |
void | addPrevious (const string current, const string previous, const string value, const string format) throw (CfiError) |
Insert an element before the current one with a string value. | |
void | addPrevious (const string current, const string previous, const long value, const string format) throw (CfiError) |
Insert an element before the current one with an integer value. | |
void | addPrevious (const string current, const string previous, const double value, const string format) throw (CfiError) |
Insert an element before the current one with a real value. | |
void | addAttribute (const string element, const string attribute, const string value, const string format) throw (CfiError) |
Add attribute with a string value to an element. | |
void | addAttribute (const string element, const string attribute, const long value, const string format) throw (CfiError) |
Add attribute with an integer value to an element. | |
void | addAttribute (const string element, const string attribute, const double value, const string format) throw (CfiError) |
Add attribute with a real value to an element. | |
string | findValueInElement (const string element, const string value) throw (CfiError) |
Find element with value. | |
string | findValueInPath (const string path, const string value) throw (CfiError) |
Find node with value. | |
void | createHeader (long fileExtensionType) throw (CfiError) |
Creates a blank header. | |
void | createHeader (FixedHeader &xmlHeader) throw (CfiError) |
Creates a fixed header with the input values. | |
string | createFileName (long satelliteId, string fileClass, string fileType, string instanceId, long fileExtensionType) throw (CfiError) |
Generates a complete Cryosat file name. | |
FileNameItems | getFileNameItems (string fileNam) throw (CfiError) |
Retrieve items of created fileName. | |
void | setFixedHeaderItem (const string itemName, const string itemValue) throw (CfiError) |
Set an item in the fixed header. | |
void | setFixedHeaderItems (const string fileNam, const string fileDescription, const string notes, const string mission, const string fileClass, const string filetype, const string validityStart, const string validityStop, const long fileVersion, const string system, const string creator, const string creatorVersion, const string creationDate) throw (CfiError) |
Set all items in the fixed header. | |
string | getFixedHeaderItem (const string itemName) throw (CfiError) |
Get an item from the fixed header. | |
FixedHeader | getFixedHeader () throw (CfiError) |
Get fixed header data. | |
long | getId () const |
Get id. | |
string | getFileName () const |
Get fileName. | |
void | setSchema (const string schemaName, bool setAll) |
Set schema name. | |
void | removeSchema (bool removeAll) |
Remove schema name. | |
vector< string > & | getStringValuesFromList (const string listPath, const string element, vector< string > &outVector) throw (CfiError) |
Read elements from a list. |
This class is used for reading and writing XML files according to the Earth Explorer Mission File Format Guidelines
It relies on the EXPLORER_FILE_HANDLING CFI software and the GNOME libxml2 (http://xmlsoft.org)
In memory representation of the XML file is maintained in the form of a tree. Navigation through the tree is performed with the help of a pointer. The following methods can be used for moving the pointer:
The current position can be retrieved using the following methods:
Methods for creating nodes, reading and writing node values will move the pointer to the requested element if the execution is successful.
EECFI::XmlFile::XmlFile | ( | ) |
Empty constructor.
EECFI::XmlFile::XmlFile | ( | string | fileNam | ) | throw (CfiError) |
Construct object and init parser.
fileNam | Name of the file. |
EECFI::XmlFile::~XmlFile | ( | ) | throw (CfiError) |
Class destructor.
void EECFI::XmlFile::addAttribute | ( | const string | element, | |
const string | attribute, | |||
const double | value, | |||
const string | format | |||
) | throw (CfiError) |
Add attribute with a real value to an element.
element | XPath expression of element node to which the new attribute is added. | |
attribute | Inserted attribute name. | |
value | Attribute value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::addAttribute | ( | const string | element, | |
const string | attribute, | |||
const long | value, | |||
const string | format | |||
) | throw (CfiError) |
Add attribute with an integer value to an element.
element | XPath expression of element node to which the new attribute is added. | |
attribute | Inserted attribute name. | |
value | Attribute value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::addAttribute | ( | const string | element, | |
const string | attribute, | |||
const string | value, | |||
const string | format | |||
) | throw (CfiError) |
Add attribute with a string value to an element.
element | XPath expression of element node to which the new attribute is added. | |
attribute | Inserted attribute name. | |
value | Attribute value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::addAttribute | ( | const string | element, | |
const string | attribute | |||
) | throw (CfiError) |
Add attribute.
element | XPath expression of element node to which the new attribute is added. | |
attribute | Attribute name. |
void EECFI::XmlFile::addChild | ( | const string | parent, | |
const string | child, | |||
const double | value, | |||
const string | format | |||
) | throw (CfiError) |
Add a child element with a real value.
parent | XPath expression of element node to which the child is added. | |
child | Child element name. | |
value | Element value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::addChild | ( | const string | parent, | |
const string | child, | |||
const long | value, | |||
const string | format | |||
) | throw (CfiError) |
Add a child element with an integer value.
parent | XPath expression of element node to which the child is added. | |
child | Child element name. | |
value | Element value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::addChild | ( | const string | parent, | |
const string | child, | |||
const string | value, | |||
const string | format | |||
) | throw (CfiError) |
Add a child element with a string value.
parent | XPath expression of element node to which the child is added. | |
child | Child element name. | |
value | Element value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::addChild | ( | const string | parent, | |
const string | child | |||
) | throw (CfiError) |
Add child element.
parent | XPath expression of element node to which the child is added. | |
child | Child element name. |
void EECFI::XmlFile::addNext | ( | const string | current, | |
const string | next, | |||
const double | value, | |||
const string | format | |||
) | throw (CfiError) |
Append an element after the current one with a real value.
current | XPath expression of element node to which the new element is appended. | |
next | Appended element name. | |
value | Element value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::addNext | ( | const string | current, | |
const string | next, | |||
const long | value, | |||
const string | format | |||
) | throw (CfiError) |
Append an element after the current one with an integer value.
current | XPath expression of element node to which the new element is appended. | |
next | Appended element name. | |
value | Element value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::addNext | ( | const string | current, | |
const string | next, | |||
const string | value, | |||
const string | format | |||
) | throw (CfiError) |
Append an element after the current one with a string value.
current | XPath expression of element node to which the new element is appended. | |
next | Appended element name. | |
value | Element value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::addNext | ( | const string | current, | |
const string | next | |||
) | throw (CfiError) |
Append sibling element after current one.
current | XPath expression of element node to which the new element is appended. | |
next | Appended element name. |
void EECFI::XmlFile::addPrevious | ( | const string | current, | |
const string | previous, | |||
const double | value, | |||
const string | format | |||
) | throw (CfiError) |
Insert an element before the current one with a real value.
current | XPath expression of element node in front of which the new element is appended. | |
previous | Inserted element name. | |
value | Element value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::addPrevious | ( | const string | current, | |
const string | previous, | |||
const long | value, | |||
const string | format | |||
) | throw (CfiError) |
Insert an element before the current one with an integer value.
current | XPath expression of element node in front of which the new element is appended. | |
previous | Inserted element name. | |
value | Element value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::addPrevious | ( | const string | current, | |
const string | previous, | |||
const string | value, | |||
const string | format | |||
) | throw (CfiError) |
Insert an element before the current one with a string value.
current | XPath expression of element node in front of which the new element is appended. | |
previous | Inserted element name. | |
value | Element value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::addPrevious | ( | const string | current, | |
const string | previous | |||
) | throw (CfiError) |
Insert sibling element before current one.
current | XPath expression of element node in front of which the new element is inserted. | |
previous | Inserted element name. |
void EECFI::XmlFile::clean | ( | ) | throw (CfiError) |
Clean memory.
void EECFI::XmlFile::copyNode | ( | const string | destPath, | |
const string | sourceXmlFile, | |||
const string | sourcePath | |||
) | throw (CfiError) |
Copy a node of one XmlFile to parent node in this XmlFile.
destPath | XPath expression of element node to which the new element will be added. | |
sourceXmlFile | File Xml Source, some elements will be added to the destination file. | |
sourcePath | XPath expression of element node is copied to destination file, this element is child in destPath. |
void EECFI::XmlFile::create | ( | ) | throw (CfiError) |
Create an XML tree in memory.
string EECFI::XmlFile::createFileName | ( | long | missionId, | |
string | fileClass, | |||
string | fileType, | |||
string | instanceId, | |||
long | fileExtensionType | |||
) | throw (CfiError) |
Generates a complete Cryosat file name.
missionId | Satellite Id (one of SatIdEnum). | |
fileClass | Type of activity for which the file is used. | |
fileType | File type. | |
instanceId | Makes the file unique. | |
fileExtensionType | Type of XML file to add header. |
void EECFI::XmlFile::createHeader | ( | FixedHeader & | fixedHeader | ) | throw (CfiError) |
Creates a fixed header with the input values.
fixedHeader | FixedHeader object containing data for the fixed header. |
void EECFI::XmlFile::createHeader | ( | long | fileExtensionType | ) | throw (CfiError) |
Creates a blank header.
fileExtensionType | Type of XML. Should be one of the possibles values in FileExtensionTypeEnum. |
void EECFI::XmlFile::createRoot | ( | const string | element | ) | throw (CfiError) |
Create root element.
element | Root element name. |
string EECFI::XmlFile::currentElementName | ( | ) | throw (CfiError) |
Get current element name.
string EECFI::XmlFile::currentPathName | ( | ) | throw (CfiError) |
Get current path name.
string EECFI::XmlFile::findValueInElement | ( | const string | element, | |
const string | value | |||
) | throw (CfiError) |
Find element with value.
element | Element name. | |
value | Element value. |
string EECFI::XmlFile::findValueInPath | ( | const string | path, | |
const string | value | |||
) | throw (CfiError) |
Find node with value.
path | XPath expression of node name (wildcard allowed). | |
value | Element value. |
long EECFI::XmlFile::getAttributeValueAsInt | ( | const string | element, | |
const string | attribute | |||
) | throw (CfiError) |
Read attribute value as an integer.
element | Element name. | |
attribute | Attribute name. |
double EECFI::XmlFile::getAttributeValueAsReal | ( | const string | element, | |
const string | attribute | |||
) | throw (CfiError) |
Read attribute value as a real number.
element | Element name. | |
attribute | Attribute name. |
string EECFI::XmlFile::getAttributeValueAsString | ( | const string | element, | |
const string | attribute | |||
) | throw (CfiError) |
Read attribute value as a string.
element | Element name. | |
attribute | Attribute name. |
vector< long > & EECFI::XmlFile::getElementArrayAsInt | ( | const string | element, | |
vector< long > & | outVector | |||
) | throw (CfiError) |
Read array of values as integers.
element | Element name. | |
outVector | Vector of element values. |
vector< double > & EECFI::XmlFile::getElementArrayAsReal | ( | const string | element, | |
vector< double > & | outVector | |||
) | throw (CfiError) |
Read array of values as real numbers.
element | Element name. | |
outVector | Vector of element values. |
vector< string > & EECFI::XmlFile::getElementArrayAsString | ( | const string | element, | |
vector< string > & | outVector | |||
) | throw (CfiError) |
Read array of values as strings.
element | Element name. | |
outVector | Vector of element values. |
long EECFI::XmlFile::getElementValueAsInt | ( | const string | element | ) | throw (CfiError) |
Read element value as an integer.
element | Element name. |
double EECFI::XmlFile::getElementValueAsReal | ( | const string | element | ) | throw (CfiError) |
Read element value as a real number.
element | Element name. |
string EECFI::XmlFile::getElementValueAsString | ( | const string | element | ) | throw (CfiError) |
Read element value as a string.
element | Element name. |
string EECFI::XmlFile::getFileName | ( | ) | const |
Get fileName.
FileNameItems EECFI::XmlFile::getFileNameItems | ( | string | fileNam | ) | throw (CfiError) |
Retrieve items of created fileName.
fileNam | File Name. |
FixedHeader EECFI::XmlFile::getFixedHeader | ( | ) | throw (CfiError) |
Get fixed header data.
string EECFI::XmlFile::getFixedHeaderItem | ( | const string | itemName | ) | throw (CfiError) |
Get an item from the fixed header.
itemName | Name of the element which value we want to retrieve. |
long EECFI::XmlFile::getId | ( | ) | const |
vector< long > & EECFI::XmlFile::getPathArrayAsInt | ( | const string | path, | |
vector< long > & | outVector | |||
) | throw (CfiError) |
Read integer node array.
path | Node XPath name. | |
outVector | Vector of node values. |
vector< double > & EECFI::XmlFile::getPathArrayAsReal | ( | const string | path, | |
vector< double > & | outVector | |||
) | throw (CfiError) |
Read double node array.
path | Node XPath name. | |
outVector | Vector of node values. |
vector< string > & EECFI::XmlFile::getPathArrayAsString | ( | const string | path, | |
vector< string > & | outVector | |||
) | throw (CfiError) |
Read string node array.
path | Node XPath name. | |
outVector | Vector of node values. |
long EECFI::XmlFile::getPathValueAsInt | ( | const string | path | ) | throw (CfiError) |
Read path node value as an integer.
path | XPath expression of node. |
double EECFI::XmlFile::getPathValueAsReal | ( | const string | path | ) | throw (CfiError) |
Read path node value as a real number.
path | XPath expression of node. |
string EECFI::XmlFile::getPathValueAsString | ( | const string | path | ) | throw (CfiError) |
Read path node value as a string.
path | XPath expression of node. |
vector< string > & EECFI::XmlFile::getStringValuesFromList | ( | const string | listPath, | |
const string | element, | |||
vector< string > & | outVector | |||
) | throw (CfiError) |
Read elements from a list.
listPath | Path of the list to read. | |
element | Element to read. | |
outVector | String vector with the values. |
void EECFI::XmlFile::next | ( | ) | throw (CfiError) |
Go to next element.
Go to the next element. If the current element has a children then the next is first child else the next could be the next sibling, or the next element could be the next sibling of the parent if the next element has not sibling.
Referenced by nextSibling().
void EECFI::XmlFile::read | ( | const string | fileNam | ) | throw (CfiError) |
Read file from disk.
void EECFI::XmlFile::removeNode | ( | const string | path | ) | throw (CfiError) |
Remove node.
path | XPath name of the node to be removed. |
void EECFI::XmlFile::removeSchema | ( | bool | removeAll | ) |
Remove schema name.
removeAll | Indicates if schema and version will be removed (true) or only the schema (false). |
void EECFI::XmlFile::root | ( | ) | throw (CfiError) |
Go to root element.
void EECFI::XmlFile::setFixedHeaderItem | ( | const string | itemName, | |
const string | itemValue | |||
) | throw (CfiError) |
Set an item in the fixed header.
itemName | Name of the element which value we want to modify. | |
itemValue | New value assigned for the node. |
void EECFI::XmlFile::setFixedHeaderItems | ( | const string | fileNam, | |
const string | fileDescription, | |||
const string | notes, | |||
const string | mission, | |||
const string | fileClass, | |||
const string | fileType, | |||
const string | validityStart, | |||
const string | validityStop, | |||
const long | fileVersion, | |||
const string | system, | |||
const string | creator, | |||
const string | creatorVersion, | |||
const string | creationDate | |||
) | throw (CfiError) |
Set all items in the fixed header.
fileNam | Name of the file. | |
fileDescription | Description of the file. | |
notes | Notes about the file. | |
mission | Mission the file belongs to. | |
fileClass | File class. | |
fileType | File type. | |
validityStart | Date when the file starts being valid. | |
validityStop | Date when the file stops being valid. | |
fileVersion | Version of the file. | |
system | System. | |
creator | Creator name. | |
creatorVersion | Version put by the creator. | |
creationDate | Date of creation. |
void EECFI::XmlFile::setSchema | ( | const string | schemaName, | |
bool | setAll | |||
) |
Set schema name.
schemaName | Name of the new schema. | |
setAll | Indicates if schema and version will be changed (true) or only the schema (false). |
void EECFI::XmlFile::setValue | ( | const string | path, | |
const double | value, | |||
const string | format | |||
) | throw (CfiError) |
Set real node value with format.
path | XPath name of node. | |
value | New node value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::setValue | ( | const string | path, | |
const long | value, | |||
const string | format | |||
) | throw (CfiError) |
Set integer node value with format.
path | XPath name of node. | |
value | New node value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::setValue | ( | const string | path, | |
const string | value, | |||
const string | format | |||
) | throw (CfiError) |
Set string node value with format.
path | XPath name of node. | |
value | New node value. | |
format | Value format as expressed for printf functions. If format is empty "%%s" is used. |
void EECFI::XmlFile::toElement | ( | const string | element | ) | throw (CfiError) |
Go to element.
element | Element name to be found. |
void EECFI::XmlFile::toPath | ( | const string | path | ) | throw (CfiError) |
Go to path.
path | Path name to be found, either absolute or relative to the current element. |
void EECFI::XmlFile::write | ( | const string | fileNam | ) | throw (CfiError) |
Write file to disk with different name.
fileNam | Output file name. |
void EECFI::XmlFile::write | ( | ) | throw (CfiError) |
Write file to disk.