diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-03-26 23:28:29 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-03-26 23:28:29 +0100 |
commit | b57951a6b372bd77a6207b67fa305270129fcb71 (patch) | |
tree | 5108f600506d66f4c131d7c5ac10febf7993f8aa /sal | |
parent | 30be686ddee70c5aa661abfc8eb2cb6f6fdc4752 (diff) |
No need for a template here
Change-Id: I43262c984c311fcb1e1a9eca9b4dec4092351dea
Diffstat (limited to 'sal')
-rw-r--r-- | sal/rtl/strtmpl.cxx | 70 |
1 files changed, 31 insertions, 39 deletions
diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx index 455a6aebd540..78aa1f57b863 100644 --- a/sal/rtl/strtmpl.cxx +++ b/sal/rtl/strtmpl.cxx @@ -982,44 +982,6 @@ namespace { else return n; } - - - template <typename T> static inline T IMPL_RTL_STRNAME( toUInt )( const IMPL_RTL_STRCODE* pStr, - sal_Int16 nRadix ) - { - BOOST_STATIC_ASSERT(!std::numeric_limits<T>::is_signed); - sal_Int16 nDigit; - T n = 0; - - if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) ) - nRadix = 10; - - /* Skip whitespaces */ - while ( *pStr && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) ) - ++pStr; - - // skip optional explicit sign - if ( *pStr == '+' ) - ++pStr; - - const T nDiv = std::numeric_limits<T>::max()/nRadix; - const sal_Int16 nMod = std::numeric_limits<T>::max()%nRadix; - while ( *pStr ) - { - nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix ); - if ( nDigit < 0 ) - break; - if( ( nMod < nDigit ? nDiv-1 : nDiv ) < n ) - return 0; - - n *= nRadix; - n += nDigit; - - ++pStr; - } - - return n; - } } sal_Int32 SAL_CALL IMPL_RTL_STRNAME( toInt32 )( const IMPL_RTL_STRCODE* pStr, @@ -1042,7 +1004,37 @@ sal_uInt64 SAL_CALL IMPL_RTL_STRNAME( toUInt64 )( const IMPL_RTL_STRCODE* pStr, sal_Int16 nRadix ) SAL_THROW_EXTERN_C() { - return IMPL_RTL_STRNAME( toUInt )<sal_uInt64>(pStr, nRadix); + sal_Int16 nDigit; + sal_uInt64 n = 0; + + if ( (nRadix < RTL_STR_MIN_RADIX) || (nRadix > RTL_STR_MAX_RADIX) ) + nRadix = 10; + + /* Skip whitespaces */ + while ( *pStr && rtl_ImplIsWhitespace( IMPL_RTL_USTRCODE( *pStr ) ) ) + ++pStr; + + // skip optional explicit sign + if ( *pStr == '+' ) + ++pStr; + + const sal_uInt64 nDiv = SAL_MAX_UINT64/nRadix; + const sal_Int16 nMod = SAL_MAX_UINT64%nRadix; + while ( *pStr ) + { + nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix ); + if ( nDigit < 0 ) + break; + if( ( nMod < nDigit ? nDiv-1 : nDiv ) < n ) + return 0; + + n *= nRadix; + n += nDigit; + + ++pStr; + } + + return n; } /* ======================================================================= */ |