| 1 | #pragma once |
|---|---|
| 2 | |
| 3 | #include <basis/seadTypes.h> |
| 4 | #include <prim/seadSafeString.h> |
| 5 | |
| 6 | namespace sead |
| 7 | { |
| 8 | class HashCRC16 |
| 9 | { |
| 10 | public: |
| 11 | struct Context |
| 12 | { |
| 13 | u32 hash = 0; |
| 14 | }; |
| 15 | |
| 16 | static u32 calcHash(const void* ptr, u32 size); |
| 17 | static u32 calcHashWithContext(Context* context, const void* ptr, u32 size); |
| 18 | |
| 19 | static u32 calcStringHash(const char* str); |
| 20 | static u32 calcStringHash(const SafeString& str) { return calcStringHash(str: str.cstr()); } |
| 21 | static u32 calcStringHashWithContext(Context* context, const char* str); |
| 22 | static u32 calcStringHashWithContext(Context* context, const SafeString& str) |
| 23 | { |
| 24 | return calcStringHashWithContext(context, str: str.cstr()); |
| 25 | } |
| 26 | |
| 27 | static void initialize(); |
| 28 | |
| 29 | private: |
| 30 | static u16 sTable[256]; |
| 31 | static bool sInitialized; |
| 32 | }; |
| 33 | } // namespace sead |
| 34 |