foobar2000 SDK  2015-08-03
Public Types | Public Member Functions | Private Member Functions | Private Attributes
meta_table_builder

#include <meta_table_builder.h>

Public Types

typedef pfc::map_t< pfc::string8, t_entry, file_info::field_name_comparatort_content
 
typedef pfc::chain_list_v2_t< pfc::string8t_entry
 

Public Member Functions

void add (const char *p_name, const char *p_value, t_size p_value_len=~0)
 
t_entryadd (const char *p_name)
 
t_contentcontent ()
 
t_content const & content () const
 
void deduplicate (const char *name)
 
void finalize (file_info &p_info) const
 
void finalize_withRG (file_info &p_info) const
 
void fix_itunes_compilation ()
 
void from_info (const file_info &p_info)
 
void from_info_overwrite (const file_info &p_info)
 
void from_info_withRG (const file_info &p_info)
 
void from_RG_overwrite (replaygain_info info)
 
void keep_one (const char *name)
 
void remove (const char *p_name)
 
void reset ()
 
void set (const char *p_name, const char *p_value, t_size p_value_len=~0)
 
void tidy_VorbisComment ()
 

Private Member Functions

t_entry_add (const char *p_name)
 

Private Attributes

t_content m_data
 

Detailed Description

Purpose: building a file_info metadata table from loose input without search-for-existing-entry bottleneck.

Definition at line 36 of file meta_table_builder.h.

Member Typedef Documentation

Definition at line 39 of file meta_table_builder.h.

Definition at line 38 of file meta_table_builder.h.

Member Function Documentation

t_entry& meta_table_builder::_add ( const char *  p_name)
inlineprivate

Definition at line 136 of file meta_table_builder.h.

136  {
137  return m_data.find_or_add(p_name);
138  }
t_storage_value & find_or_add(_t_key const &p_key)
Definition: map.h:29
void meta_table_builder::add ( const char *  p_name,
const char *  p_value,
t_size  p_value_len = ~0 
)
inline

Definition at line 44 of file meta_table_builder.h.

44  {
46  _add(p_name).insert_last()->set_string(p_value,p_value_len);
47  }
48  }
t_entry & _add(const char *p_name)
static bool g_is_valid_field_name(const char *p_name, t_size p_length=pfc_infinite)
Definition: file_info.cpp:498
t_entry& meta_table_builder::add ( const char *  p_name)
inline

Definition at line 60 of file meta_table_builder.h.

60  {
61  if (!file_info::g_is_valid_field_name(p_name)) uBugCheck();//we return a reference, nothing smarter to do
62  return _add(p_name);
63  }
t_entry & _add(const char *p_name)
static bool g_is_valid_field_name(const char *p_name, t_size p_length=pfc_infinite)
Definition: file_info.cpp:498
PFC_NORETURN void SHARED_EXPORT uBugCheck()
t_content& meta_table_builder::content ( )
inline

Definition at line 41 of file meta_table_builder.h.

41 {return m_data;}
t_content const& meta_table_builder::content ( ) const
inline

Definition at line 42 of file meta_table_builder.h.

42 {return m_data;}
void meta_table_builder::deduplicate ( const char *  name)
inline

Definition at line 64 of file meta_table_builder.h.

64  {
65  t_entry * e;
66  if (!m_data.query_ptr(name, e)) return;
68  for(t_entry::iterator iter = e->first(); iter.is_valid(); ) {
69  t_entry::iterator next = iter; ++next;
70  const char * v = *iter;
71  if (!found.add_item_check(v)) e->remove(iter);
72  iter = next;
73  }
74  }
bool add_item_check(t_param const &item)
Returns true when the list has been altered, false when the item was already present before...
Definition: avltree.h:393
::pfc::iterator< t_item > iterator
Definition: chain_list_v2.h:30
const t_storage_value * query_ptr(const _t_key &p_key) const
Definition: map.h:64
void meta_table_builder::finalize ( file_info p_info) const
inline

Definition at line 86 of file meta_table_builder.h.

86  {
87  p_info.meta_remove_all();
88  _meta_table_enum_wrapper e(p_info);
89  m_data.enumerate(e);
90  }
void enumerate(t_callback &p_callback) const
Definition: map.h:125
void meta_remove_all()
Definition: file_info.cpp:35
void meta_table_builder::finalize_withRG ( file_info p_info) const
inline

Definition at line 91 of file meta_table_builder.h.

91  {
94  m_data.enumerate(e);
95  }
void enumerate(t_callback &p_callback) const
Definition: map.h:125
static const replaygain_info replaygain_info_invalid
Definition: file_info.h:69
virtual void set_replaygain(const replaygain_info &p_info)=0
Sets ReplayGain information.
void meta_remove_all()
Definition: file_info.cpp:35
void meta_table_builder::fix_itunes_compilation ( )
inline

