diff options
author | Muthu Subramanian <sumuthu@collabora.com> | 2014-02-13 21:49:18 +0530 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2014-04-03 05:25:55 -0700 |
commit | bfb7729b9b93f64959afc9c9bf77ac665ea40abc (patch) | |
tree | 5f100f7d1122e9d2ebb399afbd708c2dd79e0bee /sal/inc | |
parent | 4600f1141487ebf408064587a93ef3ac0059676b (diff) |
Move string hash function into String class.
Change-Id: If229f3a8c4b4fd1e5f0c28618e29eded7b7853da
Diffstat (limited to 'sal/inc')
-rw-r--r-- | sal/inc/rtl/string.h | 18 | ||||
-rw-r--r-- | sal/inc/rtl/string.hxx | 13 | ||||
-rw-r--r-- | sal/inc/rtl/ustring.h | 18 |
3 files changed, 49 insertions, 0 deletions
diff --git a/sal/inc/rtl/string.h b/sal/inc/rtl/string.h index 9f3c69a0bcc4..3def4c1c2a05 100644 --- a/sal/inc/rtl/string.h +++ b/sal/inc/rtl/string.h @@ -277,6 +277,24 @@ SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode( SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_str_hashCode_WithLength( const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C(); +/** Return a hash code (64bit) for a string. + + It is not allowed to store the hash code persistently, because later + versions could return other hash codes. + + @param str + a string. Need not be null-terminated, but must be at least as long as + the specified len. + + @param len + the length of the string. + + @return + a hash code for the given string. + */ +SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_str_hashCode64_WithLength( + const sal_Char * str, sal_Int32 len ) SAL_THROW_EXTERN_C(); + /** Search for the first occurrence of a character within a string. The string must be null-terminated. diff --git a/sal/inc/rtl/string.hxx b/sal/inc/rtl/string.hxx index cbd4b9a1b043..4b7b072cb398 100644 --- a/sal/inc/rtl/string.hxx +++ b/sal/inc/rtl/string.hxx @@ -866,6 +866,19 @@ public: } /** + Returns a 64bit hash of the string data. + This hashes the entire data, while hashCode would do sampling for larger string sizes. + + @return a hash code value of the string data + + @see hashCode() for simple hashes + */ + sal_uInt64 hashCode64() const SAL_THROW(()) + { + return rtl_str_hashCode64_WithLength( pData->buffer, pData->length ); + } + + /** Returns a hashcode for this string. @return a hash code value for this object. diff --git a/sal/inc/rtl/ustring.h b/sal/inc/rtl/ustring.h index 0352e59b0e33..24a7dd8cdeeb 100644 --- a/sal/inc/rtl/ustring.h +++ b/sal/inc/rtl/ustring.h @@ -551,6 +551,24 @@ SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode( SAL_DLLPUBLIC sal_Int32 SAL_CALL rtl_ustr_hashCode_WithLength( const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C(); +/** Return a hash code (64bit) for a string. + + It is not allowed to store the hash code persistently, because later + versions could return other hash codes. + + @param str + a string. Need not be null-terminated, but must be at least as long as + the specified len. + + @param len + the length of the string. + + @return + a hash code for the given string. + */ +SAL_DLLPUBLIC sal_uInt64 SAL_CALL rtl_ustr_hashCode64_WithLength( + const sal_Unicode * str, sal_Int32 len ) SAL_THROW_EXTERN_C(); + /** Search for the first occurrence of a character within a string. The string must be null-terminated. |