-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFileTypeRegistrar.h
67 lines (53 loc) · 1.52 KB
/
FileTypeRegistrar.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/** $VER: FileTypeRegistrar.h (2022.12.28) P. Stuer **/
#pragma once
#include <foobar2000/SDK/foobar2000.h>
extern "C"
{
#include <src/vgmstream.h>
}
#pragma region("FileTypeRegistrar")
class FileTypeRegistrar : public input_file_type_v2
{
public:
FileTypeRegistrar() noexcept
{
_Extensions = ::vgmstream_get_formats(&_ExtensionCount);
}
FileTypeRegistrar(const FileTypeRegistrar&) = delete;
FileTypeRegistrar(const FileTypeRegistrar&&) = delete;
FileTypeRegistrar& operator=(const FileTypeRegistrar&) = delete;
FileTypeRegistrar& operator=(FileTypeRegistrar&&) = delete;
virtual ~FileTypeRegistrar() { };
#pragma region("Interface input_file_type")
unsigned get_count() noexcept final
{
return (unsigned)_ExtensionCount;
}
bool is_associatable(unsigned) noexcept final
{
return true;
}
#pragma endregion
#pragma region("Interface input_file_type_v2")
void get_format_name(unsigned idx, pfc::string_base & out, bool isPlural) final
{
out.reset();
pfc::stringToUpperAppend(out, _Extensions[idx], pfc::strlen_utf8(_Extensions[idx]));
out += " Audio File";
if (isPlural)
out += "s";
}
void get_extensions(unsigned idx, pfc::string_base & out) final
{
out = _Extensions[idx];
}
#pragma endregion
private:
const char ** _Extensions;
size_t _ExtensionCount;
};
namespace
{
static service_factory_single_t<FileTypeRegistrar> _FileTypeRegistrar;
}
#pragma endregion