comparison foosdk/sdk/foobar2000/SDK/file_info_impl.h @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
comparison
equal deleted inserted replaced
0:e9bb126753e7 1:20d02a178406
1 #pragma once
2
3 #include <pfc/array.h>
4 #include "file_info.h"
5
6 namespace file_info_impl_utils {
7
8 struct info_entry {
9 void init(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len) {
10 m_name.set_string(p_name,p_name_len);
11 m_value.set_string(p_value,p_value_len);
12 }
13
14 inline const char * get_name() const {return m_name;}
15 inline const char * get_value() const {return m_value;}
16
17 pfc::string_simple m_name,m_value;
18 };
19
20 typedef pfc::array_t<info_entry,pfc::alloc_fast> info_entry_array;
21
22 }
23
24 namespace pfc {
25 template<> class traits_t<file_info_impl_utils::info_entry> : public traits_t<pfc::string_simple> {};
26 };
27
28
29 namespace file_info_impl_utils {
30 class info_storage
31 {
32 public:
33 t_size add_item(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
34 void remove_mask(const bit_array & p_mask);
35 inline t_size get_count() const {return m_info.get_count();}
36 inline const char * get_name(t_size p_index) const {return m_info[p_index].get_name();}
37 inline const char * get_value(t_size p_index) const {return m_info[p_index].get_value();}
38 void copy_from(const file_info & p_info);
39 private:
40 info_entry_array m_info;
41 };
42 }
43
44
45 namespace file_info_impl_utils {
46 typedef pfc::array_hybrid_t<pfc::string_simple,1,pfc::alloc_fast > meta_value_array;
47 struct meta_entry {
48 meta_entry() {}
49 meta_entry(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len);
50
51 void remove_values(const bit_array & p_mask);
52 void insert_value(t_size p_value_index,const char * p_value,t_size p_value_length);
53 void modify_value(t_size p_value_index,const char * p_value,t_size p_value_length);
54
55 inline const char * get_name() const {return m_name;}
56 inline const char * get_value(t_size p_index) const {return m_values[p_index];}
57 inline t_size get_value_count() const {return m_values.get_size();}
58
59
60 pfc::string_simple m_name;
61 meta_value_array m_values;
62 };
63 typedef pfc::array_hybrid_t<meta_entry,10, pfc::alloc_fast> meta_entry_array;
64 }
65 namespace pfc {
66 template<> class traits_t<file_info_impl_utils::meta_entry> : public pfc::traits_combined<pfc::string_simple,file_info_impl_utils::meta_value_array> {};
67 }
68
69
70 namespace file_info_impl_utils {
71 class meta_storage
72 {
73 public:
74 size_t add_blank(const char* name);
75 t_size add_entry(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
76 void insert_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length);
77 void modify_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length);
78 void remove_values(t_size p_index,const bit_array & p_mask);
79 void remove_mask(const bit_array & p_mask);
80 void copy_from(const file_info & p_info);
81
82 inline void reorder(const t_size * p_order);
83
84 inline t_size get_count() const {return m_data.get_size();}
85
86 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();}
87 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);}
88 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();}
89
90 private:
91 meta_entry_array m_data;
92 };
93 }
94
95 //! Implements file_info.
96 class file_info_impl : public file_info
97 {
98 public:
99 file_info_impl(const file_info_impl & p_source);
100 file_info_impl(const file_info & p_source);
101 file_info_impl();
102 ~file_info_impl();
103
104 double get_length() const;
105 void set_length(double p_length);
106
107 void copy_meta(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass
108 void copy_info(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass
109
110 t_size meta_get_count() const;
111 const char* meta_enum_name(t_size p_index) const;
112 t_size meta_enum_value_count(t_size p_index) const;
113 const char* meta_enum_value(t_size p_index,t_size p_value_number) const;
114 t_size meta_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
115 void meta_insert_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length);
116 void meta_remove_mask(const bit_array & p_mask);
117 void meta_reorder(const t_size * p_order);
118 void meta_remove_values(t_size p_index,const bit_array & p_mask);
119 void meta_modify_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length);
120
121 t_size info_get_count() const;
122 const char* info_enum_name(t_size p_index) const;
123 const char* info_enum_value(t_size p_index) const;
124 t_size info_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
125 void info_remove_mask(const bit_array & p_mask);
126
127 const file_info_impl & operator=(const file_info_impl & p_source);
128
129 replaygain_info get_replaygain() const;
130 void set_replaygain(const replaygain_info & p_info);
131
132 protected:
133 t_size meta_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
134 t_size info_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
135
136 file_info_impl_utils::meta_storage m_meta;
137 file_info_impl_utils::info_storage m_info;
138
139
140 double m_length = 0;
141
142 replaygain_info m_replaygain;
143 };