Table with C-strings mapped to an integer id. More...
#include <strintmap.hpp>
Public Member Functions | |
CStrIntMap (T &a_table) | |
Needs to know what table to use. | |
size_t | index_of (const char *a_name, bool a_case_sensitive=false) |
Match the given name with names from the entries in the table. | |
size_t | index_of (const int a_id) |
Returns the index from the table where the id matches the entry from the table. | |
Static Public Attributes | |
static constexpr size_t | npos = size_t(-1) |
Value returned on error or when an index on a container is not found. | |
Table with C-strings mapped to an integer id.
Definition at line 38 of file strintmap.hpp.
|
inline |
Needs to know what table to use.
A valid table is a std::array() container with entries like {"GET", UPnPsdk::HTTPMETHOD_GET}
with (const char*)"GET" and (int)HTTPMETHOD_GET. Any C-String and integer is possible. Due to use of effective binary seach the entries must be sorted by the string names.
Definition at line 54 of file strintmap.hpp.
size_t UPnPsdk::CStrIntMap< T >::index_of | ( | const char * | a_name, |
bool | a_case_sensitive = false |
||
) |
Match the given name with names from the entries in the table.
[in] | a_name | String containing the name to be matched. |
[in] | a_case_sensitive | Whether search should be case sensitive or not. Default is not case sensitive search. |
Definition at line 81 of file strintmap.hpp.
size_t UPnPsdk::CStrIntMap< T >::index_of | ( | const int | a_id | ) |
Returns the index from the table where the id matches the entry from the table.
[in] | a_id | ID to be matched. |
Definition at line 122 of file strintmap.hpp.
|
staticconstexpr |
Value returned on error or when an index on a container is not found.
Although the definition uses -1, size_t is an unsigned integer type, and the value of npos is the largest positive value it can hold, due to signed-to-unsigned implicit conversion. This is a portable way to specify the largest value of any unsigned type.
Definition at line 46 of file strintmap.hpp.