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

#include <menu_helpers.h>

Data Structures

struct  entry
 

Public Member Functions

 guid_to_name_table ()
 
 ~guid_to_name_table ()
 
const char * search (const GUID &p_guid)
 

Static Private Member Functions

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

Private Attributes

pfc::array_t< entrym_data
 
bool m_inited
 

Detailed Description

Definition at line 24 of file menu_helpers.h.


Data Structure Documentation

struct menu_helpers::guid_to_name_table::entry

Definition at line 31 of file menu_helpers.h.

Data Fields
GUID m_guid
char * m_name

Constructor & Destructor Documentation

menu_helpers::guid_to_name_table::guid_to_name_table ( )

Definition at line 173 of file menu_helpers.cpp.

174 {
175  m_inited = false;
176 }
menu_helpers::guid_to_name_table::~guid_to_name_table ( )

Definition at line 178 of file menu_helpers.cpp.

179 {
180  t_size n, m = m_data.get_size();
181  for(n=0;n<m;n++) free(m_data[n].m_name);
182 
183 }
size_t t_size
Definition: int_types.h:48
pfc::array_t< entry > m_data
Definition: menu_helpers.h:35

Member Function Documentation

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

Definition at line 168 of file menu_helpers.cpp.

169 {
170  return pfc::guid_compare(entry1.m_guid,entry2.m_guid);
171 }
int guid_compare(const GUID &g1, const GUID &g2)
Definition: guid.h:18
int menu_helpers::guid_to_name_table::entry_compare_search ( const entry entry1,
const GUID entry2 
)
staticprivate

Definition at line 163 of file menu_helpers.cpp.

164 {
165  return pfc::guid_compare(entry1.m_guid,entry2);
166 }
int guid_compare(const GUID &g1, const GUID &g2)
Definition: guid.h:18
const char * menu_helpers::guid_to_name_table::search ( const GUID p_guid)

Definition at line 128 of file menu_helpers.cpp.

129 {
130  if (!m_inited)
131  {
132  m_data.set_size(calc_total_action_count());
133  t_size dataptr = 0;
134  pfc::string8_fastalloc nametemp;
135 
138  while(e.next(ptr))
139  {
140  unsigned n, m = ptr->get_num_items();
141  for(n=0;n<m;n++)
142  {
143  assert(dataptr < m_data.get_size());
144 
145  ptr->get_item_name(n,nametemp);
146  m_data[dataptr].m_name = _strdup(nametemp);
147  m_data[dataptr].m_guid = ptr->get_item_guid(n);
148  dataptr++;
149  }
150  }
151  assert(dataptr == m_data.get_size());
152 
154  m_inited = true;
155  }
156  t_size index;
157  if (pfc::bsearch_t(m_data.get_size(),m_data,entry_compare_search,p_guid,index))
158  return m_data[index].m_name;
159  else
160  return 0;
161 }
static int entry_compare(const entry &entry1, const 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
pfc::array_t< entry > m_data
Definition: menu_helpers.h:35
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
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
static int entry_compare_search(const entry &entry1, const GUID &entry2)

Field Documentation

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

Definition at line 35 of file menu_helpers.h.

bool menu_helpers::guid_to_name_table::m_inited
private

Definition at line 36 of file menu_helpers.h.


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