DEIMOS
Earth Observation Mission CFI Software
FileHandlling Software User Manual
ESA

EECFI::XmlFile Class Reference

Class for reading and writing XML files. More...

Inheritance diagram for EECFI::XmlFile:
EECFI::CfiClass

List of all members.

Public Member Functions

 XmlFile ()
 Empty constructor.
 XmlFile (const std::string &fileNam)
 Construct object and init parser.
 ~XmlFile () EXCEPT
 Class destructor.
void create ()
 Create an XML tree in memory.
void read (const std::string &fileNam)
 Read file from disk.
void write ()
 Write file to disk.
void write (const std::string &fileNam)
 Write file to disk with different name.
void clean ()
 Clean memory.
void root ()
 Go to root element.
void next ()
 Go to next element.
void nextSibling ()
 Go to the next Sibling.
void toElement (const std::string &element)
 Go to element.
void toPath (const std::string &path)
 Go to path.
std::string currentElementName () const
 Get current element name.
std::string currentPathName () const
 Get current path name.
std::string getElementValueAsString (const std::string &element)
 Read element value as a string.
long getElementValueAsInt (const std::string &element)
 Read element value as an integer.
double getElementValueAsReal (const std::string &element)
 Read element value as a real number.
std::vector< std::string > & getElementArrayAsString (const std::string &element, std::vector< std::string > &outVector)
 Read array of values as strings.
std::vector< long > & getElementArrayAsInt (const std::string &element, std::vector< long > &outVector)
 Read array of values as integers.
std::vector< double > & getElementArrayAsReal (const std::string &element, std::vector< double > &outVector)
 Read array of values as real numbers.
std::string getAttributeValueAsString (const std::string &element, const std::string &attribute)
 Read attribute value as a string.
long getAttributeValueAsInt (const std::string &element, const std::string &attribute)
 Read attribute value as an integer.
double getAttributeValueAsReal (const std::string &element, const std::string &attribute)
 Read attribute value as a real number.
std::string getPathValueAsString (const std::string &path)
 Read path node value as a string.
long getPathValueAsInt (const std::string &path)
 Read path node value as an integer.
double getPathValueAsReal (const std::string &path)
 Read path node value as a real number.
std::vector< std::string > & getPathArrayAsString (const std::string &node, std::vector< std::string > &outVector)
 Read string node array.
std::vector< long > & getPathArrayAsInt (const std::string &node, std::vector< long > &outVector)
 Read integer node array.
std::vector< double > & getPathArrayAsReal (const std::string &node, std::vector< double > &outVector)
 Read double node array.
void createRoot (const std::string &element)
 Create root element.
void addChild (const std::string &parent, const std::string &child)
 Add child element.
void addNext (const std::string &current, const std::string &next)
 Append sibling element after current one.
void addPrevious (const std::string &current, const std::string &previous)
 Insert sibling element before current one.
void addAttribute (const std::string &element, const std::string &attribute)
 Add attribute.
void copyNode (const std::string &destPath, const std::string &sourceXmlFile, const std::string &sourcePath)
 Copy a node of one XmlFile to parent node in this XmlFile.
void removeNode (const std::string &path)
 Remove node.
void setValue (const std::string &path, const std::string &value, const std::string &format)
 Set string node value with format.
void setValue (const std::string &path, const long value, const std::string &format)
 Set integer node value with format.
void setValue (const std::string &path, const double value, const std::string &format)
 Set real node value with format.
void addChild (const std::string &parent, const std::string &child, const std::string &value, const std::string &format)
 Add a child element with a string value.
void addChild (const std::string &parent, const std::string &hild, const long value, const std::string &format)
 Add a child element with an integer value.
void addChild (const std::string &parent, const std::string &child, const double value, const std::string &format)
 Add a child element with a real value.
void addNext (const std::string &current, const std::string &next, const std::string &value, const std::string &format)
 Append an element after the current one with a string value.
void addNext (const std::string &current, const std::string &next, const long value, const std::string &format)
 Append an element after the current one with an integer value.