Definition at line 127 of file meta_table_builder.h.

127  {
128  static const char cmp[] = "itunescompilation";
129  if (m_data.have_item(cmp)) {
130  // m_data.remove(cmp);
131  if (!m_data.have_item("album artist")) add("album artist", "Various Artists");
132  }
133  }
void add(const char *p_name, const char *p_value, t_size p_value_len=~0)
bool have_item(const _t_key &p_key) const
Definition: map.h:39
void meta_table_builder::from_info ( const file_info p_info)
inline

Definition at line 97 of file meta_table_builder.h.

97  {
99  from_info_overwrite(p_info);
100  }
void remove_all()
Definition: map.h:139
void from_info_overwrite(const file_info &p_info)
void meta_table_builder::from_info_overwrite ( const file_info p_info)
inline

Definition at line 113 of file meta_table_builder.h.

113  {
114  for(t_size metawalk = 0, metacount = p_info.meta_get_count(); metawalk < metacount; ++metawalk ) {
115  const t_size valuecount = p_info.meta_enum_value_count(metawalk);
116  if (valuecount > 0) {
117  t_entry & entry = add(p_info.meta_enum_name(metawalk));
118  entry.remove_all();
119  for(t_size valuewalk = 0; valuewalk < valuecount; ++valuewalk) {
120  entry.insert_last(p_info.meta_enum_value(metawalk,valuewalk));
121  }
122  }
123  }
124  }
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
virtual t_size meta_get_count() const =0
Retrieves count of metadata entries.
void add(const char *p_name, const char *p_value, t_size p_value_len=~0)
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...
void meta_table_builder::from_info_withRG ( const file_info p_info)
inline

Definition at line 101 of file meta_table_builder.h.

101  {
102  m_data.remove_all();
103  from_info_overwrite(p_info);
105  }
void from_RG_overwrite(replaygain_info info)
void remove_all()
Definition: map.h:139
virtual replaygain_info get_replaygain() const =0
Retrieves ReplayGain information.
void from_info_overwrite(const file_info &p_info)
void meta_table_builder::from_RG_overwrite ( replaygain_info  info)
inline

Definition at line 106 of file meta_table_builder.h.

106  {
108  if (info.format_album_gain(buffer)) set("replaygain_album_gain", buffer);
109  if (info.format_track_gain(buffer)) set("replaygain_track_gain", buffer);
110  if (info.format_album_peak(buffer)) set("replaygain_album_peak", buffer);
111  if (info.format_track_peak(buffer)) set("replaygain_track_peak", buffer);
112  }
bool format_track_gain(char p_buffer[text_buffer_size]) const
Definition: file_info.h:16
bool format_album_peak(char p_buffer[text_buffer_size]) const
Definition: file_info.h:17
bool format_track_peak(char p_buffer[text_buffer_size]) const
Definition: file_info.h:18
bool format_album_gain(char p_buffer[text_buffer_size]) const
Definition: file_info.h:15
char t_text_buffer[text_buffer_size]
Definition: file_info.h:8
void meta_table_builder::keep_one ( const char *  name)
inline

Definition at line 75 of file meta_table_builder.h.

75  {
76  t_entry * e;
77  if (!m_data.query_ptr(name, e)) return;
78  while(e->get_count() > 1) e->remove(e->last());
79  }
const t_storage_value * query_ptr(const _t_key &p_key) const
Definition: map.h:64
void meta_table_builder::remove ( const char *  p_name)
inline

Definition at line 50 of file meta_table_builder.h.

50  {
51  m_data.remove(p_name);
52  }
bool remove(const _t_key &p_key)
Definition: map.h:120
void meta_table_builder::reset ( )
inline

Definition at line 125 of file meta_table_builder.h.

125 {m_data.remove_all();}
void remove_all()
Definition: map.h:139
void meta_table_builder::set ( const char *  p_name,
const char *  p_value,
t_size  p_value_len = ~0 
)
inline

Definition at line 53 of file meta_table_builder.h.

53  {
55  t_entry & entry = _add(p_name);
56  entry.remove_all();
57  entry.insert_last()->set_string(p_value,p_value_len);
58  }
59  }
t_entry & _add(const char *p_name)
static bool g_is_valid_field_name(const char *p_name, t_size p_length=pfc_infinite)
Definition: file_info.cpp:498
void meta_table_builder::tidy_VorbisComment ( )
inline

Definition at line 80 of file meta_table_builder.h.

80  {
81  deduplicate("album artist");
82  deduplicate("publisher");
83  keep_one("totaltracks");
84  keep_one("totaldiscs");
85  }
void keep_one(const char *name)
void deduplicate(const char *name)

Field Documentation

t_content meta_table_builder::m_data
private

Definition at line 140 of file meta_table_builder.h.


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