|
CeresEngine 0.2.0
A game development framework
|
The string identifier class. More...
#include <CeresEngine/Foundation/StringID.hpp>
Public Types | |
| enum class | Status { Collision , NewString , OldString } |
| The status of an insert operation. More... | |
| using | Hash = UInt64 |
| The type of a hashed string. | |
| using | CollisionHandler = void(*)(StringID::Hash hash, StringView a, StringView b) |
| The type of the collision handler. | |
Public Member Functions | |
| StringID ()=default | |
Constructs a new empty StringID. | |
| StringID (StringView string) | |
| Creates a new id by hashing a given string. | |
| StringID (StringDatabase &database, StringView string) | |
| Creates a new id by hashing a given string. | |
| StringID (const StringID &prefix, StringView string) | |
| Creates a new id with a given prefix. | |
| StringID (StringDatabase &database, StringView string, Status &status) | |
Same as other constructors versions but instead of calling the CollisionHandler, they set the output parameter to the appropriate status. | |
| StringID (const StringID &prefix, StringView string, Status &status) | |
Same as other constructors versions but instead of calling the CollisionHandler, they set the output parameter to the appropriate status. | |
| StringID::Hash | getHashCode () const noexcept |
| StringView | getString () const noexcept |
Static Public Member Functions | |
| static CollisionHandler | setCollisionHandler (CollisionHandler h) |
Exchanges the CollisionHandler. | |
| static CollisionHandler | getCollisionHandler () |
Returns the current CollisionHandler. | |
Private Attributes | |
| Hash | mID = 0 |
| StringDatabase * | mDatabase = nullptr |
Friends | |
| bool | operator== (const StringID a, const StringID b) noexcept |
| Compares string ids with another or hashed values. | |
| bool | operator== (const StringID::Hash a, const StringID &b) noexcept |
| bool | operator== (const StringID &a, const StringID::Hash b) noexcept |
| bool | operator!= (const StringID &a, const StringID &b) noexcept |
| bool | operator!= (const StringID::Hash a, const StringID &b) noexcept |
| bool | operator!= (const StringID &a, const StringID::Hash b) noexcept |
The string identifier class.
This is a lightweight class to store strings. It only stores a hash of the string allowing fast copying and comparisons.
| using CeresEngine::StringID::CollisionHandler = void (*)(StringID::Hash hash, StringView a, StringView b) |
The type of the collision handler.
CollisionError. The type of a hashed string.
|
default |
Constructs a new empty StringID.
The value will be comparable true only to other empty string IDs.
|
explicit |
Creates a new id by hashing a given string.
Database which will copy it. If it encounters a collision, the CollisionHandler will be called. | CeresEngine::StringID::StringID | ( | StringDatabase & | database, |
| StringView | string | ||
| ) |
Creates a new id by hashing a given string.
Database which will copy it. If it encounters a collision, the CollisionHandler will be called. | CeresEngine::StringID::StringID | ( | const StringID & | prefix, |
| StringView | string | ||
| ) |
Creates a new id with a given prefix.
| CeresEngine::StringID::StringID | ( | StringDatabase & | database, |
| StringView | string, | ||
| Status & | status | ||
| ) |
Same as other constructors versions but instead of calling the CollisionHandler, they set the output parameter to the appropriate status.
| CeresEngine::StringID::StringID | ( | const StringID & | prefix, |
| StringView | string, | ||
| Status & | status | ||
| ) |
Same as other constructors versions but instead of calling the CollisionHandler, they set the output parameter to the appropriate status.
|
static |
Returns the current CollisionHandler.
|
inlinenoexcept |
|
noexcept |
|
static |
Exchanges the CollisionHandler.
Compares string ids with another or hashed values.
|
private |
|
private |