summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2013-01-21 21:42:46 +0100
committerLuboš Luňák <l.lunak@suse.cz>2013-01-22 11:26:39 +0000
commitfea25896a87aa5826eb243069d34aae7d0333a4c (patch)
treea41c644ca2efcdc4814d53ee1bd7ae2b9c7b578f /tools
parentc605119a8a69a04e3dcc958d1ac2796d4bb04a9b (diff)
tools/string.hxx: add operator==/!= for OUString/String
This has the disadvantage that it makes comparisons involving fast OUString concatenation via operator+ ambiguous, as can be seen in scriptdlg.cxx, but it allows comparing String and OUString wihout explicit conversion, which is nice for incrementally converting code. Change-Id: Ibfc728bdb161a01e0f8311915c97bcbba8b58c0b Reviewed-on: https://gerrit.libreoffice.org/1803 Reviewed-by: Luboš Luňák <l.lunak@suse.cz> Tested-by: Luboš Luňák <l.lunak@suse.cz>
Diffstat (limited to 'tools')
-rw-r--r--tools/inc/tools/string.hxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/inc/tools/string.hxx b/tools/inc/tools/string.hxx
index 03276c178c1d..0adf08cdc1cf 100644
--- a/tools/inc/tools/string.hxx
+++ b/tools/inc/tools/string.hxx
@@ -333,6 +333,28 @@ struct ToStringHelper< UniString >
#endif
+// some compare operators, so that conversions from String to OUString don't
+// have to insert conversions all over the place
+inline bool operator==(UniString const& rLeft, ::rtl::OUString const& rRight)
+{
+ return ::rtl::OUString(rLeft) == rRight;
+}
+
+inline bool operator==(::rtl::OUString const& rLeft, UniString const& rRight)
+{
+ return rLeft == ::rtl::OUString(rRight);
+}
+
+inline bool operator!=(UniString const& rLeft, ::rtl::OUString const& rRight)
+{
+ return ::rtl::OUString(rLeft) != rRight;
+}
+
+inline bool operator!=(::rtl::OUString const& rLeft, UniString const& rRight)
+{
+ return rLeft != ::rtl::OUString(rRight);
+}
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */