-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
These might need touched up to fit your style but just to say thanks for the library, here are a couple new Methods some might find useful, if you want to include them.
shared_ptr<HtmlElement> GetSiblingNext() {
shared_ptr<HtmlElement> el = shared_from_this();
if (el->GetParent()) {
auto& children = el->GetParent()->children;
auto it = std::find(children.begin(), children.end(), el);
if (it != children.end()) {
if (it + 1 != children.end()) {
auto nextSibling = *(it + 1);
return nextSibling;
}
}
}
return nullptr;
}
shared_ptr<HtmlElement> GetSiblingPrev() {
shared_ptr<HtmlElement> el = shared_from_this();
if (el->GetParent()) {
auto& children = el->GetParent()->children;
auto it = std::find(children.begin(), children.end(), el);
if (it != children.end()) {
if (it != children.begin()) {
auto prevSibling = *(it - 1);
return prevSibling;
}
}
}
return nullptr;
}
Metadata
Metadata
Assignees
Labels
No labels