-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrewrite.h
44 lines (31 loc) · 984 Bytes
/
rewrite.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
#ifndef REWRITE_TBD_REWRITE_H
#define REWRITE_TBD_REWRITE_H
#include <unordered_map>
#include <optional>
#include <vector>
#include <string>
#include <yaml.h>
struct rewrite_result;
struct rewrite_config {
/**
* Prefix matches
*/
std::unordered_map<std::string, std::string> prefixes;
/**
* Absolute path rewrites, without any context.
*/
std::unordered_map<std::string, std::string> constPaths;
std::optional<std::string> requiredPrefix;
bool checkExistence = true;
friend std::ostream &operator<<(std::ostream &os, const rewrite_config &cfg);
rewrite_result rewrite(yaml_document_t *document) const;
};
struct rewrite_result {
std::vector<std::string> unmatchedPaths;
std::vector<std::string> nonExistentPaths;
std::vector<std::string> missingPrefixPaths;
[[nodiscard]] bool failed() const {
return !unmatchedPaths.empty() || !nonExistentPaths.empty();
}
};
#endif //REWRITE_TBD_REWRITE_H