qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches
qb::icase_basic_map< _Map, _Trait > Class Template Reference

A case-insensitive map implementation. More...

#include <unordered_map.h>

Inheritance diagram for qb::icase_basic_map< _Map, _Trait >:
Collaboration diagram for qb::icase_basic_map< _Map, _Trait >:

Public Member Functions

 icase_basic_map ()=default
 Default constructor.
 icase_basic_map (icase_basic_map const &)=default
 Copy constructor.
 icase_basic_map (icase_basic_map &&) noexcept=default
 Move constructor.
 icase_basic_map (std::initializer_list< typename _Map::value_type > il)
 Initializer list constructor.
icase_basic_mapoperator= (icase_basic_map const &)=default
 Copy assignment operator.
icase_basic_mapoperator= (icase_basic_map &&) noexcept=default
 Move assignment operator.
template<typename T, typename... _Args>
auto emplace (T &&key, _Args &&...args)
 Emplace a new key-value pair with the key converted to lowercase.
template<typename T, typename... _Args>
auto try_emplace (T &&key, _Args &&...args)
 Try to emplace a new key-value pair with the key converted to lowercase.
template<typename T>
auto & at (T &&key)
 Access a value by key, with the key converted to lowercase.
template<typename T>
const auto & at (T &&key) const
 Access a value by key, with the key converted to lowercase (const version)
template<typename T>
auto & operator[] (T &&key)
 Access or insert a value by key, with the key converted to lowercase.
template<typename T>
auto find (T &&key)
 Find a key-value pair by key, with the key converted to lowercase.
template<typename T>
auto find (T &&key) const
 Find a key-value pair by key, with the key converted to lowercase (const version)
template<typename T>
bool has (T &&key) const
 Check if a key exists in the map.
template<typename T>
auto erase (T &&key)
 Erase a key-value pair by key, with the key converted to lowercase.

Static Public Member Functions

template<typename T>
static std::string convert_key (T &&key) noexcept
 Convert a key to lowercase.

Detailed Description

template<typename _Map, typename _Trait = string_to_lower>
class qb::icase_basic_map< _Map, _Trait >

A case-insensitive map implementation.

This template class wraps any map type to provide case-insensitive string keys by converting keys to lowercase before operations.

Template Parameters
_MapThe underlying map type
_TraitThe trait class for string conversion (defaults to string_to_lower)

Constructor & Destructor Documentation

◆ icase_basic_map()

template<typename _Map, typename _Trait = string_to_lower>
qb::icase_basic_map< _Map, _Trait >::icase_basic_map ( std::initializer_list< typename _Map::value_type > il)
inline

Initializer list constructor.

Parameters
ilInitializer list of key-value pairs

Member Function Documentation

◆ emplace()

template<typename _Map, typename _Trait = string_to_lower>
template<typename T, typename... _Args>
auto qb::icase_basic_map< _Map, _Trait >::emplace ( T && key,
_Args &&... args )
inline

Emplace a new key-value pair with the key converted to lowercase.

Template Parameters
TKey type
_ArgsValue constructor argument types
Parameters
keyThe key (will be converted to lowercase)
argsArguments to construct the value
Returns
Result of the underlying map's emplace operation

◆ try_emplace()

template<typename _Map, typename _Trait = string_to_lower>
template<typename T, typename... _Args>
auto qb::icase_basic_map< _Map, _Trait >::try_emplace ( T && key,
_Args &&... args )
inline

Try to emplace a new key-value pair with the key converted to lowercase.

Template Parameters
TKey type
_ArgsValue constructor argument types
Parameters
keyThe key (will be converted to lowercase)
argsArguments to construct the value
Returns
Result of the underlying map's try_emplace operation

◆ at() [1/2]

template<typename _Map, typename _Trait = string_to_lower>
template<typename T>
auto & qb::icase_basic_map< _Map, _Trait >::at ( T && key)
inline

Access a value by key, with the key converted to lowercase.

Template Parameters
TKey type
Parameters
keyThe key (will be converted to lowercase)
Returns
Reference to the value associated with the key
Exceptions
std::out_of_rangeif the key is not found

◆ at() [2/2]

template<typename _Map, typename _Trait = string_to_lower>
template<typename T>
const auto & qb::icase_basic_map< _Map, _Trait >::at ( T && key) const
inline

Access a value by key, with the key converted to lowercase (const version)

Template Parameters
TKey type
Parameters
keyThe key (will be converted to lowercase)
Returns
Reference to the value associated with the key
Exceptions
std::out_of_rangeif the key is not found

◆ operator[]()

template<typename _Map, typename _Trait = string_to_lower>
template<typename T>
auto & qb::icase_basic_map< _Map, _Trait >::operator[] ( T && key)
inline

Access or insert a value by key, with the key converted to lowercase.

Template Parameters
TKey type
Parameters
keyThe key (will be converted to lowercase)
Returns
Reference to the value associated with the key

◆ find() [1/2]

template<typename _Map, typename _Trait = string_to_lower>
template<typename T>
auto qb::icase_basic_map< _Map, _Trait >::find ( T && key)
inline

Find a key-value pair by key, with the key converted to lowercase.

Template Parameters
TKey type
Parameters
keyThe key (will be converted to lowercase)
Returns
Iterator to the key-value pair if found, or end() if not found

◆ find() [2/2]

template<typename _Map, typename _Trait = string_to_lower>
template<typename T>
auto qb::icase_basic_map< _Map, _Trait >::find ( T && key) const
inline

Find a key-value pair by key, with the key converted to lowercase (const version)

Template Parameters
TKey type
Parameters
keyThe key (will be converted to lowercase)
Returns
Iterator to the key-value pair if found, or end() if not found

◆ has()

template<typename _Map, typename _Trait = string_to_lower>
template<typename T>
bool qb::icase_basic_map< _Map, _Trait >::has ( T && key) const
inline

Check if a key exists in the map.

Template Parameters
TKey type
Parameters
keyThe key (will be converted to lowercase)
Returns
true if the key exists, false otherwise

◆ erase()

template<typename _Map, typename _Trait = string_to_lower>
template<typename T>
auto qb::icase_basic_map< _Map, _Trait >::erase ( T && key)
inline

Erase a key-value pair by key, with the key converted to lowercase.

Template Parameters
TKey type
Parameters
keyThe key (will be converted to lowercase)
Returns
The number of elements erased.

◆ convert_key()

template<typename _Map, typename _Trait = string_to_lower>
template<typename T>
std::string qb::icase_basic_map< _Map, _Trait >::convert_key ( T && key)
inlinestaticnoexcept

Convert a key to lowercase.

Utility method to convert a key to lowercase outside of map operations.

Template Parameters
TKey type
Parameters
keyThe key to convert
Returns
std::string The lowercase version of the key