cmListFileCache.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmListFileCache_h
  11. #define cmListFileCache_h
  12. #include "cmStandardIncludes.h"
  13. /** \class cmListFileCache
  14. * \brief A class to cache list file contents.
  15. *
  16. * cmListFileCache is a class used to cache the contents of parsed
  17. * cmake list files.
  18. */
  19. class cmMakefile;
  20. struct cmListFileArgument
  21. {
  22. enum Delimiter
  23. {
  24. Unquoted,
  25. Quoted
  26. };
  27. cmListFileArgument(): Value(), Delim(Unquoted), FilePath(0), Line(0) {}
  28. cmListFileArgument(const cmListFileArgument& r):
  29. Value(r.Value), Delim(r.Delim), FilePath(r.FilePath), Line(r.Line) {}
  30. cmListFileArgument(const std::string& v, Delimiter d, const char* file,
  31. long line): Value(v), Delim(d),
  32. FilePath(file), Line(line) {}
  33. bool operator == (const cmListFileArgument& r) const
  34. {
  35. return (this->Value == r.Value) && (this->Delim == r.Delim);
  36. }
  37. bool operator != (const cmListFileArgument& r) const
  38. {
  39. return !(*this == r);
  40. }
  41. std::string Value;
  42. Delimiter Delim;
  43. const char* FilePath;
  44. long Line;
  45. };
  46. struct cmListFileContext
  47. {
  48. std::string Name;
  49. std::string FilePath;
  50. long Line;
  51. cmListFileContext(): Name(), FilePath(), Line(0) {}
  52. };
  53. std::ostream& operator<<(std::ostream&, cmListFileContext const&);
  54. struct cmListFileFunction: public cmListFileContext
  55. {
  56. std::vector<cmListFileArgument> Arguments;
  57. };
  58. class cmListFileBacktrace: public std::vector<cmListFileContext> {};
  59. struct cmListFile
  60. {
  61. cmListFile()
  62. :ModifiedTime(0)
  63. {
  64. }
  65. bool ParseFile(const char* path,
  66. bool topLevel,
  67. cmMakefile *mf);
  68. long int ModifiedTime;
  69. std::vector<cmListFileFunction> Functions;
  70. };
  71. struct cmValueWithOrigin {
  72. cmValueWithOrigin(const std::string &value,
  73. const cmListFileBacktrace &bt)
  74. : Value(value), Backtrace(bt)
  75. {}
  76. std::string Value;
  77. cmListFileBacktrace Backtrace;
  78. };
  79. #endif