void addNext (const std::string &current, const std::string &next, const double value, const std::string &format)
 Append an element after the current one with a real value.
void addPrevious (const std::string &current, const std::string &previous, const std::string &value, const std::string &format)
 Insert an element before the current one with a string value.
void addPrevious (const std::string &current, const std::string &previous, const long value, const std::string &format)
 Insert an element before the current one with an integer value.
void addPrevious (const std::string &current, const std::string &previous, const double value, const std::string &format)
 Insert an element before the current one with a real value.
void addAttribute (const std::string &element, const std::string &attribute, const std::string &value, const std::string &format)
 Add attribute with a string value to an element.
void addAttribute (const std::string &element, const std::string &attribute, const long value, const std::string &format)
 Add attribute with an integer value to an element.
void addAttribute (const std::string &element, const std::string &attribute, const double value, const std::string &format)
 Add attribute with a real value to an element.
std::string findValueInElement (const std::string &element, const std::string &value)
 Find element with value.
std::string findValueInPath (const std::string &path, const std::string &value)
 Find node with value.
void createHeader (long fileExtensionType)
 Creates a blank header.
void createHeader (FixedHeader &xmlHeader)
 Creates a fixed header with the input values.
std::string createFileName (long satelliteId, const std::string &fileClass, const std::string &fileType, const std::string &instanceId, long fileExtensionType) const
 Generates a complete Cryosat file name.
FileNameItems getFileNameItems (std::string &fileNam) const
 Retrieve items of created fileName.
void setFixedHeaderItem (const std::string &itemName, const std::string &itemValue)
 Set an item in the fixed header.
void setFixedHeaderItems (const std::string &fileNam, const std::string &fileDescription, const std::string &notes, const std::string &mission, const std::string &fileClass, const std::string &filetype, const std::string &validityStart, const std::string &validityStop, const long fileVersion, const std::string &system, const std::string &creator, const std::string &creatorVersion, const std::string &creationDate)
 Set all items in the fixed header.
std::string getFixedHeaderItem (const std::string &itemName)
 Get an item from the fixed header.
FixedHeader getFixedHeader ()
 Get fixed header data.
long getId () const
 Get id.
std::string getFileName () const
 Get fileName.
void setSchema (const std::string &schemaName, bool setAll)
 Set schema name.
void removeSchema (bool removeAll)
 Remove schema name.
std::vector< std::string > & getStringValuesFromList (const std::string &listPath, const std::string &element, std::vector< std::string > &outVector)
 Read elements from a list.

Detailed Description

Class for reading and writing XML files.

This class is used for reading and writing XML files according to the Earth Explorer Mission File Format Guidelines

It relies on the EO_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.


Constructor & Destructor Documentation

EECFI::XmlFile::XmlFile (  ) 

Empty constructor.

EECFI::XmlFile::XmlFile ( const std::string &  fileNam  )  [explicit]

Construct object and init parser.

EECFI::XmlFile::~XmlFile (  ) 

Class destructor.


Member Function Documentation

void EECFI::XmlFile::addAttribute ( const std::string &  element,
const std::string &  attribute 
)

Add attribute.

void EECFI::XmlFile::addAttribute ( const std::string &  element,
const std::string &  attribute,
const std::string &  value,
const std::string &  format 
)

Add attribute with a string value to an element.

void EECFI::XmlFile::addAttribute ( const std::string &  element,
const std::string &  attribute,
const long  value,
const std::string &  format 
)

Add attribute with an integer value to an element.

void EECFI::XmlFile::addAttribute ( const std::string &  element,
const std::string &  attribute,
const double  value,
const std::string &  format 
)

Add attribute with a real value to an element.

void EECFI::XmlFile::addChild ( const std::string &  parent,
const std::string &  child,
const std::string &  value,
const std::string &  format 
)

Add a child element with a string value.

void EECFI::XmlFile::addChild ( const std::string &  parent,
const std::string &  hild,
const long  value,
const std::string &  format 
)

Add a child element with an integer value.

void EECFI::XmlFile::addChild ( const std::string &  parent,
const std::string &  child 
)

