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

◆ check_include() [2/2]

std::optional< std::string > MayaFlux::Reflect::Tool::check_include ( const std::filesystem::path & header,
unsigned last_marker,
std::string_view suffix )
nodiscard

check_include() for any marker, given the header, the line of its last marker and the sidecar suffix.

Definition at line 170 of file Sidecar.cpp.

172{
173 const std::string file = sidecar_path(header, suffix).filename().string();
174 const std::string quoted = file + "\"";
175
176 const auto text = read_text(header);
177 if (!text) {
178 return header.string() + ": cannot read the header to check its sidecar include";
179 }
180
181 const std::vector<unsigned> includes = include_lines(*text, quoted);
182
183 const std::string where = header.string() + ": ";
184 if (includes.empty()) {
185 return where + "add #include \"" + file + "\" after line " + std::to_string(last_marker);
186 }
187 if (includes.size() > 1) {
188 return where + "#include \"" + file + "\" appears more than once";
189 }
190 if (includes.front() <= last_marker) {
191 return where + "#include \"" + file + "\" at line " + std::to_string(includes.front())
192 + " must come after line " + std::to_string(last_marker)
193 + ", the end of the namespace holding the last MF_DESCRIBE";
194 }
195 return std::nullopt;
196}
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

References read_text(), and sidecar_path().

Here is the call graph for this function: