cmListFileCache.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 cmCommandContext
  22. {
  23. std::string Name;
  24. long Line;
  25. cmCommandContext(): Name(), Line(0) {}
  26. };
  27. struct cmListFileArgument
  28. {
  29. enum Delimiter
  30. {
  31. Unquoted,
  32. Quoted,
  33. Bracket
  34. };
  35. cmListFileArgument(): Value(), Delim(Unquoted), Line(0) {}
  36. cmListFileArgument(const cmListFileArgument& r)
  37. : Value(r.Value), Delim(r.Delim), Line(r.Line) {}
  38. cmListFileArgument(const std::string& v, Delimiter d, long line)
  39. : Value(v), Delim(d), Line(line) {}
  40. bool operator == (const cmListFileArgument& r) const
  41. {
  42. return (this->Value == r.Value) && (this->Delim == r.Delim);
  43. }
  44. bool operator != (const cmListFileArgument& r) const
  45. {
  46. return !(*this == r);
  47. }
  48. std::string Value;
  49. Delimiter Delim;
  50. long Line;
  51. };
  52. struct cmListFileContext
  53. {
  54. std::string Name;
  55. std::string FilePath;
  56. long Line;
  57. cmListFileContext(): Name(), FilePath(), Line(0) {}
  58. static cmListFileContext FromCommandContext(cmCommandContext const& lfcc,
  59. std::string const& fileName)
  60. {
  61. cmListFileContext lfc;
  62. lfc.FilePath = fileName;
  63. lfc.Line = lfcc.Line;
  64. lfc.Name = lfcc.Name;
  65. return lfc;
  66. }
  67. };
  68. std::ostream& operator<<(std::ostream&, cmListFileContext const&);
  69. bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs);
  70. bool operator==(cmListFileContext const& lhs, cmListFileContext const& rhs);
  71. bool operator!=(cmListFileContext const& lhs, cmListFileContext const& rhs);
  72. struct cmListFileFunction: public cmCommandContext
  73. {
  74. std::vector<cmListFileArgument> Arguments;
  75. };
  76. class cmListFileBacktrace
  77. {
  78. public:
  79. cmListFileBacktrace(cmState::Snapshot snapshot = cmState::Snapshot(),
  80. cmCommandContext const& cc = cmCommandContext())
  81. : Context(cc), Snapshot(snapshot)
  82. {
  83. }
  84. void PrintTitle(std::ostream& out) const;
  85. void PrintCallStack(std::ostream& out) const;
  86. private:
  87. cmCommandContext Context;
  88. cmState::Snapshot Snapshot;
  89. };
  90. struct cmListFile
  91. {
  92. bool ParseFile(const char* path,
  93. bool topLevel,
  94. cmMakefile *mf);
  95. std::vector<cmListFileFunction> Functions;
  96. };
  97. #endif