Fixed DefinitionNode::findChildByName
This commit is contained in:
parent
62a7f746ea
commit
990d28d09d
2 changed files with 3 additions and 4 deletions
|
@ -91,8 +91,7 @@ DefinitionNode *DefinitionNode::findByPath(const string &path) const {
|
||||||
} else {
|
} else {
|
||||||
size_t seppos = path.find("/");
|
size_t seppos = path.find("/");
|
||||||
string child_name = (seppos == string::npos) ? path : path.substr(0, seppos);
|
string child_name = (seppos == string::npos) ? path : path.substr(0, seppos);
|
||||||
DefinitionNode *child =
|
DefinitionNode *child = findChildByName(child_name);
|
||||||
((DefinitionNode *)this)->findChildByName(child_name); // FIXME findChildByName should be const
|
|
||||||
if (child) {
|
if (child) {
|
||||||
if (seppos == string::npos) {
|
if (seppos == string::npos) {
|
||||||
return child;
|
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) {
|
for (auto child : children) {
|
||||||
if (child->name == name) {
|
if (child->name == name) {
|
||||||
return child;
|
return child;
|
||||||
|
|
|
@ -98,7 +98,7 @@ class DEFINITIONSHARED_EXPORT DefinitionNode {
|
||||||
protected:
|
protected:
|
||||||
void addChild(DefinitionNode *child);
|
void addChild(DefinitionNode *child);
|
||||||
void removeChild(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.
|
* Get the size in bytes this child will consume when serialized to a stream.
|
||||||
|
|
Loading…
Reference in a new issue