|
1
|
1 #pragma once
|
|
|
2 #include "file_info.h"
|
|
|
3
|
|
|
4 class file_info_readonly : public file_info {
|
|
|
5 [[noreturn]] static void verboten() { FB2K_BugCheck(); }
|
|
|
6 protected:
|
|
|
7 void set_length(double) override { verboten(); }
|
|
|
8 void set_replaygain(const replaygain_info &) override { verboten(); }
|
|
|
9
|
|
|
10
|
|
|
11 t_size meta_set_ex(const char *, t_size, const char *, t_size) override { verboten(); }
|
|
|
12 void meta_insert_value_ex(t_size, t_size, const char *, t_size) override { verboten(); }
|
|
|
13 void meta_remove_mask(const bit_array &) override { verboten(); }
|
|
|
14 void meta_reorder(const t_size *) override { verboten(); }
|
|
|
15 void meta_remove_values(t_size, const bit_array &) override { verboten(); }
|
|
|
16 void meta_modify_value_ex(t_size, t_size, const char *, t_size) override { verboten(); }
|
|
|
17
|
|
|
18 t_size info_set_ex(const char *, t_size, const char *, t_size) override { verboten(); }
|
|
|
19 void info_remove_mask(const bit_array &) override { verboten(); }
|
|
|
20
|
|
|
21 t_size meta_set_nocheck_ex(const char *, t_size, const char *, t_size) override { verboten(); }
|
|
|
22 t_size info_set_nocheck_ex(const char *, t_size, const char *, t_size) override { verboten(); }
|
|
|
23 };
|
|
|
24
|
|
|
25 #define __file_info_const_impl_have_hintmap__
|
|
|
26
|
|
|
27 //! Special implementation of file_info that implements only const and copy methods. The difference between this and regular file_info_impl is amount of resources used and speed of the copy operation.
|
|
|
28 class file_info_const_impl : public file_info_readonly
|
|
|
29 {
|
|
|
30 public:
|
|
|
31 file_info_const_impl(const file_info & p_source) {copy(p_source);}
|
|
|
32 file_info_const_impl(const file_info_const_impl & p_source) {copy(p_source);}
|
|
|
33 file_info_const_impl() {m_meta_count = m_info_count = 0; m_length = 0; m_replaygain.reset();}
|
|
|
34
|
|
|
35 double get_length() const {return m_length;}
|
|
|
36
|
|
|
37 t_size meta_get_count() const {return m_meta_count;}
|
|
|
38 const char* meta_enum_name(t_size p_index) const {return m_meta[p_index].m_name;}
|
|
|
39 t_size meta_enum_value_count(t_size p_index) const;
|
|
|
40 const char* meta_enum_value(t_size p_index,t_size p_value_number) const;
|
|
|
41 t_size meta_find_ex(const char * p_name,t_size p_name_length) const;
|
|
|
42
|
|
|
43 t_size info_get_count() const {return m_info_count;}
|
|
|
44 const char* info_enum_name(t_size p_index) const {return m_info[p_index].m_name;}
|
|
|
45 const char* info_enum_value(t_size p_index) const {return m_info[p_index].m_value;}
|
|
|
46
|
|
|
47
|
|
|
48 const file_info_const_impl & operator=(const file_info & p_source) {copy(p_source); return *this;}
|
|
|
49 const file_info_const_impl & operator=(const file_info_const_impl & p_source) {copy(p_source); return *this;}
|
|
|
50 void copy(const file_info & p_source);
|
|
|
51 void reset();
|
|
|
52
|
|
|
53 replaygain_info get_replaygain() const {return m_replaygain;}
|
|
|
54
|
|
|
55 public:
|
|
|
56 struct meta_entry {
|
|
|
57 const char * m_name;
|
|
|
58 t_size m_valuecount;
|
|
|
59 const char * const * m_valuemap;
|
|
|
60 };
|
|
|
61
|
|
|
62 struct info_entry {
|
|
|
63 const char * m_name;
|
|
|
64 const char * m_value;
|
|
|
65 };
|
|
|
66
|
|
|
67 #ifdef __file_info_const_impl_have_hintmap__
|
|
|
68 typedef t_uint32 t_index;
|
|
|
69 enum {hintmap_cutoff = 20};
|
|
|
70 #endif//__file_info_const_impl_have_hintmap__
|
|
|
71 private:
|
|
|
72 pfc::array_t<char> m_buffer;
|
|
|
73 t_index m_meta_count;
|
|
|
74 t_index m_info_count;
|
|
|
75
|
|
|
76 const meta_entry * m_meta;
|
|
|
77 const info_entry * m_info;
|
|
|
78
|
|
|
79 #ifdef __file_info_const_impl_have_hintmap__
|
|
|
80 const t_index * m_hintmap;
|
|
|
81 #endif
|
|
|
82
|
|
|
83 double m_length;
|
|
|
84 replaygain_info m_replaygain;
|
|
|
85 };
|