LibreOffice Module canvas (master) 1
|
A very simplistic map for ASCII strings and arbitrary value types. More...
#include <canvastools.hxx>
Classes | |
struct | MapEntry |
Public Member Functions | |
ValueMap (const MapEntry *pMap, ::std::size_t nEntries, bool bCaseSensitive) | |
Create a ValueMap for the given array of MapEntries. More... | |
bool | lookup (const OUString &rName, ValueType &o_rResult) const |
Lookup a value for the given query string. More... | |
Static Private Member Functions | |
static bool | mapComparator (const MapEntry &rLHS, const MapEntry &rRHS) |
Private Attributes | |
const MapEntry * | mpMap |
::std::size_t | mnEntries |
bool | mbCaseSensitive |
A very simplistic map for ASCII strings and arbitrary value types.
This class internally references a constant, static array of sorted MapEntries, and performs a binary search to look up values for a given query string. Note that this map is static, i.e. not meant to be extended at runtime.
Definition at line 421 of file canvastools.hxx.
|
inline |
Create a ValueMap for the given array of MapEntries.
pMap | Pointer to a static array of MapEntries. Must live longer than this object! Make absolutely sure that the string entries passed via pMap are ASCII-only - everything else might not yield correct string comparisons, and thus will result in undefined behaviour. |
nEntries | Number of entries for pMap |
bCaseSensitive | Whether the map query should be performed case sensitive or not. When bCaseSensitive is false, all MapEntry strings must be lowercase! |
Definition at line 447 of file canvastools.hxx.
References aStr, i, maKey, canvas::tools::ValueMap< ValueType >::MapEntry::maKey, canvas::tools::ValueMap< ValueType >::mapComparator(), canvas::tools::ValueMap< ValueType >::mbCaseSensitive, canvas::tools::ValueMap< ValueType >::mnEntries, and SAL_WARN.
|
inline |
Lookup a value for the given query string.
rName | The string to lookup. If the map was created with the case insensitive flag, the lookup is performed case-insensitive, otherwise, case-sensitive. |
o_rResult | Output parameter, which receives the value associated with the query string. If no value was found, the referenced object is kept unmodified. |
Definition at line 501 of file canvastools.hxx.
References canvas::tools::ValueMap< ValueType >::MapEntry::maKey, canvas::tools::ValueMap< ValueType >::mapComparator(), canvas::tools::ValueMap< ValueType >::MapEntry::maValue, canvas::tools::ValueMap< ValueType >::mbCaseSensitive, canvas::tools::ValueMap< ValueType >::mnEntries, canvas::tools::ValueMap< ValueType >::mpMap, and OUStringToOString().
|
inlinestaticprivate |
Definition at line 536 of file canvastools.hxx.
References canvas::tools::ValueMap< ValueType >::MapEntry::maKey.
Referenced by canvas::tools::ValueMap< ValueType >::lookup(), and canvas::tools::ValueMap< ValueType >::ValueMap().
|
private |
Definition at line 545 of file canvastools.hxx.
Referenced by canvas::tools::ValueMap< ValueType >::lookup(), and canvas::tools::ValueMap< ValueType >::ValueMap().
|
private |
Definition at line 544 of file canvastools.hxx.
Referenced by canvas::tools::ValueMap< ValueType >::lookup(), and canvas::tools::ValueMap< ValueType >::ValueMap().
|
private |
Definition at line 543 of file canvastools.hxx.
Referenced by canvas::tools::ValueMap< ValueType >::lookup().