foobar2000 SDK  2015-08-03
Functions | Variables
file_info_merge.cpp File Reference

Go to the source code of this file.

Functions

static void merge_meta (file_info &p_out, const pfc::list_base_const_t< const file_info * > &p_in)
 
static t_size merge_tags_calc_rating (const file_info &p_info, const char *p_field)
 
static t_size merge_tags_calc_rating_by_index (const file_info &p_info, t_size p_index)
 
static void merge_tags_copy_info (const char *field, const file_info *from, file_info *to)
 

Variables

static const char _tagtype [] = "tagtype"
 

Function Documentation

static void merge_meta ( file_info p_out,
const pfc::list_base_const_t< const file_info * > &  p_in 
)
static

Definition at line 52 of file file_info_merge.cpp.

52  {
54  for(t_size in_walk = 0; in_walk < p_in.get_count(); in_walk++) {
55  const file_info & in = * p_in[in_walk];
56  for(t_size meta_walk = 0, meta_count = in.meta_get_count(); meta_walk < meta_count; meta_walk++ ) {
57  meta_merge_entry & entry = map.find_or_add(in.meta_enum_name(meta_walk));
58  t_size rating = merge_tags_calc_rating_by_index(in,meta_walk);
59  if (rating > entry.m_rating) {
60  entry.m_rating = rating;
61  const t_size value_count = in.meta_enum_value_count(meta_walk);
62  entry.m_data.set_size(value_count);
63  for(t_size value_walk = 0; value_walk < value_count; value_walk++ ) {
64  entry.m_data[value_walk] = in.meta_enum_value(meta_walk,value_walk);
65  }
66  }
67  }
68  }
69 
70  meta_merge_map_enumerator en(p_out);
71  map.enumerate(en);
72 }
Definition: map.h:16
void enumerate(t_callback &p_callback) const
Definition: map.h:125
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...
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...
static t_size merge_tags_calc_rating_by_index(const file_info &p_info, t_size p_index)
t_storage_value & find_or_add(_t_key const &p_key)
Definition: map.h:29
Main interface class for information about some playable object.
Definition: file_info.h:73
size_t t_size
Definition: int_types.h:48
virtual t_size get_count() const =0
virtual t_size meta_get_count() const =0
Retrieves count of metadata entries.
virtual const char * meta_enum_name(t_size p_index) const =0
Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 enco...
static t_size merge_tags_calc_rating ( const file_info p_info,
const char *  p_field 
)
static

Definition at line 11 of file file_info_merge.cpp.

11  {
12  t_size field_index = p_info.meta_find(p_field);
13  if (field_index != ~0) {
14  return merge_tags_calc_rating_by_index(p_info,field_index);
15  } else {
16  return 0;
17  }
18 }
static t_size merge_tags_calc_rating_by_index(const file_info &p_info, t_size p_index)
size_t t_size
Definition: int_types.h:48
t_size meta_find(const char *p_name) const
Definition: file_info.h:154
static t_size merge_tags_calc_rating_by_index ( const file_info p_info,
t_size  p_index 
)
static

Definition at line 3 of file file_info_merge.cpp.

3  {
4  t_size n,m = p_info.meta_enum_value_count(p_index);
5  t_size ret = 0;
6  for(n=0;n<m;n++)
7  ret += strlen(p_info.meta_enum_value(p_index,n)) + 10;//yes, strlen on utf8 data, plus a slight bump to prefer multivalue over singlevalue w/ separator
8  return ret;
9 }
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...
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...
size_t t_size
Definition: int_types.h:48
static void merge_tags_copy_info ( const char *  field,
const file_info from,
file_info to 
)
static

Definition at line 20 of file file_info_merge.cpp.

21 {
22  const char * val = from->info_get(field);
23  if (val) to->info_set(field,val);
24 }
const char * info_get(const char *p_name) const
Definition: file_info.h:171
t_size info_set(const char *p_name, const char *p_value)
Definition: file_info.h:167

Variable Documentation

const char _tagtype[] = "tagtype"
static

Definition at line 149 of file file_info_merge.cpp.