foobar2000 SDK  2015-01-14
input_file_type.cpp
Go to the documentation of this file.
1 #include "foobar2000.h"
2 
3 #if FOOBAR2000_TARGET_VERSION >= 76
4 
6 
7 static void formatMaskList(pfc::string_base & out, t_fnList const & in) {
9  if (walk.is_valid()) {
10  out << *walk; ++walk;
11  while(walk.is_valid()) {
12  out << ";" << *walk; ++walk;
13  }
14  }
15 }
16 static void formatMaskList(pfc::string_base & out, t_fnList const & in, const char * label) {
17  if (in.get_count() > 0) {
18  out << label << "|";
19  formatMaskList(out,in);
20  out << "|";
21  }
22 }
23 
27 
28  {
29  componentversion::ptr ptr; service_enum_t<componentversion> e;
31  while(e.next(ptr)) {
32  name = "";
33  ptr->get_component_name(name);
34  if (strstr(name, "decoder") != NULL || strstr(name, "Decoder") != NULL) names += name;
35  }
36  }
37 
38 
40  for(pfc::const_iterator<pfc::string8> walk = names.first(); walk.is_valid(); ++walk) {
41  if (!out.is_empty()) str << "|";
42  out << *walk;
43  }
44  str = out;
45 }
48  {
52  while(e.next(ptr)) {
53  const unsigned count = ptr->get_count();
54  for(unsigned n=0;n<count;n++) {
55  mask.reset();
56  if (ptr->get_mask(n,mask)) {
57  if (strchr(mask,'|') == NULL) masks += mask;
58  }
59  }
60  }
61  }
63  for(pfc::const_iterator<pfc::string8> walk = masks.first(); walk.is_valid(); ++walk) {
64  if (!out.is_empty()) out << "|";
65  out << *walk;
66  }
67  str = out;
68 }
69 void input_file_type::build_openfile_mask(pfc::string_base & out, bool b_include_playlists)
70 {
71  t_fnList extensionsAll, extensionsPl;;
72 
73  if (b_include_playlists) {
75  while(e.next(ptr)) {
76  if (ptr->is_associatable()) {
77  pfc::string_formatter temp; temp << "*." << ptr->get_extension();
78  extensionsPl += temp;
79  extensionsAll += temp;
80  }
81  }
82  }
83 
85  t_masks masks;
86  {
89  pfc::string_formatter name, mask;
90  while(e.next(ptr)) {
91  const unsigned count = ptr->get_count();
92  for(unsigned n=0;n<count;n++) {
93  name.reset();
94  mask.reset();
95  if (ptr->get_name(n,name) && ptr->get_mask(n,mask)) {
96  if (!strchr(name,'|') && !strchr(mask,'|')) {
97  masks.find_or_add(name) += mask;
98  extensionsAll += mask;
99  }
100  }
101  }
102  }
103  }
104  pfc::string_formatter outBuf;
105  outBuf << "All files|*.*|";
106  formatMaskList(outBuf, extensionsAll, "All supported types");
107  formatMaskList(outBuf, extensionsPl, "Playlists");
108  for(t_masks::const_iterator walk = masks.first(); walk.is_valid(); ++walk) {
109  formatMaskList(outBuf,walk->m_value,walk->m_key);
110  }
111  out = outBuf;
112 }
113 #endif
Definition: map.h:16
t_size get_count() const
Definition: avltree.h:453
static void make_extension_support_fingerprint(pfc::string_base &str)
bool is_valid() const
Definition: iterators.h:24
const_iterator first() const
Definition: avltree.h:485
string8_fastalloc string_formatter
Definition: string_base.h:614
static void make_filetype_support_fingerprint(pfc::string_base &str)
static void build_openfile_mask(pfc::string_base &out, bool b_include_playlists=true)
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
pfc::avltree_t< pfc::string8, pfc::io::path::comparator > t_fnList
static void formatMaskList(pfc::string_base &out, t_fnList const &in)
bool next(service_ptr_t< t_query > &p_out)
Definition: service.h:587