summaryrefslogtreecommitdiff
path: root/sw/inc
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-08-15 18:46:53 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-08-17 07:44:03 +0200
commit133b9db4d68ba48eeb3682f4decba5689f6c0c1b (patch)
treef72e08d20d0256a7a5734b230d788a2b7b0c314b /sw/inc
parent16f01f82a765fc51a19be2e370a69eb7819c9ce4 (diff)
add comparison operators for SwNode
which will make it easier when I do more conversion of code doing stuff like rPos.nNode == to rPos.GetNode() == Add an assert to make sure we are talking about nodes from the same parent node array. Change-Id: I12011768d67e7fbe5a87663c661a5cc444f1deb4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138320 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/inc')
-rw-r--r--sw/inc/node.hxx7
1 files changed, 7 insertions, 0 deletions
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index 91b18e30ed66..62f6da8ef308 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -308,6 +308,13 @@ public:
*/
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
+ bool operator==(const SwNode& rOther) const { assert(&GetNodes() == &rOther.GetNodes()); return this == &rOther; }
+ bool operator!=(const SwNode& rOther) const { assert(&GetNodes() == &rOther.GetNodes()); return this != &rOther; }
+ bool operator<(const SwNode& rOther) const { assert(&GetNodes() == &rOther.GetNodes()); return GetIndex() < rOther.GetIndex(); }
+ bool operator<=(const SwNode& rOther) const { assert(&GetNodes() == &rOther.GetNodes()); return GetIndex() <= rOther.GetIndex(); }
+ bool operator>(const SwNode& rOther) const { assert(&GetNodes() == &rOther.GetNodes()); return GetIndex() > rOther.GetIndex(); }
+ bool operator>=(const SwNode& rOther) const { assert(&GetNodes() == &rOther.GetNodes()); return GetIndex() >= rOther.GetIndex(); }
+
private:
SwNode( const SwNode & rNodes ) = delete;
SwNode & operator= ( const SwNode & rNodes ) = delete;