diff options
author | David Ostrovsky <david@ostrovsky.org> | 2013-02-04 11:40:14 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-02-04 14:35:26 +0100 |
commit | 751950edc84e0069e5bce1083160d46d9ba1bf33 (patch) | |
tree | 1526682400b50bd756d446ee9c0cfc237f03de43 | |
parent | 55576105d3c9b0a116d7707a6c46b67f7b20a0ce (diff) |
Strings: boolean() as a replacement for valueOf(sal_Bool)
valueOf(?) has been superseded by number(?).
O(U)String::valueOf(sal_Bool) has been deprecated without providing an
alternative method. Use boolean() method as a replacement for it.
Change-Id: I7eb74574fa8f1a3cf007cb0cbc32e681007ffb92
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r-- | sal/inc/rtl/string.hxx | 20 | ||||
-rw-r--r-- | sal/inc/rtl/ustring.hxx | 20 | ||||
-rw-r--r-- | sal/qa/rtl_strings/rtl_OString.cxx | 8 | ||||
-rw-r--r-- | sal/qa/rtl_strings/rtl_OUString.cxx | 8 |
4 files changed, 44 insertions, 12 deletions
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 69592f93e12d..9ed01e5824cb 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -1487,15 +1487,31 @@ public: If the sal_Bool is true, the string "true" is returned. If the sal_Bool is false, the string "false" is returned. This function can't be used for language specific conversion. @param b a sal_Bool. @return a string with the string representation of the argument. - @deprecated there is no replacement, use 'condition ? OString( "true" ) : OString( "false" )' + @deprecated use boolean() */ - SAL_DEPRECATED_INTERNAL("write explicit code") static OString valueOf( sal_Bool b ) SAL_THROW(()) + SAL_DEPRECATED_INTERNAL("use boolean()") static OString valueOf( sal_Bool b ) SAL_THROW(()) + { + return boolean(b); + } + + /** + Returns the string representation of the boolean argument. + + If the sal_Bool is true, the string "true" is returned. + If the sal_Bool is false, the string "false" is returned. + This function can't be used for language specific conversion. + + @param b a sal_Bool. + @return a string with the string representation of the argument. + @since LibreOffice 4.1 + */ + static OString boolean( sal_Bool b ) SAL_THROW(()) { sal_Char aBuf[RTL_STR_MAX_VALUEOFBOOLEAN]; rtl_String* pNewData = 0; rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfBoolean( aBuf, b ) ); return OString( pNewData, (DO_NOT_ACQUIRE*)0 ); } diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index 8190d208ae68..7cdbb4e22d90 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -2138,15 +2138,31 @@ public: If the sal_Bool is true, the string "true" is returned. If the sal_Bool is false, the string "false" is returned. This function can't be used for language specific conversion. @param b a sal_Bool. @return a string with the string representation of the argument. - @deprecated there is no replacement, use 'condition ? OString( "true" ) : OString( "false" )' + @deprecated use boolean() */ - SAL_DEPRECATED_INTERNAL("write explicit condition") static OUString valueOf( sal_Bool b ) SAL_THROW(()) + SAL_DEPRECATED_INTERNAL("use boolean()") static OUString valueOf( sal_Bool b ) SAL_THROW(()) + { + return boolean(b); + } + + /** + Returns the string representation of the boolean argument. + + If the sal_Bool is true, the string "true" is returned. + If the sal_Bool is false, the string "false" is returned. + This function can't be used for language specific conversion. + + @param b a sal_Bool. + @return a string with the string representation of the argument. + @since LibreOffice 4.1 + */ + static OUString boolean( sal_Bool b ) SAL_THROW(()) { sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFBOOLEAN]; rtl_uString* pNewData = 0; rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfBoolean( aBuf, b ) ); return OUString( pNewData, (DO_NOT_ACQUIRE*)0 ); } diff --git a/sal/qa/rtl_strings/rtl_OString.cxx b/sal/qa/rtl_strings/rtl_OString.cxx index cea3cb1ba411..1934f0625248 100644 --- a/sal/qa/rtl_strings/rtl_OString.cxx +++ b/sal/qa/rtl_strings/rtl_OString.cxx @@ -1782,15 +1782,15 @@ extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_trim( // return ( res ); } //------------------------------------------------------------------------ -// testing the method valueOf( sal_Bool b ) +// testing the method boolean( sal_Bool b ) //------------------------------------------------------------------------ -sal_Bool SAL_CALL test_rtl_OString_valueOf_sal_Bool( +sal_Bool SAL_CALL test_rtl_OString_boolean( hTestResult hRtlTestResult ) { sal_Char methName[MAXBUFLENGTH]; sal_Char* pMeth =methName; typedef struct TestCase @@ -1810,13 +1810,13 @@ sal_Bool SAL_CALL test_rtl_OString_valueOf_sal_Bool( sal_Bool res = sal_True; sal_uInt32 i; for(i = 0; i < (sizeof (arrTestCase))/(sizeof (TestCase)); i++) { ::rtl::OString aStr1; - aStr1 = aStr1.valueOf( arrTestCase[i].input1 ); + aStr1 = aStr1.boolean( arrTestCase[i].input1 ); sal_Bool lastRes = (arrTestCase[i].expVal->compareTo(aStr1) == 0); c_rtl_tres_state ( hRtlTestResult, lastRes, @@ -2443,13 +2443,13 @@ sal_Bool SAL_CALL test_rtl_OString_valueOf_Int64_SmallestNegativeValue( // testing the method valueOf() //------------------------------------------------------------------------ extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OString_valueOf( hTestResult hRtlTestResult ) { c_rtl_tres_state_start(hRtlTestResult, "valueOf"); - sal_Bool bTState = test_rtl_OString_valueOf_sal_Bool( hRtlTestResult ); + sal_Bool bTState = test_rtl_OString_boolean( hRtlTestResult ); bTState &= test_rtl_OString_valueOf_sal_Char( hRtlTestResult ); bTState &= test_rtl_OString_valueOf_Int32( hRtlTestResult ); bTState &= test_rtl_OString_valueOf_Int32_Bounderies( hRtlTestResult ); bTState &= test_rtl_OString_valueOf_Int32_Negative( hRtlTestResult ); diff --git a/sal/qa/rtl_strings/rtl_OUString.cxx b/sal/qa/rtl_strings/rtl_OUString.cxx index 4982f2973d07..3ba20e7020e6 100644 --- a/sal/qa/rtl_strings/rtl_OUString.cxx +++ b/sal/qa/rtl_strings/rtl_OUString.cxx @@ -1259,15 +1259,15 @@ extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_compareToAscii( c_rtl_tres_state_end( hRtlTestResult, "compareToAscii"); // return ( res ); } //------------------------------------------------------------------------ -// testing the method valueOf( sal_Bool b ) +// testing the method boolean( sal_Bool b ) //------------------------------------------------------------------------ -extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_valueOf_sal_Bool( +extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_boolean( hTestResult hRtlTestResult ) { c_rtl_tres_state_start( hRtlTestResult, "Bool"); sal_Char methName[MAXBUFLENGTH]; sal_Char* pMeth = methName; @@ -1297,13 +1297,13 @@ extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString_valueOf_sal_Bool( sal_Bool res; sal_uInt32 i; for(i=0;i<(sizeof(arrTestCase))/(sizeof(TestCase));i++) { sal_Bool lastRes=(*arrTestCase[i].expVal== - OUString::valueOf(arrTestCase[i].input1) + OUString::boolean(arrTestCase[i].input1) ); c_rtl_tres_state(hRtlTestResult, lastRes, arrTestCase[i].comments, @@ -3344,13 +3344,13 @@ extern "C" void /* sal_Bool */ SAL_CALL test_rtl_OUString( hTestResult hRtlTestR test_rtl_OUString_csuc( hRtlTestResult ); test_rtl_OUString_getStr( hRtlTestResult ); test_rtl_OUString_reverseCompareTo( hRtlTestResult ); test_rtl_OUString_equalsAscii( hRtlTestResult ); test_rtl_OUString_equalsAsciiL( hRtlTestResult ); test_rtl_OUString_compareToAscii( hRtlTestResult ); - test_rtl_OUString_valueOf_sal_Bool( hRtlTestResult ); + test_rtl_OUString_boolean( hRtlTestResult ); test_rtl_OUString_valueOf_sal_Unicode( hRtlTestResult ); test_rtl_OUString_valueOf( hRtlTestResult ); test_rtl_OUString_createFromAscii( hRtlTestResult ); test_rtl_OUString_indexOf( hRtlTestResult ); test_rtl_OUString_concat( hRtlTestResult ); test_rtl_OUString_replaceAt( hRtlTestResult ); |