cmConditionEvaluator.h 3.1 KB

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