Mercurial > foo_out_sdl
comparison foosdk/sdk/foobar2000/SDK/file_info_impl.cpp @ 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 #include "foobar2000-sdk-pch.h" | |
| 2 | |
| 3 #include <pfc/bit_array_impl.h> | |
| 4 #include <pfc/sort.h> | |
| 5 | |
| 6 #include "file_info_impl.h" | |
| 7 | |
| 8 | |
| 9 t_size file_info_impl::meta_get_count() const | |
| 10 { | |
| 11 return m_meta.get_count(); | |
| 12 } | |
| 13 | |
| 14 const char* file_info_impl::meta_enum_name(t_size p_index) const | |
| 15 { | |
| 16 return m_meta.get_name(p_index); | |
| 17 } | |
| 18 | |
| 19 t_size file_info_impl::meta_enum_value_count(t_size p_index) const | |
| 20 { | |
| 21 return m_meta.get_value_count(p_index); | |
| 22 } | |
| 23 | |
| 24 const char* file_info_impl::meta_enum_value(t_size p_index,t_size p_value_number) const | |
| 25 { | |
| 26 return m_meta.get_value(p_index,p_value_number); | |
| 27 } | |
| 28 | |
| 29 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) | |
| 30 { | |
| 31 meta_remove_field_ex(p_name,p_name_length); | |
| 32 return meta_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length); | |
| 33 } | |
| 34 | |
| 35 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) | |
| 36 { | |
| 37 return m_meta.add_entry(p_name,p_name_length,p_value,p_value_length); | |
| 38 } | |
| 39 | |
| 40 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) | |
| 41 { | |
| 42 m_meta.insert_value(p_index,p_value_index,p_value,p_value_length); | |
| 43 } | |
| 44 | |
| 45 void file_info_impl::meta_remove_mask(const bit_array & p_mask) | |
| 46 { | |
| 47 m_meta.remove_mask(p_mask); | |
| 48 } | |
| 49 | |
| 50 void file_info_impl::meta_reorder(const t_size * p_order) | |
| 51 { | |
| 52 m_meta.reorder(p_order); | |
| 53 } | |
| 54 | |
| 55 void file_info_impl::meta_remove_values(t_size p_index,const bit_array & p_mask) | |
| 56 { | |
| 57 m_meta.remove_values(p_index,p_mask); | |
| 58 if (m_meta.get_value_count(p_index) == 0) | |
| 59 m_meta.remove_mask(pfc::bit_array_one(p_index)); | |
| 60 } | |
| 61 | |
| 62 t_size file_info_impl::info_get_count() const | |
| 63 { | |
| 64 return m_info.get_count(); | |
| 65 } | |
| 66 | |
| 67 const char* file_info_impl::info_enum_name(t_size p_index) const | |
| 68 { | |
| 69 return m_info.get_name(p_index); | |
| 70 } | |
| 71 | |
| 72 const char* file_info_impl::info_enum_value(t_size p_index) const | |
| 73 { | |
| 74 return m_info.get_value(p_index); | |
| 75 } | |
| 76 | |
| 77 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) | |
| 78 { | |
| 79 info_remove_ex(p_name,p_name_length); | |
| 80 return info_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length); | |
| 81 } | |
| 82 | |
| 83 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) | |
| 84 { | |
| 85 return m_info.add_item(p_name,p_name_length,p_value,p_value_length); | |
| 86 } | |
| 87 | |
| 88 void file_info_impl::info_remove_mask(const bit_array & p_mask) | |
| 89 { | |
| 90 m_info.remove_mask(p_mask); | |
| 91 } | |
| 92 | |
| 93 | |
| 94 file_info_impl::file_info_impl(const file_info & p_source) | |
| 95 { | |
| 96 copy(p_source); | |
| 97 } | |
| 98 | |
| 99 file_info_impl::file_info_impl(const file_info_impl & p_source) | |
| 100 { | |
| 101 copy(p_source); | |
| 102 } | |
| 103 | |
| 104 const file_info_impl & file_info_impl::operator=(const file_info_impl & p_source) | |
| 105 { | |
| 106 copy(p_source); | |
| 107 return *this; | |
| 108 } | |
| 109 | |
| 110 file_info_impl::file_info_impl() {} | |
| 111 | |
| 112 double file_info_impl::get_length() const | |
| 113 { | |
| 114 return m_length; | |
| 115 } | |
| 116 | |
| 117 void file_info_impl::set_length(double p_length) | |
| 118 { | |
| 119 m_length = p_length; | |
| 120 } | |
| 121 | |
| 122 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) | |
| 123 { | |
| 124 m_meta.modify_value(p_index,p_value_index,p_value,p_value_length); | |
| 125 } | |
| 126 | |
| 127 replaygain_info file_info_impl::get_replaygain() const | |
| 128 { | |
| 129 return m_replaygain; | |
| 130 } | |
| 131 | |
| 132 void file_info_impl::set_replaygain(const replaygain_info & p_info) | |
| 133 { | |
| 134 m_replaygain = p_info; | |
| 135 } | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 file_info_impl::~file_info_impl() | |
| 141 { | |
| 142 } | |
| 143 | |
| 144 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) { | |
| 145 t_size index = m_info.get_size(); | |
| 146 m_info.set_size(index + 1); | |
| 147 m_info[index].init(p_name,p_name_length,p_value,p_value_length); | |
| 148 return index; | |
| 149 } | |
| 150 | |
| 151 void file_info_impl_utils::info_storage::remove_mask(const bit_array & p_mask) { | |
| 152 pfc::remove_mask_t(m_info,p_mask); | |
| 153 } | |
| 154 | |
| 155 | |
| 156 size_t file_info_impl_utils::meta_storage::add_blank(const char* name) { | |
| 157 meta_entry e; | |
| 158 e.m_name = name; | |
| 159 const auto ret = m_data.size(); | |
| 160 m_data.add_item(std::move(e)); | |
| 161 return ret; | |
| 162 } | |
| 163 | |
| 164 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) | |
| 165 { | |
| 166 const auto ret = m_data.size(); | |
| 167 m_data.add_item(meta_entry(p_name, p_name_length, p_value, p_value_length)); | |
| 168 return ret; | |
| 169 } | |
| 170 | |
| 171 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) | |
| 172 { | |
| 173 m_data[p_index].insert_value(p_value_index,p_value,p_value_length); | |
| 174 } | |
| 175 | |
| 176 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) | |
| 177 { | |
| 178 m_data[p_index].modify_value(p_value_index,p_value,p_value_length); | |
| 179 } | |
| 180 | |
| 181 void file_info_impl_utils::meta_storage::remove_values(t_size p_index,const bit_array & p_mask) | |
| 182 { | |
| 183 m_data[p_index].remove_values(p_mask); | |
| 184 } | |
| 185 | |
| 186 void file_info_impl_utils::meta_storage::remove_mask(const bit_array & p_mask) | |
| 187 { | |
| 188 pfc::remove_mask_t(m_data,p_mask); | |
| 189 } | |
| 190 | |
| 191 | |
| 192 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) | |
| 193 { | |
| 194 m_name.set_string(p_name,p_name_len); | |
| 195 m_values.set_size(1); | |
| 196 m_values[0].set_string(p_value,p_value_len); | |
| 197 } | |
| 198 | |
| 199 | |
| 200 void file_info_impl_utils::meta_entry::remove_values(const bit_array & p_mask) | |
| 201 { | |
| 202 pfc::remove_mask_t(m_values,p_mask); | |
| 203 } | |
| 204 | |
| 205 void file_info_impl_utils::meta_entry::insert_value(t_size p_value_index,const char * p_value,t_size p_value_length) | |
| 206 { | |
| 207 pfc::string_simple temp; | |
| 208 temp.set_string(p_value,p_value_length); | |
| 209 pfc::insert_t(m_values,temp,p_value_index); | |
| 210 } | |
| 211 | |
| 212 void file_info_impl_utils::meta_entry::modify_value(t_size p_value_index,const char * p_value,t_size p_value_length) | |
| 213 { | |
| 214 m_values[p_value_index].set_string(p_value,p_value_length); | |
| 215 } | |
| 216 | |
| 217 void file_info_impl_utils::meta_storage::reorder(const t_size * p_order) | |
| 218 { | |
| 219 pfc::reorder_t(m_data,p_order,m_data.get_size()); | |
| 220 } | |
| 221 | |
| 222 void file_info_impl::copy_meta(const file_info & p_source) | |
| 223 { | |
| 224 m_meta.copy_from(p_source); | |
| 225 } | |
| 226 | |
| 227 void file_info_impl::copy_info(const file_info & p_source) | |
| 228 { | |
| 229 m_info.copy_from(p_source); | |
| 230 } | |
| 231 | |
| 232 void file_info_impl_utils::meta_storage::copy_from(const file_info & p_info) | |
| 233 { | |
| 234 t_size meta_index,meta_count = p_info.meta_get_count(); | |
| 235 m_data.set_size(meta_count); | |
| 236 for(meta_index=0;meta_index<meta_count;meta_index++) | |
| 237 { | |
| 238 meta_entry & entry = m_data[meta_index]; | |
| 239 t_size value_index,value_count = p_info.meta_enum_value_count(meta_index); | |
| 240 entry.m_name = p_info.meta_enum_name(meta_index); | |
| 241 entry.m_values.set_size(value_count); | |
| 242 for(value_index=0;value_index<value_count;value_index++) | |
| 243 entry.m_values[value_index] = p_info.meta_enum_value(meta_index,value_index); | |
| 244 } | |
| 245 } | |
| 246 | |
| 247 void file_info_impl_utils::info_storage::copy_from(const file_info & p_info) | |
| 248 { | |
| 249 t_size n, count; | |
| 250 count = p_info.info_get_count(); | |
| 251 m_info.set_count(count); | |
| 252 for(n=0;n<count;n++) m_info[n].init(p_info.info_enum_name(n),SIZE_MAX,p_info.info_enum_value(n),SIZE_MAX); | |
| 253 } |
