cmListFileCache.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. #include "cmState.h"
  14. /** \class cmListFileCache
  15. * \brief A class to cache list file contents.
  16. *
  17. * cmListFileCache is a class used to cache the contents of parsed
  18. * cmake list files.
  19. */
  20. class cmMakefile;
  21. struct cmListFileArgument
  22. {
  23. enum Delimiter
  24. {
  25. Unquoted,
  26. Quoted,
  27. Bracket
  28. };
  29. cmListFileArgument(): Value(), Delim(Unquoted), FilePath(0), Line(0) {}
  30. cmListFileArgument(const cmListFileArgument& r):
  31. Value(r.Value), Delim(r.Delim), FilePath(r.FilePath), Line(r.Line) {}
  32. cmListFileArgument(const std::string& v, Delimiter d, const char* file,
  33. long line): Value(v), Delim(d),
  34. FilePath(file), Line(line) {}
  35. bool operator == (const cmListFileArgument& r) const
  36. {
  37. return (this->Value == r.Value) && (this->Delim == r.Delim);
  38. }
  39. bool operator != (const cmListFileArgument& r) const
  40. {
  41. return !(*this == r);
  42. }
  43. std::string Value;
  44. Delimiter Delim;
  45. const char* FilePath;
  46. long Line;
  47. };
  48. struct cmListFileContext
  49. {
  50. std::string Name;
  51. std::string FilePath;
  52. long Line;
  53. cmListFileContext(): Name(), FilePath(), Line(0) {}
  54. };
  55. std::ostream& operator<<(std::ostream&, cmListFileContext const&);
  56. bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs);
  57. bool operator==(cmListFileContext const& lhs, cmListFileContext const& rhs);
  58. bool operator!=(cmListFileContext const& lhs, cmListFileContext const& rhs);
  59. struct cmListFileFunction: public cmListFileContext
  60. {
  61. std::vector<cmListFileArgument> Arguments;
  62. };
  63. class cmListFileBacktrace: private std::vector<cmListFileContext>
  64. {
  65. public:
  66. cmListFileBacktrace(cmState::Snapshot snapshot = cmState::Snapshot())
  67. : Snapshot(snapshot)
  68. {
  69. }
  70. void Append(cmListFileContext const& context);
  71. void PrintTitle(std::ostream& out);
  72. void PrintCallStack(std::ostream& out);
  73. private:
  74. cmState::Snapshot Snapshot;
  75. };
  76. struct cmListFile
  77. {
  78. bool ParseFile(const char* path,
  79. bool topLevel,
  80. cmMakefile *mf);
  81. std::vector<cmListFileFunction> Functions;
  82. };
  83. struct cmValueWithOrigin {
  84. cmValueWithOrigin(const std::string &value,
  85. const cmListFileBacktrace &bt)
  86. : Value(value), Backtrace(bt)
  87. {}
  88. std::string Value;
  89. cmListFileBacktrace Backtrace;
  90. };
  91. #endif