libcsdbg  1.28
C++ exception (and generic) stack trace debug library
const string * csdbg::dictionary::lookup ( const string exp,
bool  icase = false 
) const
virtual

Dictionary lookup.

Parameters
[in]expthe expression to lookup
[in]icasetrue to ignore case in comparing/matching
Returns
the matched dictionary word, NULL if no match is found
Exceptions
csdbg::exception

Definition at line 324 of file dictionary.cpp.

References csdbg::chain< string >::at(), csdbg::string::cmp(), likely, m_mode, csdbg::chain< string >::m_size, csdbg::string::match(), and unlikely.

Referenced by csdbg::parser::lookup().

325 {
326  for (u32 i = 0; likely(i < m_size); i++) {
327  string *word = at(i);
328  if ( likely(!m_mode) ) {
329  if ( unlikely(exp.cmp(*word, icase) == 0) )
330  return word;
331  }
332 
333  else if ( unlikely(exp.match(*word, icase)) )
334  return word;
335  }
336 
337  return NULL;
338 }
virtual string * at(u32) const
u32 m_size
Node count.
Definition: chain.hpp:43
bool m_mode
Lookup mode.
Definition: dictionary.hpp:40
#define likely(expr)
Offer a hint (positive) to the pipeline branch predictor.
Definition: config.hpp:344
unsigned int u32
32-bit unsigned integer
Definition: config.hpp:102
#define unlikely(expr)
Offer a hint (negative) to the pipeline branch predictor.
Definition: config.hpp:349

+ Here is the call graph for this function:

+ Here is the caller graph for this function: