cmConditionEvaluator.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmConditionEvaluator_h
  4. #define cmConditionEvaluator_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <list>
  7. #include <string>
  8. #include <vector>
  9. #include "cmExpandedCommandArgument.h"
  10. #include "cmListFileCache.h"
  11. #include "cmPolicies.h"
  12. #include "cmake.h"
  13. class cmMakefile;
  14. class cmConditionEvaluator
  15. {
  16. public:
  17. typedef std::list<cmExpandedCommandArgument> cmArgumentList;
  18. cmConditionEvaluator(cmMakefile& makefile, cmListFileContext const& context,
  19. cmListFileBacktrace const& bt);
  20. // this is a shared function for both If and Else to determine if the
  21. // arguments were valid, and if so, was the response true. If there is
  22. // an error, the errorString will be set.
  23. bool IsTrue(const std::vector<cmExpandedCommandArgument>& args,
  24. std::string& errorString, cmake::MessageType& status);
  25. private:
  26. // Filter the given variable definition based on policy CMP0054.
  27. const char* GetDefinitionIfUnquoted(
  28. const cmExpandedCommandArgument& argument) const;
  29. const char* GetVariableOrString(
  30. const cmExpandedCommandArgument& argument) const;
  31. bool IsKeyword(std::string const& keyword,
  32. cmExpandedCommandArgument& argument) const;
  33. bool GetBooleanValue(cmExpandedCommandArgument& arg) const;
  34. bool GetBooleanValueOld(cmExpandedCommandArgument const& arg,
  35. bool one) const;
  36. bool GetBooleanValueWithAutoDereference(cmExpandedCommandArgument& newArg,
  37. std::string& errorString,
  38. cmake::MessageType& status,
  39. bool oneArg = false) const;
  40. void IncrementArguments(cmArgumentList& newArgs,
  41. cmArgumentList::iterator& argP1,
  42. cmArgumentList::iterator& argP2) const;
  43. void HandlePredicate(bool value, int& reducible,
  44. cmArgumentList::iterator& arg, cmArgumentList& newArgs,
  45. cmArgumentList::iterator& argP1,
  46. cmArgumentList::iterator& argP2) const;
  47. void HandleBinaryOp(bool value, int& reducible,
  48. cmArgumentList::iterator& arg, cmArgumentList& newArgs,
  49. cmArgumentList::iterator& argP1,
  50. cmArgumentList::iterator& argP2);
  51. bool HandleLevel0(cmArgumentList& newArgs, std::string& errorString,
  52. cmake::MessageType& status);
  53. bool HandleLevel1(cmArgumentList& newArgs, std::string&,
  54. cmake::MessageType&);
  55. bool HandleLevel2(cmArgumentList& newArgs, std::string& errorString,
  56. cmake::MessageType& status);
  57. bool HandleLevel3(cmArgumentList& newArgs, std::string& errorString,
  58. cmake::MessageType& status);
  59. bool HandleLevel4(cmArgumentList& newArgs, std::string& errorString,
  60. cmake::MessageType& status);
  61. cmMakefile& Makefile;
  62. cmListFileContext ExecutionContext;
  63. cmListFileBacktrace Backtrace;
  64. cmPolicies::PolicyStatus Policy12Status;
  65. cmPolicies::PolicyStatus Policy54Status;
  66. cmPolicies::PolicyStatus Policy57Status;
  67. cmPolicies::PolicyStatus Policy64Status;
  68. };
  69. #endif