EnTT: entt::basic_hashed_string< Char > Class Template Reference

EnTT 3.15.0

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
entt::basic_hashed_string< Char > Class Template Reference

Zero overhead unique identifier. More...

`#include <hashed_string.hpp>`

Inheritance diagram for entt::basic_hashed_string< Char >:
[legend]
Collaboration diagram for entt::basic_hashed_string< Char >:
[legend]

## Public Types
using | value_type = typename base_type::value_type
| Character type.
using | size_type = typename base_type::size_type
| Unsigned integer type.
using | hash_type = typename base_type::hash_type
| Unsigned integer type.

## Public Member Functions
constexpr | basic_hashed_string () noexcept
| Constructs an empty hashed string.
constexpr | basic_hashed_string (const value_type *str, const size_type len) noexcept
| Constructs a hashed string from a string view.
template<std::size_t N>
constexpr | basic_hashed_string (const value_type(&str)[N]) noexcept
| Constructs a hashed string from an array of const characters.
constexpr | basic_hashed_string (const_wrapper wrapper) noexcept
| Explicit constructor on purpose to avoid constructing a hashed string directly from a `const value_type *`.
constexpr size_type | size () const noexcept
| Returns the size a hashed string.
constexpr const value_type * | data () const noexcept
| Returns the human-readable representation of a hashed string.
constexpr hash_type | value () const noexcept
| Returns the numeric representation of a hashed string.
constexpr | operator const value_type * () const noexcept
| Returns the human-readable representation of a hashed string.
constexpr | operator hash_type () const noexcept
| Returns the numeric representation of a hashed string.

## Static Public Member Functions
static constexpr hash_type | value (const value_type *str, const size_type len) noexcept
| Returns directly the numeric representation of a string view.
template<std::size_t N>
static constexpr hash_type | value (const value_type(&str)[N]) noexcept
| Returns directly the numeric representation of a string.
static constexpr hash_type | value (const_wrapper wrapper) noexcept
| Returns directly the numeric representation of a string.

## Detailed Description

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

Zero overhead unique identifier.

A hashed string is a compile-time tool that allows users to use human-readable identifiers 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.

Warning
  This class doesn't take ownership of user-supplied strings nor does it make a copy of them.

Template Parameters

  Char | Character type.

Definition at line 59 of file hashed_string.hpp.

## Member Typedef Documentation

## ◆ hash_type

template<typename Char>

using entt::basic_hashed_string< Char >::hash_type = typename base_type::hash_type

Unsigned integer type.

Definition at line 88 of file hashed_string.hpp.

## ◆ size_type

template<typename Char>

using entt::basic_hashed_string< Char >::size_type = typename base_type::size_type

Unsigned integer type.

Definition at line 86 of file hashed_string.hpp.

## ◆ value_type

template<typename Char>

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

Character type.

Definition at line 84 of file hashed_string.hpp.

## Constructor & Destructor Documentation

## ◆ basic_hashed_string() [1/4]

template<typename Char>

entt::basic_hashed_string< Char >::basic_hashed_string | ( |  | ) |
| inlineconstexprnoexcept

Constructs an empty hashed string.

Definition at line 122 of file hashed_string.hpp.

## ◆ basic_hashed_string() [2/4]

template<typename Char>

entt::basic_hashed_string< Char >::basic_hashed_string | ( | const value_type * | str,
|  | const size_type | len )
| inlineconstexprnoexcept

Constructs a hashed string from a string view.

Parameters

  str | Human-readable identifier.
  len | Length of the string to hash.

Definition at line 130 of file hashed_string.hpp.

## ◆ basic_hashed_string() [3/4]

template<typename Char>
template<std::size_t N>

entt::basic_hashed_string< Char >::basic_hashed_string | ( | const value_type(&) | str[N] | ) |
| inlineconstexprnoexcept

Constructs a hashed string from an array of const characters.

Template Parameters

  N | Number of characters of the identifier.

Parameters

  str | Human-readable identifier.

Definition at line 140 of file hashed_string.hpp.

## ◆ basic_hashed_string() [4/4]

template<typename Char>

entt::basic_hashed_string< Char >::basic_hashed_string | ( | const_wrapper | wrapper | ) |
| inlineexplicitconstexprnoexcept

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

Warning
  The lifetime of the string is not extended nor is it copied.

Parameters

  wrapper | Helps achieving the purpose by relying on overloading.

Definition at line 152 of file hashed_string.hpp.

## Member Function Documentation

## ◆ data()

template<typename Char>

const value_type * entt::basic_hashed_string< Char >::data | ( |  | ) | const
| inlinenodiscardconstexprnoexcept

Returns the human-readable representation of a hashed string.

Returns
  The string used to initialize the hashed string.

Definition at line 167 of file hashed_string.hpp.

## ◆ operator const value_type *()

template<typename Char>

entt::basic_hashed_string< Char >::operator const value_type * | ( |  | ) | const
| inlinenodiscardconstexprnoexcept

Returns the human-readable representation of a hashed string.

Returns
  The string used to initialize the hashed string.

Definition at line 180 of file hashed_string.hpp.

## ◆ operator hash_type()

template<typename Char>

entt::basic_hashed_string< Char >::operator hash_type | ( |  | ) | const
| inlinenodiscardconstexprnoexcept

Returns the numeric representation of a hashed string.

Returns
  The numeric representation of the hashed string.

Definition at line 188 of file hashed_string.hpp.

## ◆ size()

template<typename Char>

size_type entt::basic_hashed_string< Char >::size | ( |  | ) | const
| inlinenodiscardconstexprnoexcept

Returns the size a hashed string.

Returns
  The size of the hashed string.

Definition at line 159 of file hashed_string.hpp.

## ◆ value() [1/4]

template<typename Char>

hash_type entt::basic_hashed_string< Char >::value | ( |  | ) | const
| inlinenodiscardconstexprnoexcept

Returns the numeric representation of a hashed string.

Returns
  The numeric representation of the hashed string.

Definition at line 175 of file hashed_string.hpp.

## ◆ value() [2/4]

template<typename Char>

static constexpr hash_type entt::basic_hashed_string< Char >::value | ( | const value_type * | str,
|  | const size_type | len )
| inlinestaticnodiscardconstexprnoexcept

Returns directly the numeric representation of a string view.

Parameters

  str | Human-readable identifier.
  len | Length of the string to hash.

Returns
  The numeric representation of the string.

Definition at line 96 of file hashed_string.hpp.

## ◆ value() [3/4]

template<typename Char>
template<std::size_t N>

static constexpr hash_type entt::basic_hashed_string< Char >::value | ( | const value_type(&) | str[N] | ) |
| inlinestaticnodiscardconstexprnoexcept

Returns directly the numeric representation of a string.

Template Parameters

  N | Number of characters of the identifier.

Parameters

  str | Human-readable identifier.

Returns
  The numeric representation of the string.

Definition at line 108 of file hashed_string.hpp.

## ◆ value() [4/4]

template<typename Char>

static constexpr hash_type entt::basic_hashed_string< Char >::value | ( | const_wrapper | wrapper | ) |
| inlinestaticnodiscardconstexprnoexcept

Returns directly the numeric representation of a string.

Parameters

  wrapper | Helps achieving the purpose by relying on overloading.

Returns
  The numeric representation of the string.

Definition at line 117 of file hashed_string.hpp.

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

- src/entt/core/fwd.hpp
- src/entt/core/hashed_string.hpp