summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2012-11-28 04:01:17 -0600
committerStephan Bergmann <sbergman@redhat.com>2012-11-28 15:02:07 +0100
commit20481510003524af3e4b50c073a4f9bae87acb1f (patch)
treef8742acdfc9213527bfaad29a439927bb1606715 /sal
parent04c79bcbbc3e646d7c9ae4f9388eb0134ec9a8b8 (diff)
add SAL_WARN_UNUSED_RESULT in OString and OUString where appropriate
String used to do some operation by modifying itself whereas OUString never does that and when a modificaiton is needed it create a new copy. so it is very easy when one convert String code to OUString code to miss stuff like sString.ToUpperCase() which need to be converted into sString = sString.toAsciiUpperCase() and not sString.toAsciiUpperCase() This patch make the compiler generate a warning in that later _wrong_ case Change-Id: I4a9c0b4c7d0b75ad8850ac23b86e8508a334f5fe Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r--sal/inc/rtl/string.hxx16
-rw-r--r--sal/inc/rtl/ustring.hxx20
2 files changed, 18 insertions, 18 deletions
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx
index 51d21cb949ab..4e550209d22b 100644
--- a/sal/inc/rtl/string.hxx
+++ b/sal/inc/rtl/string.hxx
@@ -1056,7 +1056,7 @@ public:
@return a string that represents the concatenation of this string
followed by the string argument.
*/
- OString concat( const OString & str ) const SAL_THROW(())
+ SAL_WARN_UNUSED_RESULT OString concat( const OString & str ) const SAL_THROW(())
{
rtl_String* pNew = 0;
rtl_string_newConcat( &pNew, pData, str.pData );
@@ -1081,7 +1081,7 @@ public:
@param newStr the new substring.
@return the new string.
*/
- OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const SAL_THROW(())
+ SAL_WARN_UNUSED_RESULT OString replaceAt( sal_Int32 index, sal_Int32 count, const OString& newStr ) const SAL_THROW(())
{
rtl_String* pNew = 0;
rtl_string_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
@@ -1101,7 +1101,7 @@ public:
@return a string derived from this string by replacing every
occurrence of oldChar with newChar.
*/
- OString replace( sal_Char oldChar, sal_Char newChar ) const SAL_THROW(())
+ SAL_WARN_UNUSED_RESULT OString replace( sal_Char oldChar, sal_Char newChar ) const SAL_THROW(())
{
rtl_String* pNew = 0;
rtl_string_newReplace( &pNew, pData, oldChar, newChar );
@@ -1126,7 +1126,7 @@ public:
@since LibreOffice 3.6
*/
- OString replaceFirst(
+ SAL_WARN_UNUSED_RESULT OString replaceFirst(
OString const & from, OString const & to, sal_Int32 * index = 0) const
{
rtl_String * s = 0;
@@ -1150,7 +1150,7 @@ public:
@since LibreOffice 3.6
*/
- OString replaceAll(OString const & from, OString const & to) const {
+ SAL_WARN_UNUSED_RESULT OString replaceAll(OString const & from, OString const & to) const {
rtl_String * s = 0;
rtl_string_newReplaceAll(
&s, pData, from.pData->buffer, from.pData->length,
@@ -1168,7 +1168,7 @@ public:
@return the string, converted to ASCII lowercase.
*/
- OString toAsciiLowerCase() const SAL_THROW(())
+ SAL_WARN_UNUSED_RESULT OString toAsciiLowerCase() const SAL_THROW(())
{
rtl_String* pNew = 0;
rtl_string_newToAsciiLowerCase( &pNew, pData );
@@ -1185,7 +1185,7 @@ public:
@return the string, converted to ASCII uppercase.
*/
- OString toAsciiUpperCase() const SAL_THROW(())
+ SAL_WARN_UNUSED_RESULT OString toAsciiUpperCase() const SAL_THROW(())
{
rtl_String* pNew = 0;
rtl_string_newToAsciiUpperCase( &pNew, pData );
@@ -1203,7 +1203,7 @@ public:
@return the string, with white space removed from the front and end.
*/
- OString trim() const SAL_THROW(())
+ SAL_WARN_UNUSED_RESULT OString trim() const SAL_THROW(())
{
rtl_String* pNew = 0;
rtl_string_newTrim( &pNew, pData );
diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx
index 4fc1360027f9..ebf548b01636 100644
--- a/sal/inc/rtl/ustring.hxx
+++ b/sal/inc/rtl/ustring.hxx
@@ -1394,7 +1394,7 @@ public:
@return a string that represents the concatenation of this string
followed by the string argument.
*/
- OUString concat( const OUString & str ) const SAL_THROW(())
+ SAL_WARN_UNUSED_RESULT OUString concat( const OUString & str ) const SAL_THROW(())
{
rtl_uString* pNew = 0;
rtl_uString_newConcat( &pNew, pData, str.pData );
@@ -1419,7 +1419,7 @@ public:
@param newStr the new substring.
@return the new string.
*/
- OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const SAL_THROW(())
+ SAL_WARN_UNUSED_RESULT OUString replaceAt( sal_Int32 index, sal_Int32 count, const OUString& newStr ) const SAL_THROW(())
{
rtl_uString* pNew = 0;
rtl_uString_newReplaceStrAt( &pNew, pData, index, count, newStr.pData );
@@ -1439,7 +1439,7 @@ public:
@return a string derived from this string by replacing every
occurrence of oldChar with newChar.
*/
- OUString replace( sal_Unicode oldChar, sal_Unicode newChar ) const SAL_THROW(())
+ SAL_WARN_UNUSED_RESULT OUString replace( sal_Unicode oldChar, sal_Unicode newChar ) const SAL_THROW(())
{
rtl_uString* pNew = 0;
rtl_uString_newReplace( &pNew, pData, oldChar, newChar );
@@ -1464,7 +1464,7 @@ public:
@since LibreOffice 3.6
*/
- OUString replaceFirst(
+ SAL_WARN_UNUSED_RESULT OUString replaceFirst(
OUString const & from, OUString const & to, sal_Int32 * index = 0) const
{
rtl_uString * s = 0;
@@ -1493,8 +1493,8 @@ public:
@since LibreOffice 3.6
*/
template< typename T >
- typename internal::ConstCharArrayDetector< T, OUString >::Type replaceFirst( T& from, OUString const & to,
- sal_Int32 * index = 0) const
+ SAL_WARN_UNUSED_RESULT typename internal::ConstCharArrayDetector< T, OUString >::Type replaceFirst( T& from, OUString const & to,
+ sal_Int32 * index = 0) const
{
rtl_uString * s = 0;
sal_Int32 i = 0;
@@ -1522,7 +1522,7 @@ public:
@since LibreOffice 3.6
*/
template< typename T1, typename T2 >
- typename internal::ConstCharArrayDetector< T1, typename internal::ConstCharArrayDetector< T2, OUString >::Type >::Type
+ SAL_WARN_UNUSED_RESULT typename internal::ConstCharArrayDetector< T1, typename internal::ConstCharArrayDetector< T2, OUString >::Type >::Type
replaceFirst( T1& from, T2& to, sal_Int32 * index = 0) const
{
rtl_uString * s = 0;
@@ -1609,7 +1609,7 @@ public:
@return the string, converted to ASCII lowercase.
*/
- OUString toAsciiLowerCase() const SAL_THROW(())
+ SAL_WARN_UNUSED_RESULT OUString toAsciiLowerCase() const SAL_THROW(())
{
rtl_uString* pNew = 0;
rtl_uString_newToAsciiLowerCase( &pNew, pData );
@@ -1626,7 +1626,7 @@ public:
@return the string, converted to ASCII uppercase.
*/
- OUString toAsciiUpperCase() const SAL_THROW(())
+ SAL_WARN_UNUSED_RESULT OUString toAsciiUpperCase() const SAL_THROW(())
{
rtl_uString* pNew = 0;
rtl_uString_newToAsciiUpperCase( &pNew, pData );
@@ -1644,7 +1644,7 @@ public:
@return the string, with white space removed from the front and end.
*/
- OUString trim() const SAL_THROW(())
+ SAL_WARN_UNUSED_RESULT OUString trim() const SAL_THROW(())
{
rtl_uString* pNew = 0;
rtl_uString_newTrim( &pNew, pData );