Skip to content

Commit

Permalink
Add Element compare operators
Browse files Browse the repository at this point in the history
  • Loading branch information
sammycage committed Sep 15, 2024
1 parent eee9424 commit 41cff44
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions include/lunasvg.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,22 +505,36 @@ class LUNASVG_API Element {
*/
Box getBoundingBox() const;

/**
* @brief Returns the parent element.
* @return The parent element of this element. If this element has no parent, a null `Element` is returned.
*/
Element parent() const;

/**
* @brief Checks if the element is null.
* @return True if the element is null, false otherwise.
*/
bool isNull() const { return m_element == nullptr; }

/**
* @brief Returns the parent element.
* @return The parent element of this element. If this element has no parent, a null `Element` is returned.
* @brief Checks if two elements are equal.
* @param element The element to compare.
* @return True if equal, otherwise false.
*/
Element parent() const;
bool operator==(const Element& element) const { return m_element == element.get(); }

/**
* @brief Checks if two elements are not equal.
* @param element The element to compare.
* @return True if not equal, otherwise false.
*/
bool operator!=(const Element& element) const { return m_element != element.get(); }

/**
* @internal
*/
SVGElement* get() { return m_element; }
SVGElement* get() const { return m_element; }

private:
SVGElement* m_element{nullptr};
Expand Down

0 comments on commit 41cff44

Please sign in to comment.