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 <tho...@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
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice