cmConditionEvaluator.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <string>
  6. #include <vector>
  7. #include <cmext/string_view>
  8. #include "cmListFileCache.h"
  9. #include "cmMessageType.h" // IWYU pragma: keep
  10. #include "cmPolicies.h"
  11. #include "cmValue.h"
  12. class cmExpandedCommandArgument;
  13. class cmMakefile;
  14. class cmConditionEvaluator
  15. {
  16. public:
  17. cmConditionEvaluator(cmMakefile& makefile, cmListFileBacktrace bt);
  18. // this is a shared function for both If and Else to determine if the
  19. // arguments were valid, and if so, was the response true. If there is
  20. // an error, the errorString will be set.
  21. bool IsTrue(const std::vector<cmExpandedCommandArgument>& args,
  22. std::string& errorString, MessageType& status);
  23. private:
  24. class cmArgumentList;
  25. // Filter the given variable definition based on policy CMP0054.
  26. cmValue GetDefinitionIfUnquoted(
  27. const cmExpandedCommandArgument& argument) const;
  28. cmValue GetVariableOrString(const cmExpandedCommandArgument& argument) const;
  29. bool IsKeyword(cm::static_string_view keyword,
  30. const cmExpandedCommandArgument& argument) const;
  31. bool GetBooleanValue(cmExpandedCommandArgument& arg) const;
  32. template <int N>
  33. int matchKeysImpl(const cmExpandedCommandArgument&);
  34. template <int N, typename T, typename... Keys>
  35. int matchKeysImpl(const cmExpandedCommandArgument&, T, Keys...);
  36. template <typename... Keys>
  37. int matchKeys(const cmExpandedCommandArgument&, Keys...);
  38. bool HandleLevel0(cmArgumentList& newArgs, std::string& errorString,
  39. MessageType& status);
  40. bool HandleLevel1(cmArgumentList& newArgs, std::string&, MessageType&);
  41. bool HandleLevel2(cmArgumentList& newArgs, std::string& errorString,
  42. MessageType& status);
  43. bool HandleLevel3(cmArgumentList& newArgs, std::string& errorString,
  44. MessageType& status);
  45. bool HandleLevel4(cmArgumentList& newArgs, std::string& errorString,
  46. MessageType& status);
  47. cmMakefile& Makefile;
  48. cmListFileBacktrace Backtrace;
  49. cmPolicies::PolicyStatus Policy54Status;
  50. cmPolicies::PolicyStatus Policy57Status;
  51. cmPolicies::PolicyStatus Policy64Status;
  52. cmPolicies::PolicyStatus Policy139Status;
  53. };