UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
UPnPsdk::CStrIntMap< T > Class Template Reference

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.
 

Detailed Description

template<typename T>
class UPnPsdk::CStrIntMap< T >

Table with C-strings mapped to an integer id.

Definition at line 38 of file strintmap.hpp.

Constructor & Destructor Documentation

◆ CStrIntMap()

template<typename T >
UPnPsdk::CStrIntMap< T >::CStrIntMap ( T &  a_table)
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.

Member Function Documentation

◆ index_of() [1/2]

template<typename T >
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.

Returns
  • On success: Zero based index (position) on the table of entries.
  • On failure: CStrIntMap::npos means string not found
Parameters
[in]a_nameString containing the name to be matched.
[in]a_case_sensitiveWhether search should be case sensitive or not. Default is not case sensitive search.

Definition at line 81 of file strintmap.hpp.

+ Here is the caller graph for this function:

◆ index_of() [2/2]

template<typename T >
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.

Returns
  • On success: Zero based index (position) on the table of entries.
  • On failure: CStrIntMap::npos means id not found
Parameters
[in]a_idID to be matched.

Definition at line 122 of file strintmap.hpp.

Member Data Documentation

◆ npos

template<typename T >
constexpr size_t UPnPsdk::CStrIntMap< T >::npos = size_t(-1)
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.


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