Replies: 3 comments 1 reply
-
Another related question is how do I move the children of a Otherwise I will probably use Looking at the description of |
Beta Was this translation helpful? Give feedback.
-
It seems that a better name for And likewise |
Beta Was this translation helpful? Give feedback.
-
Yes that is OK and good to know. In that case Perhaps have So also How does |
Beta Was this translation helpful? Give feedback.
-
I notice (via segmentation faults), that
Object::InsertChild()
does not attach the inserted child to the parent automatically (viaObject::SetParent()
). It would be preferable if it did set the parent at the same time; otherwise, it would be more proper to haveInsertChild
be a protected class member rather than public. (I cannot think of a case where you would want to insert a child and not have it attached to that object as its parent).Related to this, I want to insert a child in the first position of an object. I don't see a one-liner way of doing that. I currently have to get the first child with
GetChild(0)
and then useObject::InsertBefore()
. But also a check to see that GetChild does not return NULL.Object::GetFirst()
would work in a similar manner, but also is a three-step process to insert a child to the front of the list.I am thinking that it would be good to add
Object::AddChildFirst()
orObject::AddChildFront()
to allow inserting a new child before any other children (and if there are no children, it would also work to insert into the empty list. In other words, this would complimentObject::AddChild
by inserting on the opposite side of the list (sinceAddChild
adds to the end of the list).For identifying if an object has a specific attribute with
Object::HasAttribute()
, that function seems to test if the object has the attribute and if it is set to specific content. How does that work withu32string
data since the input attribute value isstring
(and I am presuming many or all attributes are stored as u32string)? And more importantly, how do I ask an object if it has an attribute with a specific name (if it exists but I do not care what the value is)? Or do all attributes technically always exist in objects (and what about invalid ones)?Would that be equivalent to checking for an empty string value? It seems like adding
Object::HasAttribute(std::string name)
with only one parameter for the attribute name and not the value would be useful to clarify the case where you only want to know if the attribute exists and do not care what its value is.Is
Object::SetParent(NULL)
equivalent toObject::DetachChild(index)
? (other than which object is being called). In other words, doesSetParent
inform the parent that it is moving out? Looking at the code, forSetParent
it seems that it will not be informed that the child is leaving. If the current parent is not NULL, is it not better to tell it to detach the child whenSetParent
is called? It seems dangerous to allow a new parent to be set without it being detached from the existing parent.Beta Was this translation helpful? Give feedback.
All reactions