#include #include #include #include #include "preXmlAngle.hh" #include "DWUnits.hh" #include "ExpatInterface/Element.h" namespace preXml { void Angle::readFrom(const xml::Element & elt) { // Check we are reading the right kind of entity. assert(elt.getTagName() == string("angle")); // These will be our allowed units: typedef std::map UnitMap; UnitMap uM; uM[string("radian")] = DWradian; uM[string("degree")] = DWdegree; // Check we know this particular unit. string unit(elt[string("unit")]); assert(uM.find(unit) != uM.end()); // OK, we know the unit. We can go on. istrstream is(elt[string("value")].c_str()); double faceValue; is >> faceValue; this->_value = faceValue*uM[unit]; }; void Angle::printMeNicelyTo(ostream & os) const { os << this->_value / DWdegree << " degree"; }; } // End of namespace