foobar2000 SDK  2015-08-03
Functions
cue_parser_embedding.cpp File Reference

Go to the source code of this file.

Functions

static void build_cue_meta_name (const char *p_name, unsigned p_tracknumber, pfc::string_base &p_out)
 
static bool is_allowed_field (const char *p_name)
 
static bool is_global_meta_entry (const char *p_name)
 
static bool is_reserved_meta_entry (const char *p_name)
 
static bool resolve_cue_meta_name (const char *p_name, pfc::string_base &p_outname, unsigned &p_tracknumber)
 
static void strip_redundant_track_meta (unsigned p_tracknumber, const file_info &p_cueinfo, file_info_record::t_meta_map &p_meta, const char *p_metaname)
 

Function Documentation

static void build_cue_meta_name ( const char *  p_name,
unsigned  p_tracknumber,
pfc::string_base p_out 
)
static

Definition at line 5 of file cue_parser_embedding.cpp.

5  {
6  p_out.reset();
7  p_out << "cue_track" << pfc::format_uint(p_tracknumber % 100,2) << "_" << p_name;
8 }
static bool is_allowed_field ( const char *  p_name)
static

Definition at line 18 of file cue_parser_embedding.cpp.

18  {
19  return !is_reserved_meta_entry(p_name) && is_global_meta_entry(p_name);
20 }
static bool is_global_meta_entry(const char *p_name)
static bool is_reserved_meta_entry(const char *p_name)
static bool is_global_meta_entry ( const char *  p_name)
static

Definition at line 14 of file cue_parser_embedding.cpp.

14  {
15  static const char header[] = "cue_track";
16  return pfc::stricmp_ascii_ex(p_name,strlen(header),header,~0) != 0;
17 }
int stricmp_ascii_ex(const char *const s1, t_size const len1, const char *const s2, t_size const len2)
static bool is_reserved_meta_entry ( const char *  p_name)
static

Definition at line 10 of file cue_parser_embedding.cpp.

10  {
11  return file_info::field_name_comparator::compare(p_name,"cuesheet") == 0;
12 }
static int compare(T1 const &v1, T2 const &v2)
Definition: stringNew.h:181
static bool resolve_cue_meta_name ( const char *  p_name,
pfc::string_base p_outname,
unsigned &  p_tracknumber 
)
static

Definition at line 203 of file cue_parser_embedding.cpp.

203  {
204  //"cue_trackNN_fieldname"
205  static const char header[] = "cue_track";
206  if (pfc::stricmp_ascii_ex(p_name,strlen(header),header,~0) != 0) return false;
207  p_name += strlen(header);
208  if (!pfc::char_is_numeric(p_name[0]) || !pfc::char_is_numeric(p_name[1]) || p_name[2] != '_') return false;
209  unsigned tracknumber = pfc::atoui_ex(p_name,2);
210  if (tracknumber == 0) return false;
211  p_name += 3;
212  p_tracknumber = tracknumber;
213  p_outname = p_name;
214  return true;
215 }
int stricmp_ascii_ex(const char *const s1, t_size const len1, const char *const s2, t_size const len2)
unsigned atoui_ex(const char *p_string, t_size p_string_len)
bool char_is_numeric(char_t p_char)
Definition: string_base.h:99
static void strip_redundant_track_meta ( unsigned  p_tracknumber,
const file_info p_cueinfo,
file_info_record::t_meta_map p_meta,
const char *  p_metaname 
)
static

Definition at line 125 of file cue_parser_embedding.cpp.

125  {
126  t_size metaindex = p_cueinfo.meta_find(p_metaname);
127  if (metaindex == ~0) return;
128  pfc::string_formatter namelocal;
129  build_cue_meta_name(p_metaname,p_tracknumber,namelocal);
130  {
131  const file_info_record::t_meta_value * val = p_meta.query_ptr(namelocal);
132  if (val == NULL) return;
134  for(t_size valwalk = 0, valcount = p_cueinfo.meta_enum_value_count(metaindex); valwalk < valcount; ++valwalk) {
135  if (iter.is_empty()) return;
136  if (strcmp(*iter,p_cueinfo.meta_enum_value(metaindex,valwalk)) != 0) return;
137  ++iter;
138  }
139  if (!iter.is_empty()) return;
140  }
141  //success
142  p_meta.remove(namelocal);
143 }
virtual t_size meta_enum_value_count(t_size p_index) const =0
Retrieves count of values in metadata entry of specified index. The value is always equal to or great...
Differences between chain_list_v2_t<> and old chain_list_t<>: Iterators pointing to removed items as...
Definition: chain_list_v2.h:26
virtual const char * meta_enum_value(t_size p_index, t_size p_value_number) const =0
Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 enco...
const t_storage_value * query_ptr(const _t_key &p_key) const
Definition: map.h:64
size_t t_size
Definition: int_types.h:48
string8_fastalloc string_formatter
Definition: string_base.h:615
bool remove(const _t_key &p_key)
Definition: map.h:120
bool is_empty() const
Definition: iterators.h:23
static void build_cue_meta_name(const char *p_name, unsigned p_tracknumber, pfc::string_base &p_out)
t_size meta_find(const char *p_name) const
Definition: file_info.h:154