Add child element.

void EECFI::XmlFile::addChild ( const std::string &  parent,
const std::string &  child,
const double  value,
const std::string &  format 
)

Add a child element with a real value.

void EECFI::XmlFile::addNext ( const std::string &  current,
const std::string &  next,
const std::string &  value,
const std::string &  format 
)

Append an element after the current one with a string value.

void EECFI::XmlFile::addNext ( const std::string &  current,
const std::string &  next,
const long  value,
const std::string &  format 
)

Append an element after the current one with an integer value.

void EECFI::XmlFile::addNext ( const std::string &  current,
const std::string &  next,
const double  value,
const std::string &  format 
)

Append an element after the current one with a real value.

void EECFI::XmlFile::addNext ( const std::string &  current,
const std::string &  next 
)

Append sibling element after current one.

void EECFI::XmlFile::addPrevious ( const std::string &  current,
const std::string &  previous,
const long  value,
const std::string &  format 
)

Insert an element before the current one with an integer value.

void EECFI::XmlFile::addPrevious ( const std::string &  current,
const std::string &  previous,
const std::string &  value,
const std::string &  format 
)

Insert an element before the current one with a string value.

void EECFI::XmlFile::addPrevious ( const std::string &  current,
const std::string &  previous,
const double  value,
const std::string &  format 
)

Insert an element before the current one with a real value.

void EECFI::XmlFile::addPrevious ( const std::string &  current,
const std::string &  previous 
)

Insert sibling element before current one.

void EECFI::XmlFile::clean (  ) 

Clean memory.

void EECFI::XmlFile::copyNode ( const std::string &  destPath,
const std::string &  sourceXmlFile,
const std::string &  sourcePath 
)

Copy a node of one XmlFile to parent node in this XmlFile.

void EECFI::XmlFile::create (  ) 

Create an XML tree in memory.

std::string EECFI::XmlFile::createFileName ( long  satelliteId,
const std::string &  fileClass,
const std::string &  fileType,
const std::string &  instanceId,
long  fileExtensionType 
) const

Generates a complete Cryosat file name.

void EECFI::XmlFile::createHeader ( long  fileExtensionType  ) 

Creates a blank header.

Parameters:
fileExtensionType Type of XML. Should be one of the possibles values in FileExtensionTypeEnum.

Generates a new blank Header including both Fixed and Variable headers.

void EECFI::XmlFile::createRoot ( const std::string &  element  ) 

Create root element.

string EECFI::XmlFile::currentElementName (  )  const

Get current element name.

Returns:
Current element name
string EECFI::XmlFile::currentPathName (  )  const

Get current path name.

Returns:
Current XPath node name
std::string EECFI::XmlFile::findValueInElement ( const std::string &  element,
const std::string &  value 
)

Find element with value.

std::string EECFI::XmlFile::findValueInPath ( const std::string &  path,
const std::string &  value 
)

Find node with value.

long EECFI::XmlFile::getAttributeValueAsInt ( const std::string &  element,
const std::string &  attribute 
)

Read attribute value as an integer.

double EECFI::XmlFile::getAttributeValueAsReal ( const std::string &  element,
const std::string &  attribute 
)

Read attribute value as a real number.

std::string EECFI::XmlFile::getAttributeValueAsString ( const std::string &  element,
const std::string &  attribute 
)

Read attribute value as a string.

std::vector<long>& EECFI::XmlFile::getElementArrayAsInt ( const std::string &  element,
std::vector< long > &  outVector 
)

Read array of values as integers.

std::vector<double>& EECFI::XmlFile::getElementArrayAsReal ( const std::string &  element,
std::vector< double > &  outVector 
)

Read array of values as real numbers.

std::vector<std::string>& EECFI::XmlFile::getElementArrayAsString ( const std::string &  element,
std::vector< std::string > &  outVector 
)

Read array of values as strings.

long EECFI::XmlFile::getElementValueAsInt ( const std::string &  element  ) 

Read element value as an integer.

double EECFI::XmlFile::getElementValueAsReal ( const std::string &  element  ) 

