foobar2000 SDK  2015-08-03
file_info_impl.cpp
Go to the documentation of this file.
1 #include "foobar2000.h"
2 
3 
5 {
6  return m_meta.get_count();
7 }
8 
9 const char* file_info_impl::meta_enum_name(t_size p_index) const
10 {
11  return m_meta.get_name(p_index);
12 }
13 
15 {
16  return m_meta.get_value_count(p_index);
17 }
18 
19 const char* file_info_impl::meta_enum_value(t_size p_index,t_size p_value_number) const
20 {
21  return m_meta.get_value(p_index,p_value_number);
22 }
23 
24 t_size file_info_impl::meta_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length)
25 {
26  meta_remove_field_ex(p_name,p_name_length);
27  return meta_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);
28 }
29 
30 t_size file_info_impl::meta_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length)
31 {
32  return m_meta.add_entry(p_name,p_name_length,p_value,p_value_length);
33 }
34 
35 void file_info_impl::meta_insert_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length)
36 {
37  m_meta.insert_value(p_index,p_value_index,p_value,p_value_length);
38 }
39 
41 {
42  m_meta.remove_mask(p_mask);
43 }
44 
45 void file_info_impl::meta_reorder(const t_size * p_order)
46 {
47  m_meta.reorder(p_order);
48 }
49 
51 {
52  m_meta.remove_values(p_index,p_mask);
53  if (m_meta.get_value_count(p_index) == 0)
55 }
56 
58 {
59  return m_info.get_count();
60 }
61 
62 const char* file_info_impl::info_enum_name(t_size p_index) const
63 {
64  return m_info.get_name(p_index);
65 }
66 
67 const char* file_info_impl::info_enum_value(t_size p_index) const
68 {
69  return m_info.get_value(p_index);
70 }
71 
72 t_size file_info_impl::info_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length)
73 {
74  info_remove_ex(p_name,p_name_length);
75  return info_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);
76 }
77 
78 t_size file_info_impl::info_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length)
79 {
80  return m_info.add_item(p_name,p_name_length,p_value,p_value_length);
81 }
82 
84 {
85  m_info.remove_mask(p_mask);
86 }
87 
88 
90 {
91  copy(p_source);
92 }
93 
95 {
96  copy(p_source);
97 }
98 
100 {
101  copy(p_source);
102  return *this;
103 }
104 
106 {
108 }
109 
111 {
112  return m_length;
113 }
114 
115 void file_info_impl::set_length(double p_length)
116 {
117  m_length = p_length;
118 }
119 
120 void file_info_impl::meta_modify_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length)
121 {
122  m_meta.modify_value(p_index,p_value_index,p_value,p_value_length);
123 }
124 
126 {
127  return m_replaygain;
128 }
129 
131 {
132  m_replaygain = p_info;
133 }
134 
135 
136 
137 
139 {
140 }
141 
142 t_size file_info_impl_utils::info_storage::add_item(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) {
143  t_size index = m_info.get_size();
144  m_info.set_size(index + 1);
145  m_info[index].init(p_name,p_name_length,p_value,p_value_length);
146  return index;
147 }
148 
150  pfc::remove_mask_t(m_info,p_mask);
151 }
152 
153 
154 
155 t_size file_info_impl_utils::meta_storage::add_entry(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length)
156 {
157  meta_entry temp(p_name,p_name_length,p_value,p_value_length);
158  return pfc::append_swap_t(m_data,temp);
159 }
160 
161 void file_info_impl_utils::meta_storage::insert_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length)
162 {
163  m_data[p_index].insert_value(p_value_index,p_value,p_value_length);
164 }
165 
166 void file_info_impl_utils::meta_storage::modify_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length)
167 {
168  m_data[p_index].modify_value(p_value_index,p_value,p_value_length);
169 }
170 
172 {
173  m_data[p_index].remove_values(p_mask);
174 }
175 
177 {
178  pfc::remove_mask_t(m_data,p_mask);
179 }
180 
181 
182 file_info_impl_utils::meta_entry::meta_entry(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len)
183 {
184  m_name.set_string(p_name,p_name_len);
185  m_values.set_size(1);
186  m_values[0].set_string(p_value,p_value_len);
187 }
188 
189 
191 {
192  pfc::remove_mask_t(m_values,p_mask);
193 }
194 
195 void file_info_impl_utils::meta_entry::insert_value(t_size p_value_index,const char * p_value,t_size p_value_length)
196 {
197  pfc::string_simple temp;
198  temp.set_string(p_value,p_value_length);
199  pfc::insert_t(m_values,temp,p_value_index);
200 }
201 
202 void file_info_impl_utils::meta_entry::modify_value(t_size p_value_index,const char * p_value,t_size p_value_length)
203 {
204  m_values[p_value_index].set_string(p_value,p_value_length);
205 }
206 
208 {
209  pfc::reorder_t(m_data,p_order,m_data.get_size());
210 }
211 
212 void file_info_impl::copy_meta(const file_info & p_source)
213 {
214  m_meta.copy_from(p_source);
215 }
216 
217 void file_info_impl::copy_info(const file_info & p_source)
218 {
219  m_info.copy_from(p_source);
220 }
221 
223 {
224  t_size meta_index,meta_count = p_info.meta_get_count();
225  m_data.set_size(meta_count);
226  for(meta_index=0;meta_index<meta_count;meta_index++)
227  {
228  meta_entry & entry = m_data[meta_index];
229  t_size value_index,value_count = p_info.meta_enum_value_count(meta_index);
230  entry.m_name = p_info.meta_enum_name(meta_index);
231  entry.m_values.set_size(value_count);
232  for(value_index=0;value_index<value_count;value_index++)
233  entry.m_values[value_index] = p_info.meta_enum_value(meta_index,value_index);
234  }
235 }
236 
238 {
239  t_size n, count;
240  count = p_info.info_get_count();
241  m_info.set_count(count);
242  for(n=0;n<count;n++) m_info[n].init(p_info.info_enum_name(n),~0,p_info.info_enum_value(n),~0);
243 }
const char * info_enum_name(t_size p_index) const
Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded...
const char * get_name(t_size p_index) const
meta_value_array m_values
void insert_value(t_size p_index, t_size p_value_index, const char *p_value, t_size p_value_length)
replaygain_info get_replaygain() const
Retrieves ReplayGain information.
void set_replaygain(const replaygain_info &p_info)
Sets ReplayGain information.
t_size info_get_count() const
Retrieves number of technical info entries.
file_info_impl_utils::meta_storage m_meta
double get_length() const
Retrieves audio duration, in seconds. Note that the reported duration should not be assumed to be th...
void remove_values(const bit_array &p_mask)
void insert_value(t_size p_value_index, const char *p_value, t_size p_value_length)
void remove_values(t_size p_index, const bit_array &p_mask)
void meta_reorder(const t_size *p_order)
Reorders metadata entries according to specified permutation.
const file_info_impl & operator=(const file_info_impl &p_source)
Bit array interface class, constant version (you can only retrieve values). Range of valid indexes d...
Definition: bit_array.h:6
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...
const char * get_value(t_size p_index, t_size p_value_index) const
void copy_meta(const file_info &p_source)
Copies metadata from specified file_info object.
void meta_remove_field_ex(const char *p_name, t_size p_name_length)
Definition: file_info.cpp:23
virtual const char * info_enum_value(t_size p_index) const =0
Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encode...
t_size meta_get_count() const
Retrieves count of metadata entries.
t_size remove_mask_t(t_array &p_array, const bit_array &p_mask)
Definition: primitives.h:719
const char * meta_enum_name(t_size p_index) const
Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 enco...
t_size get_value_count(t_size p_index) const
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...
void meta_remove_mask(const bit_array &p_mask)
Removes metadata entries according to specified bit mask.
void reorder_t(t_container &p_data, const t_size *p_order, t_size p_count)
Definition: sort.h:42
void copy_from(const file_info &p_info)
const char * info_enum_value(t_size p_index) const
Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encode...
Structure containing ReplayGain scan results from some playable object, also providing various helper...
Definition: file_info.h:2
pfc::string_simple m_name
file_info_impl_utils::info_storage m_info
bool info_remove_ex(const char *p_name, t_size p_name_length)
Definition: file_info.cpp:76
Main interface class for information about some playable object.
Definition: file_info.h:73
virtual void copy(const file_info &p_source)
Copies entire file_info contents from specified file_info object.
Definition: file_info.cpp:166
string_simple_t< char > string_simple
Definition: string_base.h:826
void modify_value(t_size p_index, t_size p_value_index, const char *p_value, t_size p_value_length)
size_t t_size
Definition: int_types.h:48
void set_size(t_size p_size)
Definition: array.h:104
const char * get_value(t_size p_index) const
virtual t_size meta_get_count() const =0
Retrieves count of metadata entries.
void remove_mask(const bit_array &p_mask)
t_size meta_set_nocheck_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)
t_size append_swap_t(t_array &p_array, T &p_item)
Definition: primitives.h:482
void copy_from(const file_info &p_info)
t_size add_entry(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)
t_size info_set_nocheck_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)
const char * get_name(t_size p_index) const
t_size meta_enum_value_count(t_size p_index) const
Retrieves count of values in metadata entry of specified index. The value is always equal to or great...
void meta_insert_value_ex(t_size p_index, t_size p_value_index, const char *p_value, t_size p_value_length)
Inserts a new value into specified metadata entry.
void copy_info(const file_info &p_source)
Copies technical info from specified file_info object.
t_size info_set_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)
Creates a new technical info entry with specified name and specified value. If an entry of the same n...
t_size add_item(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)
void reorder(const t_size *p_order)
replaygain_info m_replaygain
void remove_mask(const bit_array &p_mask)
void set_length(double p_length)
Sets audio duration, in seconds. Note that the reported duration should not be assumed to be the exa...
const char * meta_enum_value(t_size p_index, t_size p_value_number) const
Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 enco...
t_size meta_set_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)
Creates a new metadata entry of specified name with specified value. If an entry of same name already...
Implements file_info.
void meta_modify_value_ex(t_size p_index, t_size p_value_index, const char *p_value, t_size p_value_length)
Alters specified value in specified metadata entry.
void info_remove_mask(const bit_array &p_mask)
Removes technical info entries indicated by specified bit mask.
void meta_remove_values(t_size p_index, const bit_array &p_mask)
Removes values according to specified bit mask from specified metadata entry. If all values are remov...
meta_entry()
t_size insert_t(t_array &p_array, const T &p_item, t_size p_index)
Definition: primitives.h:500
virtual const char * info_enum_name(t_size p_index) const =0
Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded...
virtual t_size info_get_count() const =0
Retrieves number of technical info entries.
void modify_value(t_size p_value_index, const char *p_value, t_size p_value_length)
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...