diff options
Diffstat (limited to 'sal/inc/rtl')
-rw-r--r-- | sal/inc/rtl/string.hxx | 138 | ||||
-rw-r--r-- | sal/inc/rtl/ustring.hxx | 138 |
2 files changed, 264 insertions, 12 deletions
diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index 8e33973729d7..325fe28af239 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -1399,8 +1399,9 @@ public: @param b a sal_Bool. @return a string with the string representation of the argument. + @deprecated there is no replacement, just code your own */ - static OString valueOf( sal_Bool b ) SAL_THROW(()) + SAL_DEPRECATED_INTERNAL("just code your own") static OString valueOf( sal_Bool b ) SAL_THROW(()) { sal_Char aBuf[RTL_STR_MAX_VALUEOFBOOLEAN]; rtl_String* pNewData = 0; @@ -1413,8 +1414,9 @@ public: @param c a character. @return a string with the string representation of the argument. + @deprecated just use the "+" or "+=" operator */ - static OString valueOf( sal_Char c ) SAL_THROW(()) + SAL_DEPRECATED_INTERNAL("use the + or += operator") static OString valueOf( sal_Char c ) SAL_THROW(()) { return OString( &c, 1 ); } @@ -1427,8 +1429,9 @@ public: @param i a int32. @param radix the radix (between 2 and 36) @return a string with the string representation of the argument. + @deprecated use number(sal_Int64,sal_Int16) */ - static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 ) SAL_THROW(()) + SAL_DEPRECATED_INTERNAL("use number") static OString valueOf( sal_Int32 i, sal_Int16 radix = 10 ) SAL_THROW(()) { sal_Char aBuf[RTL_STR_MAX_VALUEOFINT32]; rtl_String* pNewData = 0; @@ -1437,15 +1440,67 @@ public: } /** + Returns the string representation of the int argument. + + This function can't be used for language specific conversion. + + @param i a int32. + @param radix the radix (between 2 and 36) + @return a string with the string representation of the argument. + */ + static OString number( int i, sal_Int16 radix = 10 ) + { + sal_Char aBuf[RTL_STR_MAX_VALUEOFINT32]; + rtl_String* pNewData = 0; + rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt32( aBuf, i, radix ) ); + return OString( pNewData, (DO_NOT_ACQUIRE*)0 ); + } + + /** + Returns the string representation of the int argument. + + This function can't be used for language specific conversion. + + @param i a int32. + @param radix the radix (between 2 and 36) + @return a string with the string representation of the argument. + */ + static OString number( unsigned int i, sal_Int16 radix = 10 ) + { + sal_Char aBuf[RTL_STR_MAX_VALUEOFINT64]; + rtl_String* pNewData = 0; + rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt64( aBuf, i, radix ) ); + return OString( pNewData, (DO_NOT_ACQUIRE*)0 ); + } + + /** + Returns the string representation of the long argument. + + This function can't be used for language specific conversion. + + @param ll a int64. + @param radix the radix (between 2 and 36) + @return a string with the string representation of the argument. + @deprecated use number(sal_Int64,sal_Int16) + */ + SAL_DEPRECATED_INTERNAL("use number") static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 ) SAL_THROW(()) + { + return number( ll, radix ); + } + + /** Returns the string representation of the long argument. + This is here because when choosing which conversion for overloaded + functions is better, the standard treats all integer conversions the same. This function can't be used for language specific conversion. @param ll a int64. @param radix the radix (between 2 and 36) @return a string with the string representation of the argument. + @since LibreOffice 4.1 */ - static OString valueOf( sal_Int64 ll, sal_Int16 radix = 10 ) SAL_THROW(()) + static OString number( long ll, sal_Int16 radix = 10 ) { sal_Char aBuf[RTL_STR_MAX_VALUEOFINT64]; rtl_String* pNewData = 0; @@ -1454,14 +1509,70 @@ public: } /** + Returns the string representation of the long argument. + This is here because when choosing which conversion for overloaded + functions is better, the standard treats all integer conversions the same. + + This function can't be used for language specific conversion. + + @param ll a int64. + @param radix the radix (between 2 and 36) + @return a string with the string representation of the argument. + @since LibreOffice 4.1 + */ + static OString number( unsigned long ll, sal_Int16 radix = 10 ) + { + sal_Char aBuf[RTL_STR_MAX_VALUEOFINT64]; + rtl_String* pNewData = 0; + rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt64( aBuf, ll, radix ) ); + return OString( pNewData, (DO_NOT_ACQUIRE*)0 ); + } + + /// @overload + /// @since LibreOffice 4.1 + static OString number( long long ll, sal_Int16 radix = 10 ) + { + sal_Char aBuf[RTL_STR_MAX_VALUEOFINT64]; + rtl_String* pNewData = 0; + rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt64( aBuf, ll, radix ) ); + return OString( pNewData, (DO_NOT_ACQUIRE*)0 ); + } + + /// @overload + /// @since LibreOffice 4.1 + static OString number( unsigned long long ll, sal_Int16 radix = 10 ) + { + assert( ll <= SAL_MAX_INT64 ); // valueOfInt64 may not be able to handle the highest bit + sal_Char aBuf[RTL_STR_MAX_VALUEOFINT64]; + rtl_String* pNewData = 0; + rtl_string_newFromStr_WithLength( &pNewData, aBuf, rtl_str_valueOfInt64( aBuf, ll, radix ) ); + return OString( pNewData, (DO_NOT_ACQUIRE*)0 ); + } + + /** + Returns the string representation of the float argument. + + This function can't be used for language specific conversion. + + @param f a float. + @return a string with the string representation of the argument. + @deprecated use number(float) + */ + SAL_DEPRECATED_INTERNAL("use number") static OString valueOf( float f ) SAL_THROW(()) + { + return number(f); + } + + /** Returns the string representation of the float argument. This function can't be used for language specific conversion. @param f a float. @return a string with the string representation of the argument. + @since LibreOffice 4.1 */ - static OString valueOf( float f ) SAL_THROW(()) + static OString number( float f ) { sal_Char aBuf[RTL_STR_MAX_VALUEOFFLOAT]; rtl_String* pNewData = 0; @@ -1476,8 +1587,23 @@ public: @param d a double. @return a string with the string representation of the argument. + @deprecated use number(double) + */ + SAL_DEPRECATED_INTERNAL("use number") static OString valueOf( double d ) SAL_THROW(()) + { + return number(d); + } + + /** + Returns the string representation of the double argument. + + This function can't be used for language specific conversion. + + @param d a double. + @return a string with the string representation of the argument. + @since LibreOffice 4.1 */ - static OString valueOf( double d ) SAL_THROW(()) + static OString number( double d ) { sal_Char aBuf[RTL_STR_MAX_VALUEOFDOUBLE]; rtl_String* pNewData = 0; diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index c9fe25ec6131..c87978f4b067 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -2033,8 +2033,9 @@ public: @param b a sal_Bool. @return a string with the string representation of the argument. + @deprecated there is no replacement, just code your own */ - static OUString valueOf( sal_Bool b ) SAL_THROW(()) + SAL_DEPRECATED_INTERNAL("just code your own") static OUString valueOf( sal_Bool b ) SAL_THROW(()) { sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFBOOLEAN]; rtl_uString* pNewData = 0; @@ -2047,8 +2048,9 @@ public: @param c a character. @return a string with the string representation of the argument. + @deprecated just use the '+' or '+'; operator */ - static OUString valueOf( sal_Unicode c ) SAL_THROW(()) + SAL_DEPRECATED_INTERNAL("just use the '+' or '+'; operator") static OUString valueOf( sal_Unicode c ) SAL_THROW(()) { return OUString( &c, 1 ); } @@ -2061,8 +2063,9 @@ public: @param i a int32. @param radix the radix (between 2 and 36) @return a string with the string representation of the argument. + @deprecated use number(sal_Int64,sal_Int16) */ - static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 ) SAL_THROW(()) + SAL_DEPRECATED_INTERNAL("use number") static OUString valueOf( sal_Int32 i, sal_Int16 radix = 10 ) SAL_THROW(()) { sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFINT32]; rtl_uString* pNewData = 0; @@ -2071,6 +2074,40 @@ public: } /** + Returns the string representation of the int argument. + + This function can't be used for language specific conversion. + + @param i a int32. + @param radix the radix (between 2 and 36) + @return a string with the string representation of the argument. + */ + static OUString number( int i, sal_Int16 radix = 10 ) + { + sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFINT32]; + rtl_uString* pNewData = 0; + rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt32( aBuf, i, radix ) ); + return OUString( pNewData, (DO_NOT_ACQUIRE*)0 ); + } + + /** + Returns the string representation of the int argument. + + This function can't be used for language specific conversion. + + @param i a int32. + @param radix the radix (between 2 and 36) + @return a string with the string representation of the argument. + */ + static OUString number( unsigned int i, sal_Int16 radix = 10 ) + { + sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFINT64]; + rtl_uString* pNewData = 0; + rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, i, radix ) ); + return OUString( pNewData, (DO_NOT_ACQUIRE*)0 ); + } + + /** Returns the string representation of the long argument. This function can't be used for language specific conversion. @@ -2078,8 +2115,26 @@ public: @param ll a int64. @param radix the radix (between 2 and 36) @return a string with the string representation of the argument. + @deprecated use number(sal_Int64,sal_Int16) */ - static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 ) SAL_THROW(()) + SAL_DEPRECATED_INTERNAL("use number") static OUString valueOf( sal_Int64 ll, sal_Int16 radix = 10 ) SAL_THROW(()) + { + return number( ll, radix ); + } + + /** + Returns the string representation of the long argument. + This is here because when choosing which conversion for overloaded + functions is better, the standard treats all integer conversions the same. + + This function can't be used for language specific conversion. + + @param ll a int64. + @param radix the radix (between 2 and 36) + @return a string with the string representation of the argument. + @since LibreOffice 4.1 + */ + static OUString number( long ll, sal_Int16 radix = 10) { sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFINT64]; rtl_uString* pNewData = 0; @@ -2088,14 +2143,70 @@ public: } /** + Returns the string representation of the long argument. + This is here because when choosing which conversion for overloaded + functions is better, the standard treats all integer conversions the same. + + This function can't be used for language specific conversion. + + @param ll a int64. + @param radix the radix (between 2 and 36) + @return a string with the string representation of the argument. + @since LibreOffice 4.1 + */ + static OUString number( unsigned long ll, sal_Int16 radix = 10 ) + { + sal_Unicode aBuf[RTL_STR_MAX_VALUEOFINT64]; + rtl_uString* pNewData = 0; + rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) ); + return OUString( pNewData, (DO_NOT_ACQUIRE*)0 ); + } + + /// @overload + /// @since LibreOffice 4.1 + static OUString number( long long ll, sal_Int16 radix = 10 ) + { + sal_Unicode aBuf[RTL_STR_MAX_VALUEOFINT64]; + rtl_uString* pNewData = 0; + rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) ); + return OUString( pNewData, (DO_NOT_ACQUIRE*)0 ); + } + + /// @overload + /// @since LibreOffice 4.1 + static OUString number( unsigned long long ll, sal_Int16 radix = 10 ) + { + assert( ll <= SAL_MAX_INT64 ); // valueOfInt64 may not be able to handle the highest bit + sal_Unicode aBuf[RTL_STR_MAX_VALUEOFINT64]; + rtl_uString* pNewData = 0; + rtl_uString_newFromStr_WithLength( &pNewData, aBuf, rtl_ustr_valueOfInt64( aBuf, ll, radix ) ); + return OUString( pNewData, (DO_NOT_ACQUIRE*)0 ); + } + + /** + Returns the string representation of the float argument. + + This function can't be used for language specific conversion. + + @param f a float. + @return a string with the string representation of the argument. + @deprecated use number(float) + */ + SAL_DEPRECATED_INTERNAL("use number") static OUString valueOf( float f ) SAL_THROW(()) + { + return number(f); + } + + /** Returns the string representation of the float argument. This function can't be used for language specific conversion. @param f a float. @return a string with the string representation of the argument. + @since LibreOffice 4.1 */ - static OUString valueOf( float f ) SAL_THROW(()) + static OUString number( float f ) { sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFFLOAT]; rtl_uString* pNewData = 0; @@ -2110,8 +2221,23 @@ public: @param d a double. @return a string with the string representation of the argument. + @deprecated use number(double) + */ + SAL_DEPRECATED_INTERNAL("use number") static OUString valueOf( double d ) SAL_THROW(()) + { + return number(d); + } + + /** + Returns the string representation of the double argument. + + This function can't be used for language specific conversion. + + @param d a double. + @return a string with the string representation of the argument. + @since LibreOffice 4.1 */ - static OUString valueOf( double d ) SAL_THROW(()) + static OUString number( double d ) { sal_Unicode aBuf[RTL_USTR_MAX_VALUEOFDOUBLE]; rtl_uString* pNewData = 0; |