ParsingFunctions.h File Reference

Data Extraction Functions These functions are designed to work with the Xerces 2.1.0 library. More...

#include "DataTypes.h"
#include <xercesc/dom/DOM.hpp>
#include <fstream>

Functions

void FillSpeciesSpecificValue (xercesc::DOMElement *p_oParent, char *cTagName, char *cSubTagName, floatVal *p_array, int iNumSpecies, clTreePopulation *p_oPop, bool bRequired)
 Fills species-specific float values from a DOM tree.
void FillSpeciesSpecificValue (xercesc::DOMElement *p_oParent, char *cTagName, char *cSubTagName, intVal *p_array, int iNumSpecies, clTreePopulation *p_oPop, bool bRequired)
 Fills species-specific integer values from a DOM tree.
void FillSpeciesSpecificValue (xercesc::DOMElement *p_oParent, char *cTagName, char *cSubTagName, boolVal *p_array, int iNumSpecies, clTreePopulation *p_oPop, bool bRequired)
 Fills species-specific boolean values from a DOM tree.
void FillSpeciesSpecificValue (xercesc::DOMElement *p_oParent, char *cTagName, char *cSubTagName, float *p_fArray, clTreePopulation *p_oPop, bool bRequired)
 Fills species-specific float values from a DOM tree.
void FillSpeciesSpecificValue (xercesc::DOMElement *p_oParent, char *cTagName, char *cSubTagName, int *p_iArray, clTreePopulation *p_oPop, bool bRequired)
 Fills species-specific integer values from a DOM tree.
short int GetNodeSpeciesCode (xercesc::DOMNode *p_oDocNode, clTreePopulation *p_oPop)
 GetNodeSpeciesCode Translates a species string into a species number.
void FillSingleValue (xercesc::DOMElement *p_oParent, char *cTagName, int *p_iValToFill, bool bRequired)
 Extracts a single integer value from a parsed XML file.
void FillSingleValue (xercesc::DOMElement *p_oParent, char *cTagName, float *p_fValToFill, bool bRequired)
 Extracts a single float value from a parsed XML file.
void FillSingleValue (xercesc::DOMElement *p_oParent, char *cTagName, char *p_cValToFill, int iMaxSize, bool bRequired)
 Extracts a single string value from a parsed XML file.
void FillSingleValue (xercesc::DOMElement *p_oParent, char *cTagName, bool *p_bValToFill, bool bRequired)
 Extracts a single boolean value from a parsed XML file.


Detailed Description

Data Extraction Functions These functions are designed to work with the Xerces 2.1.0 library.

They handle the extraction of data from parsed files.

Copyright 2003 Charles D. Canham.

Author:
Lora E. Murphy

Edit history:
-----------------
April 28, 2004 - Submitted as beta (LEM)
April 26, 2005 - Added FillSpeciesSpecificValue for ints, all species (LEM)
September 20, 2007 - Cleaned up memory leaks (LEM)

Function Documentation

void FillSingleValue ( xercesc::DOMElement *  p_oParent,
char *  cTagName,
bool *  p_bValToFill,
bool  bRequired 
)

Extracts a single boolean value from a parsed XML file.

For those values which are not species-specific and have the following structure:

<tag>value</tag>

this function will extract the value and place it in a given variable. The element can be the child of another tag.

This expects the values to come as either 1 (true) or 0 (false).

Parameters:
p_oParent Pointer to the parent element of the element to extract. If this is a top-level element, the parent will be the XML document root element (at the time of this writing, named paramFile).
cTagName The tag name of the node.
p_bValToFill Pointer to the variable to put the extracted value in.
bRequired Whether or not this value is required.
Exceptions:
Error if the value is required and it is not found.

void FillSingleValue ( xercesc::DOMElement *  p_oParent,
char *  cTagName,
char *  p_cValToFill,
int  iMaxSize,
bool  bRequired 
)

Extracts a single string value from a parsed XML file.

For those values which are not species-specific and have the following structure:

<tag>value</tag>

this function will extract the value and place it in a given variable. The element can be the child of another tag. An empty string is considered a valid value.

Parameters:
p_oParent Pointer to the parent element of the element to extract. If this is a top-level element, the parent will be the XML document root element (at the time of this writing, named paramFile).
cTagName The tag name of the node.
p_cValToFill Pointer to the variable to put the extracted value in.
iMaxSize (char only) Max number of chars to be copied over into char variable
bRequired Whether or not this value is required.
Exceptions:
Error if the value is required and it is not found.

void FillSingleValue ( xercesc::DOMElement *  p_oParent,
char *  cTagName,
float *  p_fValToFill,
bool  bRequired 
)

Extracts a single float value from a parsed XML file.

For those values which are not species-specific and have the following structure:

<tag>value</tag>

