1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 08:00:47 +00:00

LibXML: Add helpers for extracting node contents if its type is known

This commit is contained in:
Dan Klishch 2023-08-14 21:01:50 -04:00 committed by Ali Mohammad Pur
parent 3a42ef4118
commit b40ab55830

View File

@ -36,5 +36,14 @@ struct Node {
Variant<Text, Comment, Element> content;
Node* parent { nullptr };
bool is_text() const { return content.has<Text>(); }
Text const& as_text() const { return content.get<Text>(); }
bool is_comment() const { return content.has<Comment>(); }
Comment const& as_comment() const { return content.get<Comment>(); }
bool is_element() const { return content.has<Element>(); }
Element const& as_element() const { return content.get<Element>(); }
};
}