22 #ifndef NANDRAD_UtilitiesH    23 #define NANDRAD_UtilitiesH    32 #include <IBK_LinearSpline.h>    33 #include <IBK_StringUtils.h>    34 #include <IBK_point.h>    36 #include <IBKMK_Vector3D.h>    55 TiXmlElement * 
openXMLFile(
const std::map<std::string,IBK::Path>  &pathPlaceHolders, 
const IBK::Path & filename,
    56     const std::string & parentXmlTag, TiXmlDocument & doc);
    60                              IBK::LinearSpline & spl, std::string & name, IBK::Unit * xunit, IBK::Unit * yunit);
    70 void writeLinearSplineElement(TiXmlElement * parent, 
const std::string & name, 
const IBK::LinearSpline & spl, 
const std::string & xunit, 
const std::string & yunit);
    82 void readVector(
const TiXmlElement * element, 
const std::string & name, std::vector<T> & vec) {
    83     FUNCID(NANDRAD::readVector);
    84     std::string text = element->GetText();
    85     text = IBK::replace_string(text, 
",", 
" ");
    87         IBK::string2vector(text, vec);
    88     } 
catch (IBK::Exception & ex) {
    89         throw IBK::Exception( ex, IBK::FormatString(XML_READ_ERROR).arg(element->Row()).arg(
    90             IBK::FormatString(
"Error reading vector element '%1'.").arg(name) ), FUNC_ID);
    96 void readVector(
const TiXmlElement * element, 
const std::string & name, std::vector<double> & vec);
   100 void writeVector(TiXmlElement * parent, 
const std::string & name, 
const std::vector<T> & vec) {
   102         TiXmlElement * child = 
new TiXmlElement(name);
   103         parent->LinkEndChild(child);
   105         std::stringstream vals;
   106         for (
unsigned int i=0; i<vec.size(); ++i) {
   108             if (i<vec.size()-1)  vals << 
",";
   110         TiXmlText * text = 
new TiXmlText( vals.str() );
   111         child->LinkEndChild( text );
   116 template <
typename T>
   117 T readPODAttributeValue(
const TiXmlElement * element, 
const TiXmlAttribute * attrib) {
   118     FUNCID(NANDRAD::readPODAttributeValue);
   120         return IBK::string2val<T>(attrib->ValueStr());
   121     } 
catch (IBK::Exception & ex) {
   122         throw IBK::Exception( ex, IBK::FormatString(XML_READ_ERROR).arg(element->Row()).arg(
   123             IBK::FormatString(
"Error reading '"+attrib->NameStr()+
"' attribute.") ), FUNC_ID);
   127 template <
typename T>
   128 T readPODElement(
const TiXmlElement * element, 
const std::string & eName) {
   129     FUNCID(NANDRAD::readPODElement);
   131         return IBK::string2val<T>(element->GetText());
   132     } 
catch (IBK::Exception & ex) {
   133         throw IBK::Exception( ex, IBK::FormatString(XML_READ_ERROR).arg(element->Row()).arg(
   134             IBK::FormatString(
"Error reading '"+eName+
"' tag.") ), FUNC_ID);
   139 IBK::Unit 
readUnitElement(
const TiXmlElement * element, 
const std::string & eName);
   141 IBK::Time 
readTimeElement(
const TiXmlElement * element, 
const std::string & eName);
   144 TiXmlElement * 
writeVector3D(TiXmlElement * parent, 
const std::string & name, 
const std::vector<IBKMK::Vector3D> & vec);
   147 void readVector3D(
const TiXmlElement * element, 
const std::string & name, std::vector<IBKMK::Vector3D> & vec);
   150 template <
typename T>
   151 void readPoint2D(
const TiXmlElement * element, 
const std::string & name, IBK::point2D<T> & p) {
   152     FUNCID(NANDRAD::readPoint2D);
   153     std::string text = element->GetText();
   155         typename std::vector<T> vec;
   156         IBK::string2vector(text, vec);
   158             throw IBK::Exception(
"Size mismatch, expected 2 numbers separated by , .", FUNC_ID);
   162     catch (IBK::Exception & ex) {
   163         throw IBK::Exception( ex, IBK::FormatString(XML_READ_ERROR).arg(element->Row()).arg(
   164             IBK::FormatString(
"Error reading point2D element '%1'.").arg(name) ), FUNC_ID);
   170 void readPoint2D(
const TiXmlElement * element, 
const std::string & name, IBK::point2D<double> & p);
   172 template <
typename T>
   173 void writePoint2D(TiXmlElement * parent, 
const std::string & name, 
const IBK::point2D<T> & p) {
   174     TiXmlElement * child = 
new TiXmlElement(name);
   175     parent->LinkEndChild(child);
   177     std::stringstream vals;
   178     vals << p.m_x << 
" " << p.m_y;
   179     TiXmlText * text = 
new TiXmlText( vals.str() );
   180     child->LinkEndChild( text );
   186 #endif // NANDRAD_UtilitiesH void readParameterElement(const TiXmlElement *element, IBK::Parameter &p)
Reads an IBK::Parameter from XML element (with proper error handling). 
 
IBK::Time readTimeElement(const TiXmlElement *element, const std::string &eName)
Read an IBK:Time tag. 
 
TiXmlElement * openXMLFile(const std::map< std::string, IBK::Path > &pathPlaceHolders, const IBK::Path &filename, const std::string &parentXmlTag, TiXmlDocument &doc)
Attempts to open an XML file, hereby substituting placeholders in the file name and checking if the t...
 
Contains global constants for the Nandrad data model. 
 
void readIntParaElement(const TiXmlElement *element, IBK::IntPara &p)
Reads an IBK::IntPara from XML element (with proper error handling). 
 
TiXmlElement * writeVector3D(TiXmlElement *parent, const std::string &name, const std::vector< IBKMK::Vector3D > &vec)
Writes out a vector of Vector3D elements. 
 
IBK::Unit readUnitElement(const TiXmlElement *element, const std::string &eName)
Read an IBK:Unit tag. 
 
void writeLinearSplineElement(TiXmlElement *parent, const std::string &name, const IBK::LinearSpline &spl, const std::string &xunit, const std::string &yunit)
Writes a linear spline into XML format. 
 
void readVector3D(const TiXmlElement *element, const std::string &name, std::vector< IBKMK::Vector3D > &vec)
Reads a vector of Vector3D elements. 
 
void readFlagElement(const TiXmlElement *element, IBK::Flag &f)
Reads an IBK::Flag from XML element (with proper error handling). 
 
void readLinearSplineElement(const TiXmlElement *element, IBK::LinearSpline &spl, std::string &name, IBK::Unit *xunit, IBK::Unit *yunit)
Reads a linear spline from XML element (with proper error handling). 
 
The namespace NANDRAD contains the data model classes that make up the NANDRAD solver input data...