this function will extract the value and place it in a given variable. The element can be the child of another tag.

This is currently not protected against overflow. I could not successfully trap for the error codes the documentation says are supposed to be set.

Parameters:
p_oParent Pointer to the parent element of the element to extract. If this is a top-level element, the parent will be the XML document root element (at the time of this writing, named paramFile).
cTagName The tag name of the node.
p_fValToFill Pointer to the variable to put the extracted value in.
bRequired Whether or not this value is required.
Exceptions:
Error if the value is required and it is not found.

void FillSingleValue ( xercesc::DOMElement *  p_oParent,
char *  cTagName,
int *  p_iValToFill,
bool  bRequired 
)

Extracts a single integer value from a parsed XML file.

For those values which are not species-specific and have the following structure:

<tag>value</tag>

this function will extract the value and place it in a given variable. The element can be the child of another tag.

Parameters:
p_oParent Pointer to the parent element of the element to extract. If this is a top-level element, the parent will be the XML document root element (at the time of this writing, named paramFile).
cTagName The tag name of the node.
p_iValToFill Pointer to the variable to put the extracted value in.
bRequired Whether or not this value is required.
Exceptions:
Error if the value is required and it is not found.

void FillSpeciesSpecificValue ( xercesc::DOMElement *  p_oParent,
char *  cTagName,
char *  cSubTagName,
int *  p_iArray,
clTreePopulation p_oPop,
bool  bRequired 
)

Fills species-specific integer values from a DOM tree.

For those values which are species-specific and have the following structure in the XML document:

<parent_tag>
<child_tag species = "sp1-name">val1</child_tag>
<child_tag species = "sp2-name">val2</child_tag>
</parent_tag>

This function will extract the values and place them in a given array. If the data isn't present in the document, the action taken depends on the value of the flag bRequired. If bRequired is false, and the data isn't there, the function simply exits. If bRequired is true, the function throws an error. In either case, if a value is not found for all species indicated, an error is thrown.

This function provides a shortcut if you need values for every species and don't need to bother with the intVal array type.

This function is currently not protected against overflow. I could not successfully trap for the error codes the documentation says are supposed to be set.

Parameters:
p_oParent Pointer to the parent element of the element to extract. If this is a top-level element, the parent will be the XML document root element (at the time of this writing, named paramFile).
cTagName Tag name of the parent node (parent_tag).
cSubTagName Tag name of the child node (child_tag).
p_iArray Pointer to the array to put the extracted values in.
p_oPop Pointer to the tree population. This is necessary for translating species names into codes
bRequired Whether or not this value is required.
Exceptions:
Error if the value is required and it is not found, or if it is found and not all species are present (whether or not it is required).

void FillSpeciesSpecificValue ( xercesc::DOMElement *  p_oParent,
char *  cTagName,
char *  cSubTagName,
float *  p_fArray,
clTreePopulation p_oPop,
bool  bRequired 
)

Fills species-specific float values from a DOM tree.

For those values which are species-specific and have the following structure in the XML document:

<parent_tag>
<child_tag species = "sp1-name">val1</child_tag>
<child_tag species = "sp2-name">val2</child_tag>
</parent_tag>

This function will extract the values and place them in a given array. If the data isn't present in the document, the action taken depends on the value of the flag bRequired. If bRequired is false, and the data isn't there, the function simply exits. If bRequired is true, the function throws an error. In either case, if a value is not found for all species indicated, an error is thrown.

This function provides a shortcut if you need values for every species and don't need to bother with the floatVal array type.

This function is currently not protected against overflow. I could not successfully trap for the error codes the documentation says are supposed to be set.

Parameters:
p_oParent Pointer to the parent element of the element to extract. If this is a top-level element, the parent will be the XML document root element (at the time of this writing, named paramFile).
cTagName Tag name of the parent node (parent_tag).
cSubTagName Tag name of the child node (child_tag).
p_fArray Pointer to the array to put the extracted values in.
p_oPop Pointer to the tree population. This is necessary for translating species names into codes
bRequired Whether or not this value is required.
Exceptions:
Error if the value is required and it is not found, or if it is found and not all species are present (whether or not it is required).

void FillSpeciesSpecificValue ( xercesc::DOMElement *  p_oParent,
char *  cTagName,
char *  cSubTagName,
boolVal p_array,
int  iNumSpecies,
clTreePopulation p_oPop,
bool  bRequired 
)

Fills species-specific boolean values from a DOM tree.

For those values which are species-specific and have the following structure in the XML document:

<parent_tag>
<child_tag species = "sp1-name">val1</child_tag>
<child_tag species = "sp2-name">val2</child_tag>
</parent_tag>

This function will extract the values and place them in a given array, matching species codes. If the data isn't present in the document, the action taken depends on the value of the flag bRequired. If bRequired is false, and the data isn't there, the function simply exits. If bRequired is true, the function throws an error. In either case, if a value is not found for all species indicated, an error is thrown.

