You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.6 KiB

24 years ago
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef cmListFileCache_h
  14. #define cmListFileCache_h
  15. #include "cmStandardIncludes.h"
  16. /** \class cmListFileCache
  17. * \brief A class to cache list file contents.
  18. *
  19. * cmListFileCache is a class used to cache the contents of parsed
  20. * cmake list files.
  21. */
  22. struct cmListFileArgument
  23. {
  24. cmListFileArgument(): Value(), Quoted(false) {}
  25. cmListFileArgument(const cmListFileArgument& r): Value(r.Value), Quoted(r.Quoted) {}
  26. cmListFileArgument(const std::string& v, bool q): Value(v), Quoted(q) {}
  27. bool operator == (const cmListFileArgument& r) const
  28. {
  29. return (this->Value == r.Value) && (this->Quoted == r.Quoted);
  30. }
  31. bool operator != (const cmListFileArgument& r) const
  32. {
  33. return !(*this == r);
  34. }
  35. std::string Value;
  36. bool Quoted;
  37. };
  38. struct cmListFileFunction
  39. {
  40. std::string m_Name;
  41. std::vector<cmListFileArgument> m_Arguments;
  42. std::string m_FilePath;
  43. long m_Line;
  44. };
  45. struct cmListFile
  46. {
  47. cmListFile()
  48. :m_ModifiedTime(0)
  49. {
  50. }
  51. long int m_ModifiedTime;
  52. std::vector<cmListFileFunction> m_Functions;
  53. };
  54. class cmListFileCache
  55. {
  56. public:
  57. static cmListFileCache* GetInstance();
  58. static void ClearCache();
  59. /** Return the cached version of the given file.
  60. * If the file is not already in the cache, a cache entry
  61. * will be made. If there is an error loading the file,
  62. * NULL is returned. If requireProjectCommand is true,
  63. * then a PROJECT(Project) command will be added to the file
  64. * if it does not have a PROJECT command in it.
  65. */
  66. cmListFile* GetFileCache(const char* path, bool requireProjectCommand);
  67. //! Flush cache file out of cache.
  68. void FlushCache(const char* path);
  69. private:
  70. // Cache the file
  71. bool CacheFile(const char* path, bool requireProjectCommand);
  72. // private data
  73. typedef std::map<cmStdString, cmListFile> ListFileMap;
  74. ListFileMap m_ListFileCache; // file name to ListFile map
  75. static cmListFileCache* Instance; // singelton pointer
  76. };
  77. #endif