summaryrefslogtreecommitdiff
path: root/sal/inc
diff options
context:
space:
mode:
authorThomas Arnhold <thomas@arnhold.org>2011-01-21 13:43:52 +0100
committerMichael Meeks <michael.meeks@novell.com>2011-01-24 09:23:20 +0000
commit21d81532add2e8960ff6b4da506d000036f12a46 (patch)
tree20ae322a6a0c8ade9efb26fac49fb5c509c9df7a /sal/inc
parenta9509d4a5f838aff62b3888ec6c8ec9678ea70fe (diff)
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.
Diffstat (limited to 'sal/inc')
-rw-r--r--sal/inc/rtl/ustring.hxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index faf63c46222e..3ffc2c25a4c7 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.