// Copyright (C) 2006 Erik Dahlberg
//
-// This file is part of LSystem3d.
+// This file is part of LSystem3D.
//
// LSystem3D is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
+#include <cstdlib>
+
+#include <sstream>
#include <string>
+#include <libxml++/attribute.h>
#include <libxml++/document.h>
#include <libxml++/nodes/element.h>
#include <libxml++/nodes/node.h>
#include <libxml++/parsers/domparser.h>
-#include <glibmm/stringutils.h>
-
#include "xmlstructure.h"
using namespace std;
*/
void XMLStructure::addNumber(double value)
{
- // convert double -> string
- string numberAsString = Glib::Ascii::dtostr(value);
-
- addString(numberAsString);
+ addString(doubleToString(value));
}
*/
double XMLStructure::getNumber()
{
- // convert string -> double
- double number = Glib::Ascii::strtod(getString());
+ double number = strtod(getString().c_str(), NULL);
return number;
}
xmlpp::Element *child = dynamic_cast<xmlpp::Element*>(*_activeChildInList);
// its attribute value
- string attributeValue = child->get_attribute(name)->get_value();
+ string attributeValue;
+ xmlpp::Attribute *attribute = child->get_attribute(name);
+
+ if (attribute)
+ {
+ attributeValue = attribute->get_value();
+ }
return attributeValue;
}
+
+
+
+/**
+ * Convert double to string
+ * @param doubleValue the double value
+ * @return the corresponding string
+ */
+string XMLStructure::doubleToString(double doubleValue)
+{
+ ostringstream doubleAsString;
+ doubleAsString << doubleValue;
+
+ return doubleAsString.str();
+}