MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ check_function_sidecars()

std::vector< std::string > MayaFlux::Reflect::Tool::check_function_sidecars ( const FunctionMap & requests,
const std::vector< std::filesystem::path > & headers,
const std::vector< std::filesystem::path > & existing )
nodiscard

Compares the function sidecars on disk with what the generator would write, touching nothing.

Reports, one message per problem: a header with MF_DESCRIBE_FUNCTION text that produced no request, a missing sidecar, a sidecar that differs, a missing, repeated or misplaced include, and a sidecar in existing whose header has no request left.

Parameters
headersEvery header the scan covered.
existingSidecars found on disk under the roots, for the orphan check. Empty skips it.
Returns
No messages when everything is current.

Definition at line 66 of file FunctionSidecar.cpp.

70{
71 std::vector<std::string> problems;
72
73 for (const auto& header : headers) {
74 const auto found = requests.find(header);
75 if (found == requests.end()) {
76 problems.push_back(header.string() + ": contains MF_DESCRIBE_FUNCTION text but produced no request");
77 continue;
78 }
79
80 const std::filesystem::path sidecar = sidecar_path(header, function_sidecar_suffix);
81 const auto current = read_text(sidecar);
82 if (!current) {
83 problems.push_back(sidecar.string() + ": missing sidecar");
84 } else if (*current != render_function_sidecar(found->second)) {
85 problems.push_back(sidecar.string() + ": differs from what the generator would write");
86 }
87
88 if (const auto problem = check_include(header, last_function_line(found->second), function_sidecar_suffix)) {
89 problems.push_back(*problem);
90 }
91 }
92
93 for (const auto& sidecar : existing) {
94 const std::string name = sidecar.filename().string();
95 const std::string stem = name.substr(0, name.size() - function_sidecar_suffix.size());
96 const std::filesystem::path header = sidecar.parent_path() / (stem + ".hpp");
97 if (!requests.contains(header)) {
98 problems.push_back(sidecar.string() + ": orphaned, its header has no MF_DESCRIBE_FUNCTION request");
99 }
100 }
101 return problems;
102}
std::optional< std::string > read_text(const std::filesystem::path &path)
The whole content of path, or nullopt when it cannot be read.
Definition Sidecar.cpp:30
std::filesystem::path sidecar_path(const std::filesystem::path &header)
Path of the sidecar for header: Name.hpp becomes Name.describe.hpp beside it.
Definition Sidecar.cpp:85
constexpr std::string_view function_sidecar_suffix
The suffix of a function sidecar: Name.hpp becomes Name.signatures.hpp beside it.
std::string render_function_sidecar(const HeaderFunctions &functions)
Text of the sidecar for one header, one Signature specialization per function, sorted by name.
unsigned last_function_line(const HeaderFunctions &functions)
The line after which the sidecar include may appear: the last marker of the header.
std::optional< std::string > check_include(const HeaderRequests &requests)
Checks that the header includes its sidecar exactly once, after its last marker.
Definition Sidecar.cpp:161

References check_include(), function_sidecar_suffix, last_function_line(), read_text(), render_function_sidecar(), and sidecar_path().

Here is the call graph for this function: