1 // props.cxx - implementation of a property list.
2 // Started Fall 2000 by David Megginson, david@megginson.com
3 // This code is released into the Public Domain.
5 // See props.html for documentation [replace with URL when available].
13 #include <simgear/compiler.h>
25 ////////////////////////////////////////////////////////////////////////
27 ////////////////////////////////////////////////////////////////////////
30 * Comparator class for sorting by index.
35 int operator() (const SGPropertyNode * n1, const SGPropertyNode *n2) const {
36 return (n1->getIndex() < n2->getIndex());
42 ////////////////////////////////////////////////////////////////////////
43 // Convenience macros for value access.
44 ////////////////////////////////////////////////////////////////////////
46 #define GET_BOOL (_value.bool_val->getValue())
47 #define GET_INT (_value.int_val->getValue())
48 #define GET_LONG (_value.long_val->getValue())
49 #define GET_FLOAT (_value.float_val->getValue())
50 #define GET_DOUBLE (_value.double_val->getValue())
51 #define GET_STRING (_value.string_val->getValue())
53 #define SET_BOOL(val) (_value.bool_val->setValue(val))
54 #define SET_INT(val) (_value.int_val->setValue(val))
55 #define SET_LONG(val) (_value.long_val->setValue(val))
56 #define SET_FLOAT(val) (_value.float_val->setValue(val))
57 #define SET_DOUBLE(val) (_value.double_val->setValue(val))
58 #define SET_STRING(val) (_value.string_val->setValue(val))
62 ////////////////////////////////////////////////////////////////////////
63 // Default values for every type.
64 ////////////////////////////////////////////////////////////////////////
66 const bool SGRawValue<bool>::DefaultValue = false;
67 const int SGRawValue<int>::DefaultValue = 0;
68 const long SGRawValue<long>::DefaultValue = 0L;
69 const float SGRawValue<float>::DefaultValue = 0.0;
70 const double SGRawValue<double>::DefaultValue = 0.0L;
71 const string SGRawValue<string>::DefaultValue = "";
75 ////////////////////////////////////////////////////////////////////////
76 // Local path normalization code.
77 ////////////////////////////////////////////////////////////////////////
80 * A component in a path.
89 * Parse the name for a path component.
91 * Name: [_a-zA-Z][-._a-zA-Z0-9]*
94 parse_name (const string &path, int &i)
97 int max = path.size();
101 if (i < max && path[i] == '.') {
107 if (i < max && path[i] != '/')
108 throw string(string("Illegal character after ") + name);
111 else if (isalpha(path[i]) || path[i] == '_') {
115 // The rules inside a name are a little
118 if (isalpha(path[i]) || isdigit(path[i]) || path[i] == '_' ||
119 path[i] == '-' || path[i] == '.') {
121 } else if (path[i] == '[' || path[i] == '/') {
124 throw string("name may contain only ._- and alphanumeric characters");
131 if (name.size() == 0)
132 throw string("name must begin with alpha or '_'");
140 * Parse the optional integer index for a path component.
142 * Index: "[" [0-9]+ "]"
145 parse_index (const string &path, int &i)
154 for (int max = path.size(); i < max; i++) {
155 if (isdigit(path[i])) {
156 index = (index * 10) + (path[i] - '0');
157 } else if (path[i] == ']') {
165 throw string("unterminated index (looking for ']')");
170 * Parse a single path component.
172 * Component: Name Index?
174 static inline PathComponent
175 parse_component (const string &path, int &i)
177 PathComponent component;
178 component.name = parse_name(path, i);
179 if (component.name[0] != '.')
180 component.index = parse_index(path, i);
182 component.index = -1;
188 * Parse a path into its components.
191 parse_path (const string &path, vector<PathComponent> &components)
194 int max = path.size();
196 // Check for initial '/'
197 if (path[pos] == '/') {
201 components.push_back(root);
203 while (pos < max && path[pos] == '/')
208 components.push_back(parse_component(path, pos));
209 while (pos < max && path[pos] == '/')
216 ////////////////////////////////////////////////////////////////////////
217 // Other static utility functions.
218 ////////////////////////////////////////////////////////////////////////
222 * Locate a child node by name and index.
225 find_child (const string &name, int index, vector<SGPropertyNode *> nodes)
227 int nNodes = nodes.size();
228 for (int i = 0; i < nNodes; i++) {
229 SGPropertyNode * node = nodes[i];
230 if (node->getName() == name && node->getIndex() == index)
238 * Locate another node, given a relative path.
240 static SGPropertyNode *
241 find_node (SGPropertyNode * current,
242 const vector<PathComponent> &components,
246 // Run off the end of the list
251 // Success! This is the one we want.
252 else if (position >= components.size()) {
256 // Empty component means root.
257 else if (components[position].name == "") {
258 return find_node(current->getRootNode(), components, position + 1, create);
261 // . means current directory
262 else if (components[position].name == ".") {
263 return find_node(current, components, position + 1, create);
266 // .. means parent directory
267 else if (components[position].name == "..") {
268 SGPropertyNode * parent = current->getParent();
270 throw string("Attempt to move past root with '..'");
272 return find_node(parent, components, position + 1, create);
275 // Otherwise, a child name
277 SGPropertyNode * child =
278 current->getChild(components[position].name,
279 components[position].index,
281 return find_node(child, components, position + 1, create);
287 ////////////////////////////////////////////////////////////////////////
288 // Implementation of SGValue.
289 ////////////////////////////////////////////////////////////////////////
293 * Default constructor.
295 * The type will be UNKNOWN and the raw value will be "".
298 : _type(UNKNOWN), _tied(false)
300 _value.string_val = new SGRawValueInternal<string>;
307 SGValue::SGValue (const SGValue &source)
309 _type = source._type;
310 _tied = source._tied;
311 switch (source._type) {
314 _value.alias = (SGValue *)(source.getAlias());
317 _value.bool_val = source._value.bool_val->clone();
320 _value.int_val = source._value.int_val->clone();
323 _value.long_val = source._value.long_val->clone();
326 _value.float_val = source._value.float_val->clone();
329 _value.double_val = source._value.double_val->clone();
333 _value.string_val = source._value.string_val->clone();
350 * Delete and clear the current value.
353 SGValue::clear_value ()
357 _value.alias->clear_value();
359 delete _value.bool_val;
363 delete _value.int_val;
367 delete _value.long_val;
368 _value.long_val = 0L;
371 delete _value.float_val;
372 _value.float_val = 0;
375 delete _value.double_val;
376 _value.double_val = 0;
380 delete _value.string_val;
381 _value.string_val = 0;
388 * Get the current type.
390 * Does not return a type of ALIAS.
393 SGValue::getType () const
396 return _value.alias->getType();
403 * Get the current aliased value.
408 return (_type == ALIAS ? _value.alias : 0);
413 * Get the current aliased value.
416 SGValue::getAlias () const
418 return (_type == ALIAS ? _value.alias : 0);
423 * Alias to another value.
426 SGValue::alias (SGValue * alias)
428 if (alias == 0 || _type == ALIAS || _tied)
431 _value.alias = alias;
438 * Unalias from another value.
443 // FIXME: keep copy of previous value,
447 _value.string_val = new SGRawValueInternal<string>;
454 * Get a boolean value.
457 SGValue::getBoolValue () const
461 return _value.alias->getBoolValue();
465 return GET_INT == 0 ? false : true;
467 return GET_LONG == 0L ? false : true;
469 return GET_FLOAT == 0.0 ? false : true;
471 return GET_DOUBLE == 0.0L ? false : true;
474 return (GET_STRING == "true" || getDoubleValue() != 0.0L);
480 * Get an integer value.
483 SGValue::getIntValue () const
487 return _value.alias->getIntValue();
489 return int(GET_BOOL);
493 return int(GET_LONG);
495 return int(GET_FLOAT);
497 return int(GET_DOUBLE);
500 return atoi(GET_STRING.c_str());
506 * Get a long integer value.
509 SGValue::getLongValue () const
513 return _value.alias->getLongValue();
515 return long(GET_BOOL);
517 return long(GET_INT);
521 return long(GET_FLOAT);
523 return long(GET_DOUBLE);
526 return strtol(GET_STRING.c_str(), 0, 0);
535 SGValue::getFloatValue () const
539 return _value.alias->getFloatValue();
541 return float(GET_BOOL);
543 return float(GET_INT);
545 return float(GET_LONG);
549 return float(GET_DOUBLE);
552 return atof(GET_STRING.c_str());
558 * Get a double value.
561 SGValue::getDoubleValue () const
565 return _value.alias->getDoubleValue();
567 return double(GET_BOOL);
569 return double(GET_INT);
571 return double(GET_LONG);
573 return double(GET_FLOAT);
578 return strtod(GET_STRING.c_str(), 0);
584 * Get a string value.
587 SGValue::getStringValue () const
593 return _value.alias->getStringValue();
600 sprintf(buf, "%d", GET_INT);
603 sprintf(buf, "%ld", GET_LONG);
606 sprintf(buf, "%f", GET_FLOAT);
609 sprintf(buf, "%lf", GET_DOUBLE);
622 SGValue::setBoolValue (bool value)
624 if (_type == UNKNOWN) {
626 _value.bool_val = new SGRawValueInternal<bool>;
632 return _value.alias->setBoolValue(value);
634 return SET_BOOL(value);
636 return SET_INT(int(value));
638 return SET_LONG(long(value));
640 return SET_FLOAT(float(value));
642 return SET_DOUBLE(double(value));
644 return SET_STRING(value ? "true" : "false");
655 SGValue::setIntValue (int value)
657 if (_type == UNKNOWN) {
659 _value.int_val = new SGRawValueInternal<int>;
665 return _value.alias->setIntValue(value);
667 return SET_BOOL(value == 0 ? false : true);
669 return SET_INT(value);
671 return SET_LONG(long(value));
673 return SET_FLOAT(float(value));
675 return SET_DOUBLE(double(value));
678 sprintf(buf, "%d", value);
679 return SET_STRING(buf);
691 SGValue::setLongValue (long value)
693 if (_type == UNKNOWN) {
695 _value.long_val = new SGRawValueInternal<long>;
701 return _value.alias->setLongValue(value);
703 return SET_BOOL(value == 0L ? false : true);
705 return SET_INT(int(value));
707 return SET_LONG(value);
709 return SET_FLOAT(float(value));
711 return SET_DOUBLE(double(value));
714 sprintf(buf, "%d", value);
715 return SET_STRING(buf);
727 SGValue::setFloatValue (float value)
729 if (_type == UNKNOWN) {
731 _value.float_val = new SGRawValueInternal<float>;
737 return _value.alias->setFloatValue(value);
739 return SET_BOOL(value == 0.0 ? false : true);
741 return SET_INT(int(value));
743 return SET_LONG(long(value));
745 return SET_FLOAT(value);
747 return SET_DOUBLE(double(value));
750 sprintf(buf, "%f", value);
751 return SET_STRING(buf);
760 * Set a double value.
763 SGValue::setDoubleValue (double value)
765 if (_type == UNKNOWN) {
767 _value.double_val = new SGRawValueInternal<double>;
773 return _value.alias->setDoubleValue(value);
775 return SET_BOOL(value == 0.0L ? false : true);
777 return SET_INT(int(value));
779 return SET_LONG(long(value));
781 return SET_FLOAT(float(value));
783 return SET_DOUBLE(value);
786 sprintf(buf, "%lf", value);
787 return SET_STRING(buf);
796 * Set a string value.
799 SGValue::setStringValue (string value)
801 if (_type == UNKNOWN) {
803 _value.string_val = new SGRawValueInternal<string>;
809 return _value.alias->setStringValue(value);
811 return SET_BOOL((value == "true" || atoi(value.c_str())) ? true : false);
813 return SET_INT(atoi(value.c_str()));
815 return SET_LONG(strtol(value.c_str(), 0, 0));
817 return SET_FLOAT(atof(value.c_str()));
819 return SET_DOUBLE(strtod(value.c_str(), 0));
821 return SET_STRING(value);
829 * Set a value of unknown type (stored as a string).
832 SGValue::setUnknownValue (string value)
836 return _value.alias->setUnknownValue(value);
838 return SET_BOOL((value == "true" || atoi(value.c_str())) ? true : false);
840 return SET_INT(atoi(value.c_str()));
842 return SET_LONG(strtol(value.c_str(), 0, 0));
844 return SET_FLOAT(atof(value.c_str()));
846 return SET_DOUBLE(strtod(value.c_str(), 0));
849 return SET_STRING(value);
860 SGValue::tie (const SGRawValue<bool> &value, bool use_default)
863 return _value.alias->tie(value, use_default);
869 old_val = getBoolValue();
874 _value.bool_val = value.clone();
877 setBoolValue(old_val);
887 SGValue::tie (const SGRawValue<int> &value, bool use_default)
890 return _value.alias->tie(value, use_default);
896 old_val = getIntValue();
901 _value.int_val = value.clone();
904 setIntValue(old_val);
914 SGValue::tie (const SGRawValue<long> &value, bool use_default)
917 return _value.alias->tie(value, use_default);
923 old_val = getLongValue();
928 _value.long_val = value.clone();
931 setLongValue(old_val);
941 SGValue::tie (const SGRawValue<float> &value, bool use_default)
944 return _value.alias->tie(value, use_default);
950 old_val = getFloatValue();
955 _value.float_val = value.clone();
958 setFloatValue(old_val);
965 * Tie a double value.
968 SGValue::tie (const SGRawValue<double> &value, bool use_default)
971 return _value.alias->tie(value, use_default);
977 old_val = getDoubleValue();
982 _value.double_val = value.clone();
985 setDoubleValue(old_val);
992 * Tie a string value.
995 SGValue::tie (const SGRawValue<string> &value, bool use_default)
998 return _value.alias->tie(value, use_default);
1004 old_val = getStringValue();
1009 _value.string_val = value.clone();
1012 setStringValue(old_val);
1029 return _value.alias->untie();
1032 bool val = getBoolValue();
1034 _value.bool_val = new SGRawValueInternal<bool>;
1039 int val = getIntValue();
1041 _value.int_val = new SGRawValueInternal<int>;
1046 long val = getLongValue();
1048 _value.long_val = new SGRawValueInternal<long>;
1053 float val = getFloatValue();
1055 _value.float_val = new SGRawValueInternal<float>;
1060 double val = getDoubleValue();
1062 _value.double_val = new SGRawValueInternal<double>;
1067 string val = getStringValue();
1069 _value.string_val = new SGRawValueInternal<string>;
1081 ////////////////////////////////////////////////////////////////////////
1082 // Implementation of SGPropertyNode.
1083 ////////////////////////////////////////////////////////////////////////
1087 * Utility function: given a value, find the property node.
1089 static SGPropertyNode *
1090 find_node_by_value (SGPropertyNode * start_node, const SGValue * value)
1092 if (start_node->getValue() == value) {
1094 } else for (int i = 0; i < start_node->nChildren(); i++) {
1095 SGPropertyNode * child =
1096 find_node_by_value(start_node->getChild(i), value);
1105 * Default constructor: always creates a root node.
1107 SGPropertyNode::SGPropertyNode ()
1108 : _value(0), _name(""), _index(0), _parent(0), _target(0)
1114 * Convenience constructor.
1116 SGPropertyNode::SGPropertyNode (const string &name,
1117 int index, SGPropertyNode * parent)
1118 : _value(0), _name(name), _index(index), _parent(parent), _target(0)
1126 SGPropertyNode::~SGPropertyNode ()
1129 for (int i = 0; i < _children.size(); i++)
1130 delete _children[i];
1135 * Get a value, optionally creating it if not present.
1138 SGPropertyNode::getValue (bool create)
1140 if (_value == 0 && create)
1141 _value = new SGValue();
1147 * Alias to another node.
1150 SGPropertyNode::alias (SGPropertyNode * target)
1153 _value = new SGValue();
1155 return _value->alias(target->getValue(true));
1160 * Alias to another node by path.
1163 SGPropertyNode::alias (const string &path)
1165 return alias(getNode(path, true));
1173 SGPropertyNode::unalias ()
1176 return (_value != 0 ? _value->unalias() : false);
1181 * Test whether this node is aliased.
1184 SGPropertyNode::isAlias () const
1186 return (_value != 0 ? _value->isAlias() : false);
1191 * Get the target of an alias.
1193 * This is tricky, because it is actually the value that is aliased,
1194 * and someone could realias or unalias the value directly without
1195 * going through the property node. The node caches its best guess,
1196 * but it may have to search the whole property tree.
1198 * @return The target node for the alias, or 0 if the node is not aliased.
1201 SGPropertyNode::getAliasTarget ()
1203 if (_value == 0 || !_value->isAlias()) {
1205 } else if (_target != 0 && _target->getValue() == _value->getAlias()) {
1208 _target = find_node_by_value(getRootNode(), _value->getAlias());
1213 const SGPropertyNode *
1214 SGPropertyNode::getAliasTarget () const
1216 if (_value == 0 || !_value->isAlias()) {
1218 } else if (_target != 0 && _target->getValue() == _value->getAlias()) {
1221 // FIXME: const cast
1223 find_node_by_value((SGPropertyNode *)getRootNode(), _value->getAlias());
1229 * Get a non-const child by index.
1232 SGPropertyNode::getChild (int position)
1234 if (position >= 0 && position < nChildren())
1235 return _children[position];
1242 * Get a const child by index.
1244 const SGPropertyNode *
1245 SGPropertyNode::getChild (int position) const
1247 if (position >= 0 && position < nChildren())
1248 return _children[position];
1255 * Get a non-const child by name and index, creating if necessary.
1258 SGPropertyNode::getChild (const string &name, int index, bool create)
1260 int pos = find_child(name, index, _children);
1262 return _children[pos];
1263 } else if (create) {
1264 _children.push_back(new SGPropertyNode(name, index, this));
1265 return _children[_children.size()-1];
1273 * Get a const child by name and index.
1275 const SGPropertyNode *
1276 SGPropertyNode::getChild (const string &name, int index) const
1278 int pos = find_child(name, index, _children);
1280 return _children[pos];
1287 * Get all children with the same name (but different indices).
1289 vector<SGPropertyNode *>
1290 SGPropertyNode::getChildren (const string &name)
1292 vector<SGPropertyNode *> children;
1293 int max = _children.size();
1295 for (int i = 0; i < max; i++)
1296 if (_children[i]->getName() == name)
1297 children.push_back(_children[i]);
1299 sort(children.begin(), children.end(), CompareIndices());
1305 * Get all children const with the same name (but different indices).
1307 vector<const SGPropertyNode *>
1308 SGPropertyNode::getChildren (const string &name) const
1310 vector<const SGPropertyNode *> children;
1311 int max = _children.size();
1313 for (int i = 0; i < max; i++)
1314 if (_children[i]->getName() == name)
1315 children.push_back(_children[i]);
1317 sort(children.begin(), children.end(), CompareIndices());
1323 SGPropertyNode::getPath (bool simplify) const
1328 string path = _parent->getPath(simplify);
1331 if (_index != 0 || !simplify) {
1333 sprintf(buffer, "[%d]", _index);
1340 SGPropertyNode::getType () const
1343 return _value->getType();
1345 return SGValue::UNKNOWN;
1350 SGPropertyNode::getBoolValue () const
1352 return (_value == 0 ? SGRawValue<bool>::DefaultValue
1353 : _value->getBoolValue());
1357 SGPropertyNode::getIntValue () const
1359 return (_value == 0 ? SGRawValue<int>::DefaultValue
1360 : _value->getIntValue());
1364 SGPropertyNode::getLongValue () const
1366 return (_value == 0 ? SGRawValue<long>::DefaultValue
1367 : _value->getLongValue());
1371 SGPropertyNode::getFloatValue () const
1373 return (_value == 0 ? SGRawValue<float>::DefaultValue
1374 : _value->getFloatValue());
1378 SGPropertyNode::getDoubleValue () const
1380 return (_value == 0 ? SGRawValue<double>::DefaultValue
1381 : _value->getDoubleValue());
1385 SGPropertyNode::getStringValue () const
1387 return (_value == 0 ? SGRawValue<string>::DefaultValue
1388 : _value->getStringValue());
1392 SGPropertyNode::setBoolValue (bool val)
1395 _value = new SGValue();
1396 return _value->setBoolValue(val);
1400 SGPropertyNode::setIntValue (int val)
1403 _value = new SGValue();
1404 return _value->setIntValue(val);
1408 SGPropertyNode::setLongValue (long val)
1411 _value = new SGValue();
1412 return _value->setLongValue(val);
1416 SGPropertyNode::setFloatValue (float val)
1419 _value = new SGValue();
1420 return _value->setFloatValue(val);
1424 SGPropertyNode::setDoubleValue (double val)
1427 _value = new SGValue();
1428 return _value->setDoubleValue(val);
1432 SGPropertyNode::setStringValue (string val)
1435 _value = new SGValue();
1436 return _value->setStringValue(val);
1440 SGPropertyNode::setUnknownValue (string val)
1443 _value = new SGValue();
1444 return _value->setUnknownValue(val);
1448 SGPropertyNode::isTied () const
1450 return (_value == 0 ? false : _value->isTied());
1454 SGPropertyNode::tie (const SGRawValue<bool> &rawValue, bool useDefault)
1457 _value = new SGValue();
1458 return _value->tie(rawValue, useDefault);
1462 SGPropertyNode::tie (const SGRawValue<int> &rawValue, bool useDefault)
1465 _value = new SGValue();
1466 return _value->tie(rawValue, useDefault);
1470 SGPropertyNode::tie (const SGRawValue<long> &rawValue, bool useDefault)
1473 _value = new SGValue();
1474 return _value->tie(rawValue, useDefault);
1478 SGPropertyNode::tie (const SGRawValue<float> &rawValue, bool useDefault)
1481 _value = new SGValue();
1482 return _value->tie(rawValue, useDefault);
1486 SGPropertyNode::tie (const SGRawValue<double> &rawValue, bool useDefault)
1489 _value = new SGValue();
1490 return _value->tie(rawValue, useDefault);
1494 SGPropertyNode::tie (const SGRawValue<string> &rawValue, bool useDefault)
1497 _value = new SGValue();
1498 return _value->tie(rawValue, useDefault);
1502 SGPropertyNode::untie ()
1504 return (_value == 0 ? false : _value->untie());
1508 SGPropertyNode::getRootNode ()
1513 return _parent->getRootNode();
1516 const SGPropertyNode *
1517 SGPropertyNode::getRootNode () const
1522 return _parent->getRootNode();
1526 SGPropertyNode::getNode (const string &relative_path, bool create)
1528 vector<PathComponent> components;
1529 parse_path(relative_path, components);
1530 return find_node(this, components, 0, create);
1533 const SGPropertyNode *
1534 SGPropertyNode::getNode (const string &relative_path) const
1536 vector<PathComponent> components;
1537 parse_path(relative_path, components);
1538 // FIXME: cast away const
1539 return find_node((SGPropertyNode *)this, components, 0, false);
1544 ////////////////////////////////////////////////////////////////////////
1545 // Convenience methods using relative paths.
1546 ////////////////////////////////////////////////////////////////////////
1550 * Test whether another node has a value attached.
1553 SGPropertyNode::hasValue (const string &relative_path) const
1555 const SGPropertyNode * node = getNode(relative_path);
1556 return (node == 0 ? false : node->hasValue());
1561 * Get the value for another node.
1564 SGPropertyNode::getValue (const string &relative_path, bool create)
1566 SGPropertyNode * node = getNode(relative_path, create);
1567 if (node != 0 && !node->hasValue())
1568 node->setUnknownValue("");
1569 return (node == 0 ? 0 : node->getValue(create));
1574 * Get the value for another node.
1577 SGPropertyNode::getValue (const string &relative_path) const
1579 const SGPropertyNode * node = getNode(relative_path);
1580 return (node == 0 ? 0 : node->getValue());
1585 * Get the value type for another node.
1588 SGPropertyNode::getType (const string &relative_path) const
1590 const SGPropertyNode * node = getNode(relative_path);
1591 return (node == 0 ? SGValue::UNKNOWN : node->getType());
1596 * Get a bool value for another node.
1599 SGPropertyNode::getBoolValue (const string &relative_path,
1600 bool defaultValue) const
1602 const SGPropertyNode * node = getNode(relative_path);
1603 return (node == 0 ? defaultValue : node->getBoolValue());
1608 * Get an int value for another node.
1611 SGPropertyNode::getIntValue (const string &relative_path,
1612 int defaultValue) const
1614 const SGPropertyNode * node = getNode(relative_path);
1615 return (node == 0 ? defaultValue : node->getIntValue());
1620 * Get a long value for another node.
1623 SGPropertyNode::getLongValue (const string &relative_path,
1624 long defaultValue) const
1626 const SGPropertyNode * node = getNode(relative_path);
1627 return (node == 0 ? defaultValue : node->getLongValue());
1632 * Get a float value for another node.
1635 SGPropertyNode::getFloatValue (const string &relative_path,
1636 float defaultValue) const
1638 const SGPropertyNode * node = getNode(relative_path);
1639 return (node == 0 ? defaultValue : node->getFloatValue());
1644 * Get a double value for another node.
1647 SGPropertyNode::getDoubleValue (const string &relative_path,
1648 double defaultValue) const
1650 const SGPropertyNode * node = getNode(relative_path);
1651 return (node == 0 ? defaultValue : node->getDoubleValue());
1656 * Get a string value for another node.
1659 SGPropertyNode::getStringValue (const string &relative_path,
1660 string defaultValue) const
1662 const SGPropertyNode * node = getNode(relative_path);
1663 return (node == 0 ? defaultValue : node->getStringValue());
1668 * Set a bool value for another node.
1671 SGPropertyNode::setBoolValue (const string &relative_path, bool value)
1673 return getNode(relative_path, true)->setBoolValue(value);
1678 * Set an int value for another node.
1681 SGPropertyNode::setIntValue (const string &relative_path, int value)
1683 return getNode(relative_path, true)->setIntValue(value);
1688 * Set a long value for another node.
1691 SGPropertyNode::setLongValue (const string &relative_path, long value)
1693 return getNode(relative_path, true)->setLongValue(value);
1698 * Set a float value for another node.
1701 SGPropertyNode::setFloatValue (const string &relative_path, float value)
1703 return getNode(relative_path, true)->setFloatValue(value);
1708 * Set a double value for another node.
1711 SGPropertyNode::setDoubleValue (const string &relative_path, double value)
1713 return getNode(relative_path, true)->setDoubleValue(value);
1718 * Set a string value for another node.
1721 SGPropertyNode::setStringValue (const string &relative_path, string value)
1723 return getNode(relative_path, true)->setStringValue(value);
1728 * Set an unknown value for another node.
1731 SGPropertyNode::setUnknownValue (const string &relative_path, string value)
1733 return getNode(relative_path, true)->setUnknownValue(value);
1738 * Test whether another node is tied.
1741 SGPropertyNode::isTied (const string &relative_path) const
1743 const SGPropertyNode * node = getNode(relative_path);
1744 return (node == 0 ? false : node->isTied());
1749 * Tie a node reached by a relative path, creating it if necessary.
1752 SGPropertyNode::tie (const string &relative_path,
1753 const SGRawValue<bool> &rawValue,
1756 return getNode(relative_path, true)->tie(rawValue, useDefault);
1761 * Tie a node reached by a relative path, creating it if necessary.
1764 SGPropertyNode::tie (const string &relative_path,
1765 const SGRawValue<int> &rawValue,
1768 return getNode(relative_path, true)->tie(rawValue, useDefault);
1773 * Tie a node reached by a relative path, creating it if necessary.
1776 SGPropertyNode::tie (const string &relative_path,
1777 const SGRawValue<long> &rawValue,
1780 return getNode(relative_path, true)->tie(rawValue, useDefault);
1785 * Tie a node reached by a relative path, creating it if necessary.
1788 SGPropertyNode::tie (const string &relative_path,
1789 const SGRawValue<float> &rawValue,
1792 return getNode(relative_path, true)->tie(rawValue, useDefault);
1797 * Tie a node reached by a relative path, creating it if necessary.
1800 SGPropertyNode::tie (const string &relative_path,
1801 const SGRawValue<double> &rawValue,
1804 return getNode(relative_path, true)->tie(rawValue, useDefault);
1809 * Tie a node reached by a relative path, creating it if necessary.
1812 SGPropertyNode::tie (const string &relative_path,
1813 const SGRawValue<string> &rawValue,
1816 return getNode(relative_path, true)->tie(rawValue, useDefault);
1821 * Attempt to untie another node reached by a relative path.
1824 SGPropertyNode::untie (const string &relative_path)
1826 SGPropertyNode * node = getNode(relative_path);
1827 return (node == 0 ? false : node->untie());