Hi folks,
what do you think about this idea:
New method: isEmpty() - Checks if a string is empty.
This could simplify logics in the source. Now this test is done
like 'if (aStr.getLength() != 0) {...}' or 'if (!aStr.getLength()) {...}'.
With isEmpty() this looks like:
if (aStr.isEmpty()) {...}
if (!aStr.isEmpty()) {...}
I think this would make the code more readable.
-Thomas
From fdf1e69730457763778f5735bb5709f5fc227327 Mon Sep 17 00:00:00 2001
From: Thomas Arnhold <thomas@arnhold.org>
Date: Fri, 21 Jan 2011 13:43:52 +0100
Subject: [PATCH] New method: isEmpty() - Checks if a string is empty.
This could simplify logics in the source. Now this test is done
like 'if (aStr.getLength() != 0) {...}' or 'if (!aStr.getLength()) {...}'.
With isEmpty() this looks like:
if (aStr.isEmpty()) {...}
if (!aStr.isEmpty()) {...}
I think this would make the code more readable.
---
sal/inc/rtl/ustring.hxx | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index a481be7..5fdbcc6 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -278,6 +278,20 @@ public:
sal_Int32 getLength() const SAL_THROW(()) { return pData->length; }
/**
+ Checks if a string is empty.
+
+ @return sal_True if the string is empty;
+ sal_False, otherwise.
+ */
+ sal_Bool isEmpty() const SAL_THROW(())
+ {
+ if ( pData->length )
+ return sal_False;
+ else
+ return sal_True;
+ }
+
+ /**
Returns a pointer to the Unicode character buffer from this string.
It isn't necessarily NULL terminated.
--
1.7.3.5
Context
- [Libreoffice] [PATCH] ure/sal/inc/rtl/ustring.hxx - new method isEmpty() · Thomas Arnhold
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.