qxLib
Functions
string_utils.inl File Reference

Go to the source code of this file.

Functions

template<class value_t >
constexpr size_t qx::djb2a_hash (const value_t *pszStr, size_t nSeed, size_t nLen)
 djb2a hash More...
 
template<class value_t >
constexpr size_t qx::djb2a_hash (const value_t *pszStr, size_t nSeed=0)
 djb2a hash More...
 
template<class value_t >
constexpr size_t qx::murmur_32_hash (const value_t *pStr, size_t nSeed, size_t nLen) noexcept
 Murmur nHash. More...
 
template<class fwd_it_1_t , class fwd_it_2_t >
constexpr int qx::iter_strcmp (fwd_it_1_t itBegin1, fwd_it_1_t itEnd1, fwd_it_2_t itBegin2, fwd_it_2_t itEnd2) noexcept
 Compares string 1 with string 2. More...
 
template<class value_t >
constexpr int qx::strcmp (const value_t *pszLeft, const value_t *pszRight)
 Constexpr compare two strings. More...
 
template<class value_t , class T >
constexpr const value_t * qx::get_format_specifier () noexcept
 Get format specifier for type. More...
 
template<class value_t >
constexpr std::size_t qx::strlen (const value_t *psz)
 Naive but constexpr string length algorithm, for runtime prefer std::strlen as there are may be a lot of optimizations. More...
 

Detailed Description

Author
Khrapov
Date
14.10.2026

Definition in file string_utils.inl.

Function Documentation

◆ djb2a_hash() [1/2]

template<class value_t >
constexpr size_t qx::djb2a_hash ( const value_t *  pszStr,
size_t  nSeed,
size_t  nLen 
)
constexpr

djb2a hash

Template Parameters
value_t- char type
Parameters
pszStr- string for hashing
nSeed- seed for hashing
nLen- string length
Return values
-32bit unsigned value

Definition at line 14 of file string_utils.inl.

◆ djb2a_hash() [2/2]

template<class value_t >
constexpr size_t qx::djb2a_hash ( const value_t *  pszStr,
size_t  nSeed = 0 
)
constexpr

djb2a hash

Template Parameters
value_t- char type
Parameters
pszStr- string for hashing (zero terminated)
nSeed- seed for hashing
Return values
-32bit unsigned value

Definition at line 25 of file string_utils.inl.

◆ get_format_specifier()

template<class value_t , class T >
constexpr const value_t * qx::get_format_specifier ( )
constexprnoexcept

Get format specifier for type.

Template Parameters
value_t- char type
T- target type
Return values
-format specifier or nullptr

Definition at line 171 of file string_utils.inl.

◆ iter_strcmp()

template<class fwd_it_1_t , class fwd_it_2_t >
constexpr int qx::iter_strcmp ( fwd_it_1_t  itBegin1,
fwd_it_1_t  itEnd1,
fwd_it_2_t  itBegin2,
fwd_it_2_t  itEnd2 
)
constexprnoexcept

Compares string 1 with string 2.

Template Parameters
fwd_it_1_t- string 1 iterator type
fwd_it_2_t- string 2 iterator type
Parameters
itBegin1- string 1 begin iterator
itEnd1- string 1 end iterator
itBegin2- string 2 begin iterator
itEnd2- string 2 end iterator
Return values
-< 0 the first character that does not match has a lower value in str 1 than in str 2 0 the contents of both strings are equal > 0 the first character that does not match has a greater value in str 1 than in str 2

Definition at line 110 of file string_utils.inl.

◆ murmur_32_hash()

template<class value_t >
constexpr size_t qx::murmur_32_hash ( const value_t *  pStr,
size_t  nSeed,
size_t  nLen 
)
constexprnoexcept

Murmur nHash.

https://en.wikipedia.org/wiki/MurmurHash https://softwareengineering.stackexchange.com/questions/49550/which-hashing-algorithm-is-best-for-uniqueness-and-speed

Template Parameters
value_t- char type
Parameters
pStr- string for hashing
nSeed- seed for hashing
nLen- string length
Return values
-32bit unsigned value

Definition at line 36 of file string_utils.inl.

◆ strcmp()

template<class value_t >
constexpr int qx::strcmp ( const value_t *  pszLeft,
const value_t *  pszRight 
)
constexpr

Constexpr compare two strings.

Template Parameters
value_t- char type
Parameters
pszLeft- first string (zero terminated)
pszRight- second string (zero terminated)
Return values
-< 0 the first character that does not match has a lower value in ptr1 than in ptr2 0 the contents of both strings are equal > 0 the first character that does not match has a greater value in ptr1 than in ptr2

Definition at line 134 of file string_utils.inl.

◆ strlen()

template<class value_t >
constexpr std::size_t qx::strlen ( const value_t *  psz)
constexpr

Naive but constexpr string length algorithm, for runtime prefer std::strlen as there are may be a lot of optimizations.

Template Parameters
value_t- char type
Parameters
psz- pointer to string zero terminated
Return values
-string length

Definition at line 250 of file string_utils.inl.