foobar2000 SDK  2015-08-03
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);
99  ~file_info_impl();
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 
126  replaygain_info get_replaygain() const;
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 * get_value(t_size p_index) const
const char * get_name(t_size p_index) const
meta_value_array m_values
void reorder(reorder_callback &p_callback, const t_size *p_order, t_size p_count)
Definition: sort.cpp:25
file_info_impl_utils::meta_storage m_meta
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
t_size get_value_count(t_size p_index) const
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:826
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
const char * get_value() const
const char * get_name(t_size p_index) const
replaygain_info m_replaygain
Implements file_info.
pfc::string_simple m_name
pfc::array_hybrid_t< meta_entry, 10, pfc::alloc_fast > meta_entry_array
meta_entry()