cmListFileCache.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 cmLocalGenerator;
  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. struct cmListFileFunction: public cmListFileContext
  58. {
  59. std::vector<cmListFileArgument> Arguments;
  60. };
  61. class cmListFileBacktrace: public std::vector<cmListFileContext>
  62. {
  63. public:
  64. cmListFileBacktrace(cmLocalGenerator* localGen)
  65. : LocalGenerator(localGen)
  66. , Relative(localGen ? false : true)
  67. {
  68. }
  69. void MakeRelative();
  70. private:
  71. cmLocalGenerator* LocalGenerator;
  72. bool Relative;
  73. };
  74. struct cmListFile
  75. {
  76. bool ParseFile(const char* path,
  77. bool topLevel,
  78. cmMakefile *mf);
  79. std::vector<cmListFileFunction> Functions;
  80. };
  81. struct cmValueWithOrigin {
  82. cmValueWithOrigin(const std::string &value,
  83. const cmListFileBacktrace &bt)
  84. : Value(value), Backtrace(bt)
  85. {}
  86. std::string Value;
  87. cmListFileBacktrace Backtrace;
  88. };
  89. #endif