9 std::multimap<std::string, std::filesystem::path> headers_by_name(
const std::filesystem::path& directory)
13 for (std::filesystem::recursive_directory_iterator it(directory, code), end; it != end; it.increment(code)) {
38 const std::filesystem::path& registry,
const std::filesystem::path& source_root, std::string& error)
40 std::ifstream stream(registry);
42 error =
"cannot read " + registry.string();
46 const std::regex entry(R
"(^\s*([NWB])\((\w+),\s*(MayaFlux::[\w:]+)\)\s*\\?\s*$)");
47 std::vector<SignatureEntry> entries;
48 std::set<std::string> names;
50 while (std::getline(stream, line)) {
51 if (!line.empty() && line.back() ==
'\r') {
55 if (!std::regex_match(line, match, entry)) {
58 if (!names.insert(match[2].str()).second) {
59 error =
"registry is empty or contains duplicate factory names: " + match[2].str();
62 entries.push_back(
SignatureEntry { .name = match[2].str(), .type_name = match[3].str(), .header = {} });
64 if (entries.empty()) {
65 error =
"registry is empty or contains duplicate factory names";
69 const auto headers = headers_by_name(source_root /
"MayaFlux");
71 const std::string class_name = item.type_name.substr(item.type_name.rfind(
"::") + 2);
72 std::vector<std::filesystem::path> matches;
73 const auto range = headers.equal_range(class_name +
".hpp");
74 for (
auto it = range.first; it != range.second; ++it) {
75 if (declares_class(it->second, class_name)) {
76 matches.push_back(it->second);
79 if (matches.size() != 1) {
80 error = item.name +
": expected one defining class header, found " + std::to_string(matches.size());
83 item.header = matches.front();