foobar2000 SDK  2015-01-14
file_info_impl.h
Go to the documentation of this file.
1 #ifndef _FOOBAR2000_SDK_FILE_INFO_IMPL_H_
2 #define _FOOBAR2000_SDK_FILE_INFO_IMPL_H_
3 
5 
6  struct info_entry {
7  void init(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len) {
8  m_name.set_string(p_name,p_name_len);
9  m_value.set_string(p_value,p_value_len);
10  }
11 
12  inline const char * get_name() const {return m_name;}
13  inline const char * get_value() const {return m_value;}
14 
16  };
17 
19 
20 }
21 
22 namespace pfc {
23  template<> class traits_t<file_info_impl_utils::info_entry> : public traits_t<pfc::string_simple> {};
24 };
25 
26 
27 namespace file_info_impl_utils {
29  {
30  public:
31  t_size add_item(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
32  void remove_mask(const bit_array & p_mask);
33  inline t_size get_count() const {return m_info.get_count();}
34  inline const char * get_name(t_size p_index) const {return m_info[p_index].get_name();}
35  inline const char * get_value(t_size p_index) const {return m_info[p_index].get_value();}
36  void copy_from(const file_info & p_info);
37  private:
39  };
40 }
41 
42 
43 namespace file_info_impl_utils {
45  struct meta_entry {
47  meta_entry(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len);
48 
49  void remove_values(const bit_array & p_mask);
50  void insert_value(t_size p_value_index,const char * p_value,t_size p_value_length);
51  void modify_value(t_size p_value_index,const char * p_value,t_size p_value_length);
52 
53  inline const char * get_name() const {return m_name;}
54  inline const char * get_value(t_size p_index) const {return m_values[p_index];}
55  inline t_size get_value_count() const {return m_values.get_size();}
56 
57 
59  meta_value_array m_values;
60  };
62 }
63 namespace pfc {
64  template<> class traits_t<file_info_impl_utils::meta_entry> : public pfc::traits_combined<pfc::string_simple,file_info_impl_utils::meta_value_array> {};
65 }
66 
67 
68 namespace file_info_impl_utils {
70  {
71  public:
72  t_size add_entry(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
73  void insert_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length);
74  void modify_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length);
75  void remove_values(t_size p_index,const bit_array & p_mask);
76  void remove_mask(const bit_array & p_mask);
77  void copy_from(const file_info & p_info);
78 
79  inline void reorder(const t_size * p_order);
80 
81  inline t_size get_count() const {return m_data.get_size();}
82 
83  inline const char * get_name(t_size p_index) const {PFC_ASSERT(p_index < m_data.get_size()); return m_data[p_index].get_name();}
84  inline const char * get_value(t_size p_index,t_size p_value_index) const {PFC_ASSERT(p_index < m_data.get_size()); return m_data[p_index].get_value(p_value_index);}
85  inline t_size get_value_count(t_size p_index) const {PFC_ASSERT(p_index < m_data.get_size()); return m_data[p_index].get_value_count();}
86 
87  private:
89  };
90 }
91 
93 class file_info_impl : public file_info
94 {
95 public:
96  file_info_impl(const file_info_impl & p_source);
97  file_info_impl(const file_info & p_source);
100 
101  double get_length() const;
102  void set_length(double p_length);
103 
104  void copy_meta(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass
105  void copy_info(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass
106 
107  t_size meta_get_count() const;
108  const char* meta_enum_name(t_size p_index) const;
109  t_size meta_enum_value_count(t_size p_index) const;
110  const char* meta_enum_value(t_size p_index,t_size p_value_number) const;
111  t_size meta_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
112  void meta_insert_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length);
113  void meta_remove_mask(const bit_array & p_mask);
114  void meta_reorder(const t_size * p_order);
115  void meta_remove_values(t_size p_index,const bit_array & p_mask);
116  void meta_modify_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length);
117 
118  t_size info_get_count() const;
119  const char* info_enum_name(t_size p_index) const;
120  const char* info_enum_value(t_size p_index) const;
121  t_size info_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
122  void info_remove_mask(const bit_array & p_mask);
123 
124  const file_info_impl & operator=(const file_info_impl & p_source);
125 
127  void set_replaygain(const replaygain_info & p_info);
128 
129 protected:
130  t_size meta_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
131  t_size info_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
132 private:
133 
134 
137 
138 
139  double m_length;
140 
142 };
143 
144 #endif
Definition: file_info_impl.h:6
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_value(t_size p_index) const
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)
pfc::array_hybrid_t< pfc::string_simple, 1, pfc::alloc_fast > meta_value_array
Bit array interface class, constant version (you can only retrieve values). Range of valid indexes d...
Definition: bit_array.h:6
const char * get_value(t_size p_index, t_size p_value_index) const
const char * get_name() const
const char * get_name() const
void copy_meta(const file_info &p_source)
Copies metadata from specified file_info object.
t_size meta_get_count() const
Retrieves count of metadata entries.
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
void meta_remove_mask(const bit_array &p_mask)
Removes metadata entries according to specified bit mask.
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
t_size get_value_count() const
file_info_impl_utils::info_storage m_info
pfc::string_simple m_value
Main interface class for information about some playable object.
Definition: file_info.h:73
string_simple_t< char > string_simple
Definition: string_base.h:824
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 init(const char *p_name, t_size p_name_len, const char *p_value, t_size p_value_len)
Definition: file_info_impl.h:7
pfc::array_t< info_entry, pfc::alloc_fast > info_entry_array
const char * get_value(t_size p_index) const
void remove_mask(const bit_array &p_mask)
const char * get_value() const
t_size meta_set_nocheck_ex(const char *p_name, t_size p_name_length, const char *p_value, t_size p_value_length)
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...
t_size get_count() const
Definition: array.h:131
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.
pfc::string_simple m_name
pfc::array_hybrid_t< meta_entry, 10, pfc::alloc_fast > meta_entry_array
void info_remove_mask(const bit_array &p_mask)
Removes technical info entries indicated by specified bit mask.
t_size get_size() const
Definition: array.h:130
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()
void modify_value(t_size p_value_index, const char *p_value, t_size p_value_length)