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