SORTIE Core C++ Documentation
Functions
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, std::string sTagName, std::string sSubTagName, doubleVal *p_array, int iNumSpecies, clTreePopulation *p_oPop, bool bRequired)
 Fills species-specific float values from a DOM tree. More...
 
void FillSpeciesSpecificValue (xercesc::DOMElement *p_oParent, std::string sTagName, std::string sSubTagName, intVal *p_array, int iNumSpecies, clTreePopulation *p_oPop, bool bRequired)
 Fills species-specific integer values from a DOM tree. More...
 
void FillSpeciesSpecificValue (xercesc::DOMElement *p_oParent, std::string sTagName, std::string sSubTagName, boolVal *p_array, int iNumSpecies, clTreePopulation *p_oPop, bool bRequired)
 Fills species-specific boolean values from a DOM tree. More...
 
void FillSpeciesSpecificValue (xercesc::DOMElement *p_oParent, std::string sTagName, std::string sSubTagName, double *p_fArray, clTreePopulation *p_oPop, bool bRequired)
 Fills species-specific float values from a DOM tree. More...
 
void FillSpeciesSpecificValue (xercesc::DOMElement *p_oParent, std::string sTagName, std::string sSubTagName, int *p_iArray, clTreePopulation *p_oPop, bool bRequired)
 Fills species-specific integer values from a DOM tree. More...
 
short int GetNodeSpeciesCode (xercesc::DOMNode *p_oDocNode, clTreePopulation *p_oPop)
 Translates a species string into a species number. More...
 
void FillSingleValue (xercesc::DOMElement *p_oParent, std::string sTagName, int *p_iValToFill, bool bRequired)
 Extracts a single integer value from a parsed XML file. More...
 
void FillSingleValue (xercesc::DOMElement *p_oParent, std::string sTagName, double *p_fValToFill, bool bRequired)
 Extracts a single float value from a parsed XML file. More...
 
void FillSingleValue (xercesc::DOMElement *p_oParent, std::string sTagName, std::string *p_sValToFill, bool bRequired)
 Extracts a single string value from a parsed XML file. More...
 
void FillSingleValue (xercesc::DOMElement *p_oParent, std::string sTagName, bool *p_bValToFill, bool bRequired)
 Extracts a single boolean value from a parsed XML file. More...
 

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:
--------------—
October 20, 2011 - Wiped the slate clean for SORTIE 7.0 (LEM)
November 12, 2012 - Chars became strings (LEM)

Function Documentation

◆ FillSingleValue() [1/4]

void FillSingleValue ( xercesc::DOMElement *  p_oParent,
std::string  sTagName,
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_oParentPointer 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).
sTagNameThe tag name of the node.
p_iValToFillPointer to the variable to put the extracted value in.
bRequiredWhether or not this value is required.
Exceptions
Errorif the value is required and it is not found.

◆ FillSingleValue() [2/4]

void FillSingleValue ( xercesc::DOMElement *  p_oParent,
std::string  sTagName,
double *  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_oParentPointer 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).
sTagNameThe tag name of the node.
p_fValToFillPointer to the variable to put the extracted value in.
bRequiredWhether or not this value is required.
Exceptions
Errorif the value is required and it is not found. Extracts a single double 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_oParentPointer 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).
sTagNameThe tag name of the node.
p_fValToFillPointer to the variable to put the extracted value in.
bRequiredWhether or not this value is required.
Exceptions
Errorif the value is required and it is not found.

◆ FillSingleValue() [3/4]

void FillSingleValue ( xercesc::DOMElement *  p_oParent,
std::string  sTagName,
std::string *  p_sValToFill,
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_oParentPointer 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).
sTagNameThe tag name of the node.
p_sValToFillPointer to the variable to put the extracted value in.
bRequiredWhether or not this value is required.
Exceptions
Errorif the value is required and it is not found.

◆ FillSingleValue() [4/4]

void FillSingleValue ( xercesc::DOMElement *  p_oParent,
std::string  sTagName,
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_oParentPointer 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).
sTagNameThe tag name of the node.
p_bValToFillPointer to the variable to put the extracted value in.
bRequiredWhether or not this value is required.
Exceptions
Errorif the value is required and it is not found.

◆ FillSpeciesSpecificValue() [1/5]

void FillSpeciesSpecificValue ( xercesc::DOMElement *  p_oParent,
std::string  sTagName,
std::string  sSubTagName,
doubleVal 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_oParentPointer 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).
sTagNameTag name of the parent node (parent_tag).
sSubTagNameTag name of the child node (child_tag).
p_arrayPointer to the array to put the extracted values in.
iNumSpeciesNumber of species expected (should equal the size of the floatVal array)
p_oPopPointer to the tree population. This is necessary for translating species names into codes
bRequiredWhether or not this value is required.
Exceptions
Errorif 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). Fills species-specific double 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_oParentPointer 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).
sTagNameTag name of the parent node (parent_tag).
sSubTagNameTag name of the child node (child_tag).
p_arrayPointer to the array to put the extracted values in.
iNumSpeciesNumber of species expected (should equal the size of the floatVal array)
p_oPopPointer to the tree population. This is necessary for translating species names into codes
bRequiredWhether or not this value is required.
Exceptions
Errorif 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).

◆ FillSpeciesSpecificValue() [2/5]

void FillSpeciesSpecificValue ( xercesc::DOMElement *  p_oParent,
std::string  sTagName,
std::string  sSubTagName,
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_oParentPointer 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).
sTagNameTag name of the parent node (parent_tag).
sSubTagNameTag name of the child node (child_tag).
p_arrayPointer to the array to put the extracted values in.
iNumSpeciesNumber of species expected (should equal the size of the intVal array)
p_oPopPointer to the tree population. This is necessary for translating species names into codes
bRequiredWhether or not this value is required.
Exceptions
Errorif 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).

◆ FillSpeciesSpecificValue() [3/5]

void FillSpeciesSpecificValue ( xercesc::DOMElement *  p_oParent,
std::string  sTagName,
std::string  sSubTagName,
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_oParentPointer 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).
sTagNameTag name of the parent node (parent_tag).
sSubTagNameTag name of the child node (child_tag).
p_arrayPointer to the array to put the extracted values in.
iNumSpeciesNumber of species expected (should equal the size of the boolVal array)
p_oPopPointer to the tree population. This is necessary for translating species names into codes
bRequiredWhether or not this value is required.
Exceptions
Errorif 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).

◆ FillSpeciesSpecificValue() [4/5]

void FillSpeciesSpecificValue ( xercesc::DOMElement *  p_oParent,
std::string  sTagName,
std::string  sSubTagName,
double *  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_oParentPointer 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).
sTagNameTag name of the parent node (parent_tag).
sSubTagNameTag name of the child node (child_tag).
p_fArrayPointer to the array to put the extracted values in.
p_oPopPointer to the tree population. This is necessary for translating species names into codes
bRequiredWhether or not this value is required.
Exceptions
Errorif 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). Fills species-specific double 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 doubleVal 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_oParentPointer 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).
sTagNameTag name of the parent node (parent_tag).
sSubTagNameTag name of the child node (child_tag).
p_fArrayPointer to the array to put the extracted values in.
p_oPopPointer to the tree population. This is necessary for translating species names into codes
bRequiredWhether or not this value is required.
Exceptions
Errorif 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).

◆ FillSpeciesSpecificValue() [5/5]

void FillSpeciesSpecificValue ( xercesc::DOMElement *  p_oParent,
std::string  sTagName,
std::string  sSubTagName,
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_oParentPointer 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).
sTagNameTag name of the parent node (parent_tag).
sSubTagNameTag name of the child node (child_tag).
p_iArrayPointer to the array to put the extracted values in.
p_oPopPointer to the tree population. This is necessary for translating species names into codes
bRequiredWhether or not this value is required.
Exceptions
Errorif 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).

◆ GetNodeSpeciesCode()

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

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_oDocNodeNode that has the species attribute to translate.
p_oPopTree population object.
Returns
Species code. If the species name was unrecognized, returns -1.