Read element value as a real number.

std::string EECFI::XmlFile::getElementValueAsString ( const std::string &  element  ) 

Read element value as a string.

string EECFI::XmlFile::getFileName (  )  const

Get fileName.

Returns:
Value of internal attribute fileName.
FileNameItems EECFI::XmlFile::getFileNameItems ( std::string &  fileNam  )  const

Retrieve items of created fileName.

FixedHeader EECFI::XmlFile::getFixedHeader (  ) 

Get fixed header data.

Returns:
FixedHeader object with all the values of the Fixed Header of the file.

Gets the value of all Fixed Header elements.

std::string EECFI::XmlFile::getFixedHeaderItem ( const std::string &  itemName  ) 

Get an item from the fixed header.

long EECFI::XmlFile::getId (  )  const

Get id.

Returns:
Value of internal attribute id.

Referenced by nextSibling().

std::vector<long>& EECFI::XmlFile::getPathArrayAsInt ( const std::string &  node,
std::vector< long > &  outVector 
)

Read integer node array.

std::vector<double>& EECFI::XmlFile::getPathArrayAsReal ( const std::string &  node,
std::vector< double > &  outVector 
)

Read double node array.

std::vector<std::string>& EECFI::XmlFile::getPathArrayAsString ( const std::string &  node,
std::vector< std::string > &  outVector 
)

Read string node array.

long EECFI::XmlFile::getPathValueAsInt ( const std::string &  path  ) 

Read path node value as an integer.

double EECFI::XmlFile::getPathValueAsReal ( const std::string &  path  ) 

Read path node value as a real number.

std::string EECFI::XmlFile::getPathValueAsString ( const std::string &  path  ) 

Read path node value as a string.

std::vector<std::string>& EECFI::XmlFile::getStringValuesFromList ( const std::string &  listPath,
const std::string &  element,
std::vector< std::string > &  outVector 
)

Read elements from a list.

void EECFI::XmlFile::next (  ) 

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.

void EECFI::XmlFile::nextSibling (  ) 

Go to the next Sibling.

References getId().

void EECFI::XmlFile::read ( const std::string &  fileNam  ) 

Read file from disk.

void EECFI::XmlFile::removeNode ( const std::string &  path  ) 

Remove node.

void EECFI::XmlFile::removeSchema ( bool  removeAll  ) 

Remove schema name.

Parameters:
removeAll Indicates if schema and version will be removed (true) or only the schema (false).
void EECFI::XmlFile::root (  ) 

Go to root element.

void EECFI::XmlFile::setFixedHeaderItem ( const std::string &  itemName,
const std::string &  itemValue 
)

Set an item in the fixed header.

void EECFI::XmlFile::setFixedHeaderItems ( const std::string &  fileNam,
const std::string &  fileDescription,
const std::string &  notes,
const std::string &  mission,
const std::string &  fileClass,
const std::string &  filetype,
const std::string &  validityStart,
const std::string &  validityStop,
const long  fileVersion,
const std::string &  system,
const std::string &  creator,
const std::string &  creatorVersion,
const std::string &  creationDate 
)

Set all items in the fixed header.

void EECFI::XmlFile::setSchema ( const std::string &  schemaName,
bool  setAll 
)

Set schema name.

void EECFI::XmlFile::setValue ( const std::string &  path,
const double  value,
const std::string &  format 
)

Set real node value with format.

void EECFI::XmlFile::setValue ( const std::string &  path,
const long  value,
const std::string &  format 
)

Set integer node value with format.

void EECFI::XmlFile::setValue ( const std::string &  path,
const std::string &  value,
const std::string &  format 
)

Set string node value with format.

void EECFI::XmlFile::toElement ( const std::string &  element  ) 

Go to element.

void EECFI::XmlFile::toPath ( const std::string &  path  ) 

Go to path.

void EECFI::XmlFile::write (  ) 

Write file to disk.

void EECFI::XmlFile::write ( const std::string &  fileNam  ) 

Write file to disk with different name.


Generated on Fri May 29 2020 14:17:27 for by doxygen 1.7.1