-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLibrary.hpp
More file actions
35 lines (31 loc) · 772 Bytes
/
Library.hpp
File metadata and controls
35 lines (31 loc) · 772 Bytes
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
#pragma once
#include "Composition.hpp"
#include <map>
#include <string>
#include <functional>
struct Folder {
std::map< std::string, Folder > folders;
std::map< std::string, Sound > sounds;
enum {
Collapsed,
Expanded,
Error
} state = Collapsed;
};
struct Library {
Library(std::string const &path);
std::string path;
Folder root;
void foreach_sound(std::function< void(std::string const &path, Sound &sound) > const &fn) {
std::function< void(std::string, Folder &) > rec;
rec = [&fn,&rec](std::string const &path, Folder &folder) {
for (auto &[ file, sound ] : folder.sounds) {
fn(path + "/" + file, sound);
}
for (auto &[ file, subfolder ] : folder.folders) {
rec(path + "/" + file, subfolder);
}
};
rec(path, root);
}
};