| 3117 | } |
| 3118 | |
| 3119 | std::pair<simplecpp::FileData *, bool> simplecpp::FileDataCache::get(const std::string &sourcefile, const std::string &header, const simplecpp::DUI &dui, bool systemheader, std::vector<std::string> &filenames, simplecpp::OutputList *outputList) |
| 3120 | { |
| 3121 | if (isAbsolutePath(header)) { |
| 3122 | auto ins = mNameMap.emplace(simplecpp::simplifyPath(header), nullptr); |
| 3123 | |
| 3124 | if (ins.second) { |
| 3125 | const auto ret = tryload(ins.first, dui, filenames, outputList); |
| 3126 | if (ret.first != nullptr) { |
| 3127 | return ret; |
| 3128 | } |
| 3129 | } else { |
| 3130 | return {ins.first->second, false}; |
| 3131 | } |
| 3132 | |
| 3133 | return {nullptr, false}; |
| 3134 | } |
| 3135 | |
| 3136 | if (!systemheader) { |
| 3137 | auto ins = mNameMap.emplace(simplecpp::simplifyPath(dirPath(sourcefile) + header), nullptr); |
| 3138 | |
| 3139 | if (ins.second) { |
| 3140 | const auto ret = tryload(ins.first, dui, filenames, outputList); |
| 3141 | if (ret.first != nullptr) { |
| 3142 | return ret; |
| 3143 | } |
| 3144 | } else if (ins.first->second != nullptr) { |
| 3145 | return {ins.first->second, false}; |
| 3146 | } |
| 3147 | } |
| 3148 | |
| 3149 | for (const auto &includePath : dui.includePaths) { |
| 3150 | auto ins = mNameMap.emplace(simplecpp::simplifyPath(includePath + "/" + header), nullptr); |
| 3151 | |
| 3152 | if (ins.second) { |
| 3153 | const auto ret = tryload(ins.first, dui, filenames, outputList); |
| 3154 | if (ret.first != nullptr) { |
| 3155 | return ret; |
| 3156 | } |
| 3157 | } else if (ins.first->second != nullptr) { |
| 3158 | return {ins.first->second, false}; |
| 3159 | } |
| 3160 | } |
| 3161 | |
| 3162 | return {nullptr, false}; |
| 3163 | } |
| 3164 | |
| 3165 | bool simplecpp::FileDataCache::getFileId(const std::string &path, FileID &id) |
| 3166 | { |
no test coverage detected