gigawidgets 0.3.55
A wxWidgets-style UI library for the Arduino Giga Display Shield.
 
Loading...
Searching...
No Matches
id.hpp File Reference

Go to the source code of this file.

Classes

struct  ui::hash32::hash32gen< size, idx, dummy >
 A compile-time CRC32 hash function. More...
 
struct  ui::hash32::hash32gen< size, size, dummy >
 The stopping specialization for the hash32 template. More...
 

Typedefs

typedef uint32_t ui::id_t
 A (typically unique) identifier for widgets.
 

Functions

id_t ui::id (const char *str, int size) noexcept
 Computes the CRC32 hash of a string at runtime.
 
constexpr id_t ui::id (const char *str) noexcept
 Computes the CRC32 hash of a string at compile time.
 
constexpr ui::id_t operator""_id (const char *str) noexcept
 The constexpr conversion operator for IDs.
 
constexpr ui::id_t operator""_id (const char *str, size_t) noexcept
 The constexpr conversion operator for IDs.
 

Function Documentation

◆ id() [1/2]

constexpr id_t ui::id ( const char *  str)
inlineconstexprnoexcept

Computes the CRC32 hash of a string at compile time.

This function will be used for strings that are known at compile time, so the hash will not be calculated at run time.

Parameters
strThe string to hash.
Returns
The computed CRC32 hash.

◆ id() [2/2]

id_t ui::id ( const char *  str,
int  size 
)
noexcept

Computes the CRC32 hash of a string at runtime.

This function is not constexpr and can be used for strings that are not known at compile time.

Parameters
strThe string to hash.
sizeThe size of the string.
Returns
The computed CRC32 hash.

◆ operator""_id() [1/2]

constexpr ui::id_t operator""_id ( const char *  str)
inlineconstexprnoexcept

The constexpr conversion operator for IDs.

This operator allows writing expressions like "some text"_id, which automatically gets converted to an integer at compile time.

Parameters
strThe string to hash.
Returns
The computed CRC32 hash.

◆ operator""_id() [2/2]

constexpr ui::id_t operator""_id ( const char *  str,
size_t   
)
inlineconstexprnoexcept

The constexpr conversion operator for IDs.

This operator allows writing expressions like "some text"_id, which automatically gets converted to an integer at compile time.

Parameters
strThe string to hash.
Returns
The computed CRC32 hash.