2 * Copyright 2004-2007, Ingo Weinhold, bonefish@users.sf.net. All rights reserved.
3 * Distributed under the terms of the MIT License.
8 #include <SupportDefs.h>
12 // from the Dragon Book: a slightly modified hashpjw()
15 string_hash(const char *name
)
19 for (; *name
; name
++) {
20 uint32 g
= h
& 0xf0000000;
37 HashString(const HashString
&string
);
38 HashString(const char *string
, int32 length
= -1);
41 bool SetTo(const char *string
, int32 maxLength
= -1);
44 void Truncate(int32 newLength
);
46 const char *GetString() const;
47 int32
GetLength() const { return fLength
; }
49 uint32
GetHashCode() const { return string_hash(GetString()); }
51 HashString
&operator=(const HashString
&string
);
52 bool operator==(const HashString
&string
) const;
53 bool operator!=(const HashString
&string
) const { return !(*this == string
); }
56 bool _SetTo(const char *string
, int32 length
);
63 } // namespace BPrivate
65 using BPrivate::HashString
;
69 #endif // HASH_STRING_H