change return value of SGPropertyNode::getPath to std::string

Also get rid of the cached value.
This commit is contained in:
Tim Moore
2010-03-09 11:02:56 +01:00
parent d04cf4d897
commit fc4009aa50
2 changed files with 14 additions and 10 deletions
+13 -8
View File
@@ -1027,17 +1027,22 @@ SGPropertyNode::getDisplayName (bool simplify) const
}
const char *
string
SGPropertyNode::getPath (bool simplify) const
{
// Calculate the complete path only once.
if (_parent != 0 && _path.empty()) {
_path = _parent->getPath(simplify);
_path += '/';
_path += getDisplayName(simplify);
typedef std::vector<SGConstPropertyNode_ptr> PList;
PList pathList;
for (const SGPropertyNode* node = this; node->_parent; node = node->_parent)
pathList.push_back(node);
string result;
for (PList::reverse_iterator itr = pathList.rbegin(),
rend = pathList.rend();
itr != rend;
++itr) {
result += '/';
result += (*itr)->getDisplayName(simplify);
}
return _path.c_str();
return result;
}
props::Type
+1 -2
View File
@@ -994,7 +994,7 @@ public:
/**
* Get the path to this node from the root.
*/
const char * getPath (bool simplify = false) const;
std::string getPath (bool simplify = false) const;
/**
@@ -1675,7 +1675,6 @@ private:
simgear::PropertyList _children;
simgear::PropertyList _removedChildren;
std::vector<hash_table *> _linkedNodes;
mutable std::string _path;
mutable std::string _buffer;
hash_table * _path_cache;
simgear::props::Type _type;