Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Hi,

as I understand this, it would be nice to have this method in OString,
too. I've attached the patch.

Thomas

On 01/21/2011 05:55 PM, Michael Meeks wrote:
Hi Thomas,

On Fri, 2011-01-21 at 13:52 +0100, Thomas Arnhold wrote:
New method: isEmpty() - Checks if a string is empty.

      I like it.

      There are lots of use-cases that we need to get into sal: that we sadly
don't have at the moment: to make writing code easier and less
error-prone.

With isEmpty() this looks like:
if (aStr.isEmpty()) {...}
if (!aStr.isEmpty()) {...}

      Prettier for sure.

      There are some methods that are all 'pure' and all that (like those for
tokenising rtl::OUStrings) that get used in fairly unreadable ways
around the place. In a world of iterators, it is unclear to me why we
need to be managing string offsets and odd loops using 'getToken()'

      Really, we need to be making OUStrings and StringBuffers easier to use,
so that we can use them everywhere - in place of the obsolete (mutable)
tools/inc/tools/string.hxx (UniString) - (mostly called 'String' outside
there).

      I suppose, simply porting a good number of String instances would help
us fall over the missing pieces there.

      Anyhow - nice patch, pushed to master; I added a:

      @since LibreOffice 3.4

      tag to the method call, since this low level piece is intended to be a
stable ABI that is managed in that way.

      Thanks !

              Michael.


From fee2cdb972482cb3682e83a72954d31c6ec6fcdc Mon Sep 17 00:00:00 2001
From: Thomas Arnhold <thomas@arnhold.org>
Date: Thu, 3 Feb 2011 22:40:17 +0100
Subject: [PATCH] OString: New method isEmpty()

---
 sal/inc/rtl/string.hxx |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index 86bc1a6..c1af815 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -223,6 +223,22 @@ 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.
+
+      @since LibreOffice 3.4
+    */
+    sal_Bool isEmpty() const SAL_THROW(())
+    {
+        if ( pData->length )
+            return sal_False;
+        else
+            return sal_True;
+    }
+
+    /**
       Returns a pointer to the characters of this string.
 
       <p>The returned pointer is not guaranteed to point to a null-terminated
-- 
1.7.3.5


Context


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.