This expects the values to come as either 1 (true) or 0 (false).

The function will only look for values for species matching codes that are pre-loaded into the arrays. The arrays must have had memory allocated and the species codes must be pre-loaded. Duplicate and invalid species from the XML file are screened out without failure.

Parameters:
p_oParent Pointer to the parent element of the element to extract. If this is a top-level element, the parent will be the XML document root element (at the time of this writing, named paramFile).
cTagName Tag name of the parent node (parent_tag).
cSubTagName Tag name of the child node (child_tag).
p_array Pointer to the array to put the extracted values in.
iNumSpecies Number of species expected (should equal the size of the boolVal array)
p_oPop Pointer to the tree population. This is necessary for translating species names into codes
bRequired Whether or not this value is required.
Exceptions:
Error if the value is required and it is not found, or if it is found and not all species are present (whether or not it is required).

void FillSpeciesSpecificValue ( xercesc::DOMElement *  p_oParent,
char *  cTagName,
char *  cSubTagName,
intVal p_array,
int  iNumSpecies,
clTreePopulation p_oPop,
bool  bRequired 
)

Fills species-specific integer values from a DOM tree.

For those values which are species-specific and have the following structure in the XML document:

<parent_tag>
<child_tag species = "sp1-name">val1</child_tag>
<child_tag species = "sp2-name">val2</child_tag>
</parent_tag>

This function will extract the values and place them in a given array, matching species codes. If the data isn't present in the document, the action taken depends on the value of the flag bRequired. If bRequired is false, and the data isn't there, the function simply exits. If bRequired is true, the function throws an error. In either case, if a value is not found for all species indicated, an error is thrown.

The function will only look for values for species matching codes that are pre-loaded into the arrays. The arrays must have had memory allocated and the species codes must be pre-loaded. Duplicate and invalid species from the XML file are screened out without failure.

Parameters:
p_oParent Pointer to the parent element of the element to extract. If this is a top-level element, the parent will be the XML document root element (at the time of this writing, named paramFile).
cTagName Tag name of the parent node (parent_tag).
cSubTagName Tag name of the child node (child_tag).
p_array Pointer to the array to put the extracted values in.
iNumSpecies Number of species expected (should equal the size of the intVal array)
p_oPop Pointer to the tree population. This is necessary for translating species names into codes
bRequired Whether or not this value is required.
Exceptions:
Error if the value is required and it is not found, or if it is found and not all species are present (whether or not it is required).

void FillSpeciesSpecificValue ( xercesc::DOMElement *  p_oParent,
char *  cTagName,
char *  cSubTagName,
floatVal p_array,
int  iNumSpecies,
clTreePopulation p_oPop,
bool  bRequired 
)

Fills species-specific float values from a DOM tree.

For those values which are species-specific and have the following structure in the XML document:

<parent_tag>
<child_tag species = "sp1-name">val1</child_tag>
<child_tag species = "sp2-name">val2</child_tag>
</parent_tag>

This function will extract the values and place them in a given array, matching species codes. If the data isn't present in the document, the action taken depends on the value of the flag bRequired. If bRequired is false, and the data isn't there, the function simply exits. If bRequired is true, the function throws an error. In either case, if a value is not found for all species indicated, an error is thrown.

The function will only look for values for species matching codes that are pre-loaded into the arrays. The arrays must have had memory allocated and the species codes must be pre-loaded. Duplicate and invalid species from the XML file are screened out without failure.

This function is currently not protected against overflow. I could not successfully trap for the error codes the documentation says are supposed to be set.

Parameters:
p_oParent Pointer to the parent element of the element to extract. If this is a top-level element, the parent will be the XML document root element (at the time of this writing, named paramFile).
cTagName Tag name of the parent node (parent_tag).
cSubTagName Tag name of the child node (child_tag).
p_array Pointer to the array to put the extracted values in.
iNumSpecies Number of species expected (should equal the size of the floatVal array)
p_oPop Pointer to the tree population. This is necessary for translating species names into codes
bRequired Whether or not this value is required.
Exceptions:
Error if the value is required and it is not found, or if it is found and not all species are present (whether or not it is required).

short int GetNodeSpeciesCode ( xercesc::DOMNode *  p_oDocNode,
clTreePopulation p_oPop 
)

GetNodeSpeciesCode Translates a species string into a species number.

For those nodes that have an attribute named "species", this will extract the name of the species in that attribute and turn it into a code.

Parameters:
p_oDocNode Node that has the species attribute to translate.
p_oPop Tree population object.
Returns:
Species code. If the species name was unrecognized, returns -1.


Generated on Wed Oct 28 13:58:42 2009 for SORTIE Core C++ Documentation by  doxygen 1.5.6