9 using Members = std::map<std::string, std::vector<std::string>>;
11 constexpr std::string_view record_marker =
"struct Description<::";
13 Members parse_sidecar(
const std::string& text)
16 auto current = parsed.end();
17 std::istringstream lines(text);
19 while (std::getline(lines, line)) {
20 if (
const auto at =
line.find(record_marker); at != std::string::npos) {
21 const auto begin =
at + record_marker.size();
22 const auto end =
line.find(
'>', begin);
23 if (end != std::string::npos) {
24 current = parsed.try_emplace(
line.substr(begin, end - begin)).first;
28 if (current == parsed.end() ||
line.find(
"Member<&::") == std::string::npos) {
33 if (close != std::string::npos) {
34 current->second.push_back(
line.substr(open + 1, close - open - 1));
40 std::string joined(
const std::vector<std::string>& names)
43 for (
const auto& name : names) {
44 out += out.empty() ? name :
", " + name;
49 std::vector<std::string> missing_from(
const std::vector<std::string>& names,
const std::vector<std::string>& other)
51 std::vector<std::string> out;
52 for (
const auto& name : names) {
53 if (std::ranges::find(other, name) == other.end()) {
60 std::vector<std::string> drift(
const std::string& where,
const std::string& have_text,
const std::string& want_text)
62 const Members have = parse_sidecar(have_text);
63 const Members want = parse_sidecar(want_text);
64 std::vector<std::string> messages;
66 for (
const auto& [name, members] : want) {
67 const auto found = have.find(name);
68 if (found == have.end()) {
69 messages.push_back(where + name +
" is not described in the sidecar");
72 if (found->second == members) {
75 const auto added = missing_from(members, found->second);
76 const auto removed = missing_from(found->second, members);
77 std::string change = where + name +
":";
79 change +=
" add " + joined(added);
81 if (!removed.empty()) {
82 change +=
" remove " + joined(removed);
84 if (added.empty() && removed.empty()) {
85 change +=
" member order changed";
87 messages.push_back(change);
89 for (
const auto& [name, members] : have) {
90 if (!want.contains(name)) {
91 messages.push_back(where + name +
" is in the sidecar but no longer requested");
94 if (messages.empty()) {
95 messages.push_back(where +
"the sidecar text differs from the generator output");
104 const std::vector<std::filesystem::path>& headers,
105 const std::vector<std::filesystem::path>&
existing)
107 std::vector<std::string> problems;
108 std::vector<std::filesystem::path> expected;
110 for (
const auto& header : headers) {
111 const auto found = requests.find(header);
112 if (found == requests.end()) {
113 problems.push_back(header.string() +
": contains MF_DESCRIBE text but produced no request");
117 const std::filesystem::path sidecar =
sidecar_path(header);
118 expected.push_back(sidecar);
119 const std::string where = sidecar.string() +
": ";
123 for (
auto at = have->find(
"\r\n"); at != std::string::npos; at = have->find(
"\r\n", at + 1)) {
127 const auto messages = drift(where, *have, want);
128 problems.insert(problems.end(), messages.begin(), messages.end());
131 problems.push_back(where +
"missing, expected " + std::to_string(found->second.records.size()) +
" record(s)");
135 problems.push_back(*problem);
139 for (
const auto& sidecar :
existing) {
140 if (std::ranges::find(expected, sidecar) == expected.end()) {
141 problems.push_back(sidecar.string() +
": orphaned, its header has no MF_DESCRIBE left");
Cycle Behavior: The for_cycles(N) configuration controls how many times the capture operation execute...
void close(std::span< const float > mask, std::span< float > tmp, std::span< float > dst, uint32_t w, uint32_t h, uint32_t radius)
Morphological closing writing into dst.
void open(std::span< const float > mask, std::span< float > tmp, std::span< float > dst, uint32_t w, uint32_t h, uint32_t radius)
Morphological opening writing into dst.
Vruta::SoundRoutine line(float start_value, float end_value, float duration_seconds, uint32_t step_duration, bool restartable)
Creates a continuous interpolation generator between two values over time.