OpenLexocad  27.1
entt::basic_hashed_string< Char > Class Template Reference

Zero overhead unique identifier. More...

#include <entt.hpp>

Public Types

using value_type = Char
 Character type. More...
 
using hash_type = ENTT_ID_TYPE
 Unsigned integer type. More...
 

Public Member Functions

constexpr basic_hashed_string () ENTT_NOEXCEPT
 Constructs an empty hashed string. More...
 
template<std::size_t N>
constexpr basic_hashed_string (const value_type(&curr)[N]) ENTT_NOEXCEPT
 Constructs a hashed string from an array of const characters. More...
 
constexpr basic_hashed_string (const_wrapper wrapper) ENTT_NOEXCEPT
 Explicit constructor on purpose to avoid constructing a hashed string directly from a const value_type *. More...
 
constexpr const value_typedata () const ENTT_NOEXCEPT
 Returns the human-readable representation of a hashed string. More...
 
constexpr hash_type value () const ENTT_NOEXCEPT
 Returns the numeric representation of a hashed string. More...
 
constexpr operator const value_type * () const ENTT_NOEXCEPT
 Returns the human-readable representation of a hashed string. More...
 
constexpr operator hash_type () const ENTT_NOEXCEPT
 Returns the numeric representation of a hashed string. More...
 
constexpr bool operator== (const basic_hashed_string &other) const ENTT_NOEXCEPT
 Compares two hashed strings. More...
 

Static Public Member Functions

template<std::size_t N>
static constexpr hash_type to_value (const value_type(&str)[N]) ENTT_NOEXCEPT
 Returns directly the numeric representation of a string. More...
 
static hash_type to_value (const_wrapper wrapper) ENTT_NOEXCEPT
 Returns directly the numeric representation of a string. More...
 
static hash_type to_value (const value_type *str, std::size_t size) ENTT_NOEXCEPT
 Returns directly the numeric representation of a string view. More...
 

Detailed Description

template<typename Char>
class entt::basic_hashed_string< Char >

Zero overhead unique identifier.

TURN_OFF_DOXYGENA 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.

Template Parameters
CharCharacter type.

Member Typedef Documentation

◆ hash_type

template<typename Char>
using entt::basic_hashed_string< Char >::hash_type = ENTT_ID_TYPE

Unsigned integer type.

◆ value_type

template<typename Char>
using entt::basic_hashed_string< Char >::value_type = Char

Character type.

Constructor & Destructor Documentation

◆ basic_hashed_string() [1/3]

template<typename Char>
constexpr entt::basic_hashed_string< Char >::basic_hashed_string ( )
inline

Constructs an empty hashed string.

◆ basic_hashed_string() [2/3]

template<typename Char>
template<std::size_t N>
constexpr entt::basic_hashed_string< Char >::basic_hashed_string ( const value_type(&)  curr[N])
inline

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:

basic_hashed_string<char> hs{"my.png"};
Template Parameters
NNumber of characters of the identifier.
Parameters
currHuman-readable identifer.

◆ basic_hashed_string() [3/3]

template<typename Char>
constexpr entt::basic_hashed_string< Char >::basic_hashed_string ( const_wrapper  wrapper)
inlineexplicit

Explicit constructor on purpose to avoid constructing a hashed string directly from a const value_type *.

Parameters
wrapperHelps achieving the purpose by relying on overloading.

Member Function Documentation

◆ data()

template<typename Char>
constexpr const value_type* entt::basic_hashed_string< Char >::data ( ) const
inline

Returns the human-readable representation of a hashed string.

Returns
The string used to initialize the instance.

◆ operator const value_type *()

template<typename Char>
constexpr entt::basic_hashed_string< Char >::operator const value_type * ( ) const
inline

Returns the human-readable representation of a hashed string.

Returns
The string used to initialize the instance.

◆ operator hash_type()

template<typename Char>
constexpr entt::basic_hashed_string< Char >::operator hash_type ( ) const
inline

Returns the numeric representation of a hashed string.

Returns
The numeric representation of the instance.

◆ operator==()

template<typename Char>
constexpr bool entt::basic_hashed_string< Char >::operator== ( const basic_hashed_string< Char > &  other) const
inline

Compares two hashed strings.

Parameters
otherHashed string with which to compare.
Returns
True if the two hashed strings are identical, false otherwise.

◆ to_value() [1/3]

template<typename Char>
template<std::size_t N>
static constexpr hash_type entt::basic_hashed_string< Char >::to_value ( const value_type(&)  str[N])
inlinestatic

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:

Template Parameters
NNumber of characters of the identifier.
Parameters
strHuman-readable identifer.
Returns
The numeric representation of the string.

◆ to_value() [2/3]

template<typename Char>
static hash_type entt::basic_hashed_string< Char >::to_value ( const_wrapper  wrapper)
inlinestatic

Returns directly the numeric representation of a string.

Parameters
wrapperHelps achieving the purpose by relying on overloading.
Returns
The numeric representation of the string.

◆ to_value() [3/3]

template<typename Char>
static hash_type entt::basic_hashed_string< Char >::to_value ( const value_type str,
std::size_t  size 
)
inlinestatic

Returns directly the numeric representation of a string view.

Parameters
strHuman-readable identifer.
sizeLength of the string to hash.
Returns
The numeric representation of the string.

◆ value()

template<typename Char>
constexpr hash_type entt::basic_hashed_string< Char >::value ( ) const
inline

Returns the numeric representation of a hashed string.

Returns
The numeric representation of the instance.

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