| 74 | virtual void parse(std::istream& stream, const vfs::FileInfo& fileInfo, const std::string& modDir) = 0; |
| 75 | |
| 76 | void processFiles() |
| 77 | { |
| 78 | ScopedDebugTimer timer("[DeclParser] Parsed " + decl::getTypeName(_declType) + " declarations"); |
| 79 | |
| 80 | // Accumulate all the files and sort them before calling the protected parse() method |
| 81 | std::vector<vfs::FileInfo> _incomingFiles; |
| 82 | _incomingFiles.reserve(200); |
| 83 | |
| 84 | GlobalFileSystem().forEachFile(_baseDir, _extension, [&](const vfs::FileInfo& info) |
| 85 | { |
| 86 | _incomingFiles.push_back(info); |
| 87 | }, _depth); |
| 88 | |
| 89 | // Sort the files by name |
| 90 | std::sort(_incomingFiles.begin(), _incomingFiles.end(), [](const vfs::FileInfo& a, const vfs::FileInfo& b) |
| 91 | { |
| 92 | return a.name < b.name; |
| 93 | }); |
| 94 | |
| 95 | // Dispatch the sorted list to the protected parse() method |
| 96 | for (const auto& fileInfo : _incomingFiles) |
| 97 | { |
| 98 | auto file = GlobalFileSystem().openTextFile(fileInfo.fullPath()); |
| 99 | |
| 100 | if (!file) continue; |
| 101 | |
| 102 | try |
| 103 | { |
| 104 | // Parse entity defs from the file |
| 105 | std::istream stream(&file->getInputStream()); |
| 106 | parse(stream, fileInfo, file->getModName()); |
| 107 | } |
| 108 | catch (ParseException& e) |
| 109 | { |
| 110 | rError() << "[DeclParser] Failed to parse " << fileInfo.fullPath() |
| 111 | << " (" << e.what() << ")" << std::endl; |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | }; |
| 116 | |
| 117 | } |
nothing calls this directly
no test coverage detected