foobar2000 SDK  2015-08-03
Data Structures | Public Member Functions | Static Private Member Functions | Private Attributes
menu_helpers::name_to_guid_table

#include <menu_helpers.h>

Data Structures

struct  entry
 
struct  search_entry
 

Public Member Functions

 name_to_guid_table ()
 
 ~name_to_guid_table ()
 
bool search (const char *p_name, unsigned p_name_len, GUID &p_out)
 

Static Private Member Functions

static int entry_compare (const entry &entry1, const entry &entry2)
 
static int entry_compare_search (const entry &entry1, const search_entry &entry2)
 

Private Attributes

pfc::array_t< entrym_data
 
bool m_inited
 

Detailed Description

Definition at line 42 of file menu_helpers.h.


Data Structure Documentation

struct menu_helpers::name_to_guid_table::entry

Definition at line 49 of file menu_helpers.h.

Data Fields
GUID m_guid
char * m_name
struct menu_helpers::name_to_guid_table::search_entry

Definition at line 55 of file menu_helpers.h.

Data Fields
const char * m_name
unsigned m_name_len

Constructor & Destructor Documentation

menu_helpers::name_to_guid_table::name_to_guid_table ( )

Definition at line 235 of file menu_helpers.cpp.

236 {
237  m_inited = false;
238 }
menu_helpers::name_to_guid_table::~name_to_guid_table ( )

Definition at line 240 of file menu_helpers.cpp.

241 {
242  t_size n, m = m_data.get_size();
243  for(n=0;n<m;n++) free(m_data[n].m_name);
244 
245 }
size_t t_size
Definition: int_types.h:48
pfc::array_t< entry > m_data
Definition: menu_helpers.h:53

Member Function Documentation

int menu_helpers::name_to_guid_table::entry_compare ( const entry entry1,
const entry entry2 
)
staticprivate

Definition at line 191 of file menu_helpers.cpp.

192 {
193  return stricmp_utf8(entry1.m_name,entry2.m_name);
194 }
int SHARED_EXPORT stricmp_utf8(const char *p1, const char *p2)
int menu_helpers::name_to_guid_table::entry_compare_search ( const entry entry1,
const search_entry entry2 
)
staticprivate

Definition at line 186 of file menu_helpers.cpp.

187 {
188  return stricmp_utf8_ex(entry1.m_name,~0,entry2.m_name,entry2.m_name_len);
189 }
int SHARED_EXPORT stricmp_utf8_ex(const char *p1, t_size len1, const char *p2, t_size len2)
bool menu_helpers::name_to_guid_table::search ( const char *  p_name,
unsigned  p_name_len,
GUID p_out 
)

Definition at line 196 of file menu_helpers.cpp.

197 {
198  if (!m_inited)
199  {
200  m_data.set_size(calc_total_action_count());
201  t_size dataptr = 0;
202  pfc::string8_fastalloc nametemp;
203 
206  while(e.next(ptr))
207  {
208  unsigned n, m = ptr->get_num_items();
209  for(n=0;n<m;n++)
210  {
211  assert(dataptr < m_data.get_size());
212 
213  ptr->get_item_name(n,nametemp);
214  m_data[dataptr].m_name = _strdup(nametemp);
215  m_data[dataptr].m_guid = ptr->get_item_guid(n);
216  dataptr++;
217  }
218  }
219  assert(dataptr == m_data.get_size());
220 
222  m_inited = true;
223  }
224  t_size index;
225  search_entry temp = {p_name,p_name_len};
226  if (pfc::bsearch_t(m_data.get_size(),m_data,entry_compare_search,temp,index))
227  {
228  p_out = m_data[index].m_guid;
229  return true;
230  }
231  else
232  return false;
233 }
static int entry_compare_search(const entry &entry1, const search_entry &entry2)
size_t t_size
Definition: int_types.h:48
static void sort_t(t_container &p_data, t_compare p_compare, t_size p_count)
Definition: sort.h:162
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
static int entry_compare(const entry &entry1, const entry &entry2)
bool next(service_ptr_t< t_query > &p_out)
Definition: service.h:587
string8_t< pfc::alloc_fast_aggressive > string8_fastalloc
Definition: string_base.h:436
bool bsearch_t(t_size p_count, const t_container &p_container, t_compare p_compare, const t_param &p_param, t_size &p_index)
Definition: bsearch.h:48
pfc::array_t< entry > m_data
Definition: menu_helpers.h:53

Field Documentation

pfc::array_t<entry> menu_helpers::name_to_guid_table::m_data
private

Definition at line 53 of file menu_helpers.h.

bool menu_helpers::name_to_guid_table::m_inited
private

Definition at line 54 of file menu_helpers.h.


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