cmListFileCache.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. class cmListFileContext
  53. {
  54. public:
  55. std::string Name;
  56. std::string FilePath;
  57. long Line;
  58. cmListFileContext(): Name(), FilePath(), Line(0) {}
  59. static cmListFileContext FromCommandContext(cmCommandContext const& lfcc,
  60. std::string const& fileName)
  61. {
  62. cmListFileContext lfc;
  63. lfc.FilePath = fileName;
  64. lfc.Line = lfcc.Line;
  65. lfc.Name = lfcc.Name;
  66. return lfc;
  67. }
  68. };
  69. std::ostream& operator<<(std::ostream&, cmListFileContext const&);
  70. bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs);
  71. bool operator==(cmListFileContext const& lhs, cmListFileContext const& rhs);
  72. bool operator!=(cmListFileContext const& lhs, cmListFileContext const& rhs);
  73. struct cmListFileFunction: public cmCommandContext
  74. {
  75. std::vector<cmListFileArgument> Arguments;
  76. };
  77. class cmListFileBacktrace
  78. {
  79. public:
  80. cmListFileBacktrace(cmState::Snapshot snapshot = cmState::Snapshot(),
  81. cmCommandContext const& cc = cmCommandContext());
  82. ~cmListFileBacktrace();
  83. void PrintTitle(std::ostream& out) const;
  84. void PrintCallStack(std::ostream& out) const;
  85. private:
  86. cmCommandContext Context;
  87. cmState::Snapshot Snapshot;
  88. };
  89. struct cmListFile
  90. {
  91. bool ParseFile(const char* path,
  92. bool topLevel,
  93. cmMakefile *mf);
  94. std::vector<cmListFileFunction> Functions;
  95. };
  96. #endif