diff options
Diffstat (limited to '')
-rw-r--r-- | src/staticstring.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/staticstring.cpp b/src/staticstring.cpp index fa61e62..9eac92e 100644 --- a/src/staticstring.cpp +++ b/src/staticstring.cpp | |||
@@ -25,6 +25,13 @@ StaticString::StaticString( const char *lpNewStr, int nNewLen ) | |||
25 | setString( lpNewStr, nNewLen ); | 25 | setString( lpNewStr, nNewLen ); |
26 | } | 26 | } |
27 | 27 | ||
28 | StaticString::StaticString( const char *lpNewStr ) | ||
29 | { | ||
30 | lpStr = NULL; | ||
31 | nLen = 0; | ||
32 | setString( lpNewStr, -1 ); | ||
33 | } | ||
34 | |||
28 | StaticString::StaticString( StaticString &xSrcStr, int nNewLen ) | 35 | StaticString::StaticString( StaticString &xSrcStr, int nNewLen ) |
29 | { | 36 | { |
30 | lpStr = NULL; | 37 | lpStr = NULL; |
@@ -32,6 +39,13 @@ StaticString::StaticString( StaticString &xSrcStr, int nNewLen ) | |||
32 | setString( xSrcStr, nNewLen ); | 39 | setString( xSrcStr, nNewLen ); |
33 | } | 40 | } |
34 | 41 | ||
42 | StaticString::StaticString( StaticString &xSrcStr ) | ||
43 | { | ||
44 | lpStr = NULL; | ||
45 | nLen = 0; | ||
46 | setString( xSrcStr, -1 ); | ||
47 | } | ||
48 | |||
35 | StaticString::~StaticString() | 49 | StaticString::~StaticString() |
36 | { | 50 | { |
37 | if( lpStr != NULL ) delete[] lpStr; | 51 | if( lpStr != NULL ) delete[] lpStr; |
@@ -225,3 +239,14 @@ bool StaticString::operator!=( StaticString &str ) | |||
225 | for(; *a == *b; a++, b++ ) if( *a == '\0' && *b == '\0' ) return false; | 239 | for(; *a == *b; a++, b++ ) if( *a == '\0' && *b == '\0' ) return false; |
226 | return true; | 240 | return true; |
227 | } | 241 | } |
242 | |||
243 | unsigned long int StaticString::getHashCode() | ||
244 | { | ||
245 | unsigned long int nPos = nLen; | ||
246 | for( const char *s = (const char *)lpStr; *s; s++ ) | ||
247 | { | ||
248 | nPos = *s + (nPos << 6) + (nPos << 16) - nPos; | ||
249 | } | ||
250 | return nPos; | ||
251 | } | ||
252 | |||