Fixed DefinitionNode::findChildByName

This commit is contained in:
Michaël Lemaire 2015-12-16 00:38:28 +01:00
parent 62a7f746ea
commit 990d28d09d
2 changed files with 3 additions and 4 deletions

View file

@ -91,8 +91,7 @@ DefinitionNode *DefinitionNode::findByPath(const string &path) const {
} else {
size_t seppos = path.find("/");
string child_name = (seppos == string::npos) ? path : path.substr(0, seppos);
DefinitionNode *child =
((DefinitionNode *)this)->findChildByName(child_name); // FIXME findChildByName should be const
DefinitionNode *child = findChildByName(child_name);
if (child) {
if (seppos == string::npos) {
return child;
@ -231,7 +230,7 @@ void DefinitionNode::removeChild(DefinitionNode *child) {
}
}
DefinitionNode *DefinitionNode::findChildByName(const string name) {
DefinitionNode *DefinitionNode::findChildByName(const string &name) const {
for (auto child : children) {
if (child->name == name) {
return child;

View file

@ -98,7 +98,7 @@ class DEFINITIONSHARED_EXPORT DefinitionNode {
protected:
void addChild(DefinitionNode *child);
void removeChild(DefinitionNode *child);
virtual DefinitionNode *findChildByName(const string name);
virtual DefinitionNode *findChildByName(const string &name) const;
/**
* Get the size in bytes this child will consume when serialized to a stream.