summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2024-01-10 21:32:02 -0800
committerGreg Ercolano <erco@seriss.com>2024-01-10 21:32:02 -0800
commitdc70a04100fd491151d3478a05ecf8baecfa894c (patch)
tree3071ac4c03b4cd425163dbdcc5ec73ca15adb8f4 /src
parent32514e6d2b0dbcd0dff9f4da65ca6d6e9596feab (diff)
Add Fl_String not-equal test
Diffstat (limited to 'src')
-rw-r--r--src/Fl_String.H1
-rw-r--r--src/Fl_String.cxx13
2 files changed, 14 insertions, 0 deletions
diff --git a/src/Fl_String.H b/src/Fl_String.H
index d10d75b6c..e7fbf49eb 100644
--- a/src/Fl_String.H
+++ b/src/Fl_String.H
@@ -135,6 +135,7 @@ public:
FL_EXPORT Fl_String operator+(const Fl_String& lhs, const Fl_String& rhs);
FL_EXPORT Fl_String operator+(const Fl_String& lhs, const char* rhs);
FL_EXPORT bool operator==(const Fl_String & lhs, const Fl_String & rhs);
+FL_EXPORT bool operator!=(const Fl_String & lhs, const Fl_String & rhs);
/**
\}
diff --git a/src/Fl_String.cxx b/src/Fl_String.cxx
index 8fd8e5f51..60d50ef99 100644
--- a/src/Fl_String.cxx
+++ b/src/Fl_String.cxx
@@ -646,6 +646,19 @@ bool operator==(const Fl_String &lhs, const Fl_String &rhs) {
}
/**
+ Compare two strings for inequality.
+ \param[in] lhs first string
+ \param[in] rhs second string
+ \return true if strings differ in size or content
+ */
+bool operator!=(const Fl_String &lhs, const Fl_String &rhs) {
+ if (lhs.size() != rhs.size()) return true;
+ int sz = lhs.size(); // same size for both
+ if (memcmp(lhs.data(), rhs.data(), sz) != 0) return true;
+ return false;
+}
+
+/**
\}
\endcond
*/