xoreos  0.0.5
Public Member Functions | Static Public Attributes | Private Types | Private Attributes | List of all members
Common::StringListMap Class Reference

A map to quickly match strings from a list. More...

#include <stringmap.h>

Public Member Functions

 StringListMap (const char *const *strings, size_t count, bool onlyFirstWord=false)
 Build a string map to match a list of strings against. More...
 
size_t find (const char *str, const char **match) const
 Match a string against the map. More...
 
size_t find (const UString &str, const char **match) const
 Match a string against the map. More...
 

Static Public Attributes

static const size_t kInvalidIndex = SIZE_MAX
 

Private Types

typedef boost::unordered_map< UString, size_t, hashUStringCaseInsensitiveStrMap
 

Private Attributes

bool _onlyFirstWord
 
StrMap _map
 

Detailed Description

A map to quickly match strings from a list.

Definition at line 43 of file stringmap.h.

Member Typedef Documentation

◆ StrMap

typedef boost::unordered_map<UString, size_t, hashUStringCaseInsensitive> Common::StringListMap::StrMap
private

Definition at line 69 of file stringmap.h.

Constructor & Destructor Documentation

◆ StringListMap()

Common::StringListMap::StringListMap ( const char *const *  strings,
size_t  count,
bool  onlyFirstWord = false 
)

Build a string map to match a list of strings against.

Definition at line 32 of file stringmap.cpp.

References _map.

Member Function Documentation

◆ find() [1/2]

size_t Common::StringListMap::find ( const char *  str,
const char **  match 
) const

Match a string against the map.

Parameters
strThe string to match against.
matchIf != 0, the position after the match will be stored here.
Returns
The index of the matched string in the original list, or kInvalidIndex if not found.

Definition at line 37 of file stringmap.cpp.

References _map, _onlyFirstWord, Common::UString::end(), Common::UString::findFirst(), kInvalidIndex, and Common::UString::truncate().

Referenced by Graphics::parseTXICommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find() [2/2]

size_t Common::StringListMap::find ( const UString str,
const char **  match 
) const

Match a string against the map.

Parameters
strThe string to match against.
matchIf != 0, the position after the match will be stored here.
Returns
The index of the matched string in the original list, or kInvalidIndex if not found.

Definition at line 55 of file stringmap.cpp.

References _map, _onlyFirstWord, Common::UString::c_str(), Common::UString::end(), Common::UString::findFirst(), kInvalidIndex, and Common::UString::truncate().

Here is the call graph for this function:

Member Data Documentation

◆ _map

StrMap Common::StringListMap::_map
private

Definition at line 71 of file stringmap.h.

Referenced by find(), and StringListMap().

◆ _onlyFirstWord

bool Common::StringListMap::_onlyFirstWord
private

Definition at line 67 of file stringmap.h.

Referenced by find().

◆ kInvalidIndex

const size_t Common::StringListMap::kInvalidIndex = SIZE_MAX
static

Definition at line 45 of file stringmap.h.

Referenced by find().


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