+static void dumpProperties(const SGPropertyNode *node)
+{
+ using namespace simgear;
+ cout << node->getPath() << '/' << endl;
+ for (int i = 0; i < node->nChildren(); i++) {
+ const SGPropertyNode *c = node->getChild(i);
+ props::Type type = c->getType();
+ if (type == props::ALIAS || c->nChildren())
+ continue;
+
+ int index = c->getIndex();
+ cout << std::setw(11) << getValueTypeString(c) << " " << c->getName();
+ if (index > 0)
+ cout << '[' << index << ']';
+ cout << " = ";
+
+ switch (c->getType()) {
+ case props::DOUBLE:
+ case props::FLOAT:
+ case props::VEC3D:
+ case props::VEC4D:
+ {
+ std::streamsize precision = cout.precision(15);
+ c->printOn(cout);
+ cout.precision(precision);
+ }
+ break;
+ case props::LONG:
+ case props::INT:
+ case props::BOOL:
+ c->printOn(cout);
+ break;
+ case props::STRING:
+ cout << '"' << c->getStringValue() << '"';
+ break;
+ case props::NONE:
+ break;
+ default:
+ cout << '\'' << c->getStringValue() << '\'';
+ }
+ cout << endl;
+ }
+ cout << endl;
+}
+
+
+static void sanitize(stdString& s)
+{
+ stdString r = s;
+ s = "";
+ for (unsigned i = 0; i < r.size(); i++) {
+ if (r[i] == '\a')
+ s += "\\a";
+ else if (r[i] == '\b')
+ s += "\\b";
+ else if (r[i] == '\t')
+ s += "\\t";
+ else if (r[i] == '\n')
+ s += "\\n";
+ else if (r[i] == '\v')
+ s += "\\v";
+ else if (r[i] == '\f')
+ s += "\\f";
+ else if (r[i] == '\r')
+ s += "\\r";
+ else if (r[i] == '\'')
+ s += "\'";
+ else if (r[i] == '\\')
+ s += "\\";
+ else if (isprint(r[i]))
+ s += r[i];
+ else {
+ const char *hex = "0123456789abcdef";
+ int c = r[i] & 255;
+ s += stdString("\\x") + hex[c / 16] + hex[c % 16];
+ }
+ }
+}
+
+