Emergency 20 Dokumentation  4.2.0
qsf::StringHash Class Reference

Compile time string hash class. More...

#include <StringHash.h>

Classes

struct  ConstCharWrapper
 "const char*"-wrapper enabling the compiler to distinguish between static and dynamic strings More...
 

Public Member Functions

template<uint32 N>
QSF_FORCEINLINE StringHash (const char(&string)[N])
 Constructor for calculating the hash value of a given static string. More...
 
QSF_FORCEINLINE StringHash (const ConstCharWrapper &string)
 Constructor for calculating the hash value of a given dynamic string. More...
 
QSF_FORCEINLINE StringHash (uint32 hash)
 Constructor for directly setting an uint32 value as string hash. More...
 
QSF_FORCEINLINE StringHash (const StringHash &stringHash)
 Copy constructor. More...
 
QSF_FORCEINLINE uint32 getHash () const
 Return the generated hash value. More...
 
QSF_FORCEINLINE operator uint32 () const
 Return the generated hash value. More...
 

Static Public Member Functions

static QSF_FORCEINLINE uint32 calculateFNV (const char *string)
 Calculate the hash value of the given string. More...
 

Detailed Description

Compile time string hash class.

Remarks
The following example shows how to use the string hash class:
uint32 hash = qsf::StringHash("qsf::MetadataComponent"); // Result will be 483975945
Note

Constructor & Destructor Documentation

template<uint32 N>
QSF_FORCEINLINE qsf::StringHash::StringHash ( const char(&)  string[N])

Constructor for calculating the hash value of a given static string.

Parameters
[in]stringStatic string to calculate the hash value for, must be valid
QSF_FORCEINLINE qsf::StringHash::StringHash ( const ConstCharWrapper string)
explicit

Constructor for calculating the hash value of a given dynamic string.

Parameters
[in]stringDynamic string to calculate the hash value for, must be valid
QSF_FORCEINLINE qsf::StringHash::StringHash ( uint32  hash)

Constructor for directly setting an uint32 value as string hash.

Parameters
[in]hashHash value to set
Note
  • By intent not explicit for best possible usability
QSF_FORCEINLINE qsf::StringHash::StringHash ( const StringHash stringHash)

Copy constructor.

Parameters
[in]stringHashString hash instance to copy from
Note
  • Don't make this explicit or you will loose the string debugging introspection functionality

Member Function Documentation

QSF_FORCEINLINE uint32 qsf::StringHash::calculateFNV ( const char *  string)
static

Calculate the hash value of the given string.

Parameters
[in]stringNull terminated ASCII string to calculate the hash value for, must be valid
Returns
The hash value of the given string
QSF_FORCEINLINE uint32 qsf::StringHash::getHash ( ) const

Return the generated hash value.

Returns
The generated FNV-1a hash value
QSF_FORCEINLINE qsf::StringHash::operator uint32 ( ) const

Return the generated hash value.

Returns
The generated FNV-1a hash value

The documentation for this class was generated from the following files: