-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
#include <simgear/compiler.h>
#include <stdlib.h> // atof() atoi()
+#include <simgear/sg_inlines.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/xml/easyxml.hxx>
State &st = state();
if (_level == 0) {
- if (string(name) != "PropertyList") {
+ if (string(name) != (string)"PropertyList") {
SG_LOG(SG_INPUT, SG_ALERT, "Root element name is " <<
name << "; expected PropertyList");
_ok = false;
int index = 0;
if (att_n != 0) {
index = atoi(att_n);
- st.counters[name] = max(st.counters[name], index+1);
+ st.counters[name] = SG_MAX2(st.counters[name], index+1);
} else {
index = st.counters[name];
st.counters[name]++;
ret = st.node->setBoolValue(false);
} else if (st.type == "int") {
ret = st.node->setIntValue(atoi(_data.c_str()));
+ } else if (st.type == "long") {
+ ret = st.node->setLongValue(strtol(_data.c_str(), 0, 0));
} else if (st.type == "float") {
ret = st.node->setFloatValue(atof(_data.c_str()));
} else if (st.type == "double") {
- ret = st.node->setDoubleValue(atof(_data.c_str()));
+ ret = st.node->setDoubleValue(strtod(_data.c_str(), 0));
} else if (st.type == "string") {
ret = st.node->setStringValue(_data);
} else if (st.type == "unknown") {
* Return the type name.
*/
static const char *
-getTypeName (SGValue::Type type)
+getTypeName (SGPropertyNode::Type type)
{
switch (type) {
case SGValue::UNKNOWN:
return "bool";
case SGValue::INT:
return "int";
+ case SGValue::LONG:
+ return "long";
case SGValue::FLOAT:
return "float";
case SGValue::DOUBLE:
// write it first.
if (node->hasValue()) {
doIndent(output, indent);
- output << '<' << name << " n=\"" << index;
- if (node->isAlias() && node->getAliasTarget() != 0) {
- output << "\" alias=\""
- << node->getAliasTarget()->getPath() << "\"/>" << endl;
- } else {
- if (node->getType() != SGValue::UNKNOWN)
- output << "\" type=\"" << getTypeName(node->getType()) << '"';
+ output << '<' << name << " n=\"" << index << '"';
+ if (node->isAlias() && node->getAliasTarget() != 0)
+ output << " alias=\"" << node->getAliasTarget()->getPath() << "\"/>";
+ else {
+ if (node->getType() != SGPropertyNode::UNKNOWN)
+ output << " type=\"" << getTypeName(node->getType()) << '"';
output << '>';
writeData(output, node->getStringValue());
- output << "</" << name << '>' << endl;;
+ output << "</" << name << '>' << endl;
}
}
// If there are children, write them
// next.
- if (nChildren > 0) {
+ if (nChildren > 0 || node->isAlias()) {
doIndent(output, indent);
- output << '<' << name << " n=\"" << index << "\">" << endl;;
+ output << '<' << name << " n=\"" << index << '"';
+ if (node->isAlias() && node->getAliasTarget() != 0)
+ output << " alias=\"" << node->getAliasTarget()->getPath() << '"';
+ output << '>' << endl;
for (int i = 0; i < nChildren; i++)
writeNode(output, node->getChild(i), indent + INDENT_STEP);
doIndent(output, indent);
// If there were no children and no
// value, at least note the presence
// of the node.
- if (nChildren == 0 && !node->hasValue()) {
- doIndent(output, indent);
- output << '<' << name << " n=\"" << index << "\"/>" << endl;
- }
+// if (nChildren == 0 && !node->isAlias() && !node->hasValue()) {
+// doIndent(output, indent);
+// output << '<' << name << " n=\"" << index << "\"/>" << endl;
+// }
return true;
}
if (!out->setIntValue(in->getIntValue()))
retval = false;
break;
+ case SGValue::LONG:
+ if (!out->setLongValue(in->getLongValue()))
+ retval = false;
+ break;
case SGValue::FLOAT:
if (!out->setFloatValue(in->getFloatValue()))
retval = false;