| 317 | } |
| 318 | |
| 319 | static Namespace *GetNamespace( |
| 320 | const std::string &qualified_name, std::vector<Namespace *> &namespaces, |
| 321 | std::map<std::string, Namespace *> &namespaces_index) { |
| 322 | size_t dot = qualified_name.find_last_of('.'); |
| 323 | std::string namespace_name = (dot != std::string::npos) |
| 324 | ? std::string(qualified_name.c_str(), dot) |
| 325 | : ""; |
| 326 | Namespace *&ns = namespaces_index[namespace_name]; |
| 327 | |
| 328 | if (!ns) { |
| 329 | ns = new Namespace(); |
| 330 | namespaces.push_back(ns); |
| 331 | |
| 332 | size_t pos = 0; |
| 333 | |
| 334 | for (;;) { |
| 335 | dot = qualified_name.find('.', pos); |
| 336 | if (dot == std::string::npos) { break; } |
| 337 | ns->components.push_back(qualified_name.substr(pos, dot - pos)); |
| 338 | pos = dot + 1; |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | return ns; |
| 343 | } |
| 344 | |
| 345 | // Generate a unique hash for a file based on its name and contents (if any). |
| 346 | static uint64_t HashFile(const char *source_filename, const char *source) { |
no test coverage detected