|
EnTT
3.5.0
|
Zero overhead unique identifier. More...
#include <hashed_string.hpp>
Public Types | |
| using | value_type = Char |
| Character type. | |
| using | hash_type = id_type |
| Unsigned integer type. | |
Public Member Functions | |
| constexpr | basic_hashed_string () noexcept |
| Constructs an empty hashed string. | |
| template<std::size_t N> | |
| constexpr | basic_hashed_string (const value_type(&curr)[N]) noexcept |
| Constructs a hashed string from an array of const characters. More... | |
| constexpr | basic_hashed_string (const_wrapper wrapper) noexcept |
Explicit constructor on purpose to avoid constructing a hashed string directly from a const value_type *. More... | |
| constexpr const value_type * | data () const noexcept |
| Returns the human-readable representation of a hashed string. More... | |
| constexpr hash_type | value () const noexcept |
| Returns the numeric representation of a hashed string. More... | |
| constexpr | operator const value_type * () const noexcept |
| Returns the human-readable representation of a hashed string. More... | |
| constexpr | operator hash_type () const noexcept |
| Returns the numeric representation of a hashed string. More... | |
| constexpr bool | operator== (const basic_hashed_string &other) const noexcept |
| Compares two hashed strings. More... | |
Static Public Member Functions | |
| template<std::size_t N> | |
| static constexpr hash_type | value (const value_type(&str)[N]) noexcept |
| Returns directly the numeric representation of a string. More... | |
| static hash_type | value (const_wrapper wrapper) noexcept |
| Returns directly the numeric representation of a string. More... | |
| static hash_type | value (const value_type *str, std::size_t size) noexcept |
| Returns directly the numeric representation of a string view. More... | |
Zero overhead unique identifier.
A hashed string is a compile-time tool that allows users to use human-readable identifers in the codebase while using their numeric counterparts at runtime.
Because of that, a hashed string can also be used in constant expressions if required.
| Char | Character type. |
Definition at line 64 of file hashed_string.hpp.
|
inlineconstexprnoexcept |
Constructs a hashed string from an array of const characters.
Forcing template resolution avoids implicit conversions. An human-readable identifier can be anything but a plain, old bunch of characters.
Example of use:
| N | Number of characters of the identifier. |
| curr | Human-readable identifer. |
Definition at line 151 of file hashed_string.hpp.
|
inlineexplicitconstexprnoexcept |
Explicit constructor on purpose to avoid constructing a hashed string directly from a const value_type *.
| wrapper | Helps achieving the purpose by relying on overloading. |
Definition at line 160 of file hashed_string.hpp.
|
inlineconstexprnoexcept |
Returns the human-readable representation of a hashed string.
Definition at line 168 of file hashed_string.hpp.
|
inlineconstexprnoexcept |
Returns the human-readable representation of a hashed string.
Definition at line 181 of file hashed_string.hpp.
|
inlineconstexprnoexcept |
Returns the numeric representation of a hashed string.
Definition at line 187 of file hashed_string.hpp.
|
inlineconstexprnoexcept |
Compares two hashed strings.
| other | Hashed string with which to compare. |
Definition at line 194 of file hashed_string.hpp.
|
inlineconstexprnoexcept |
Returns the numeric representation of a hashed string.
Definition at line 176 of file hashed_string.hpp.
|
inlinestaticnoexcept |
Returns directly the numeric representation of a string view.
| str | Human-readable identifer. |
| size | Length of the string to hash. |
Definition at line 125 of file hashed_string.hpp.
|
inlinestaticconstexprnoexcept |
Returns directly the numeric representation of a string.
Forcing template resolution avoids implicit conversions. An human-readable identifier can be anything but a plain, old bunch of characters.
Example of use:
| N | Number of characters of the identifier. |
| str | Human-readable identifer. |
Definition at line 106 of file hashed_string.hpp.
|
inlinestaticnoexcept |
Returns directly the numeric representation of a string.
| wrapper | Helps achieving the purpose by relying on overloading. |
Definition at line 115 of file hashed_string.hpp.
1.8.18