cmConditionEvaluator.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2014 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 cmConditionEvaluator_h
  11. #define cmConditionEvaluator_h
  12. #include "cmCommand.h"
  13. #include "cmExpandedCommandArgument.h"
  14. class cmConditionEvaluator
  15. {
  16. public:
  17. typedef std::list<cmExpandedCommandArgument> cmArgumentList;
  18. cmConditionEvaluator(cmMakefile& makefile);
  19. // this is a shared function for both If and Else to determine if the
  20. // arguments were valid, and if so, was the response true. If there is
  21. // an error, the errorString will be set.
  22. bool IsTrue(const std::vector<cmExpandedCommandArgument> &args,
  23. std::string &errorString,
  24. 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(
  34. cmExpandedCommandArgument& arg) const;
  35. bool GetBooleanValueOld(
  36. cmExpandedCommandArgument const& arg, bool one) const;
  37. bool GetBooleanValueWithAutoDereference(
  38. cmExpandedCommandArgument &newArg,
  39. std::string &errorString,
  40. cmake::MessageType &status,
  41. bool oneArg = false) const;
  42. void IncrementArguments(
  43. cmArgumentList &newArgs,
  44. cmArgumentList::iterator &argP1,
  45. cmArgumentList::iterator &argP2) const;
  46. void HandlePredicate(bool value, int &reducible,
  47. cmArgumentList::iterator &arg,
  48. cmArgumentList &newArgs,
  49. cmArgumentList::iterator &argP1,
  50. cmArgumentList::iterator &argP2) const;
  51. void HandleBinaryOp(bool value, int &reducible,
  52. cmArgumentList::iterator &arg,
  53. cmArgumentList &newArgs,
  54. cmArgumentList::iterator &argP1,
  55. cmArgumentList::iterator &argP2);
  56. bool HandleLevel0(cmArgumentList &newArgs,
  57. std::string &errorString,
  58. cmake::MessageType &status);
  59. bool HandleLevel1(cmArgumentList &newArgs,
  60. std::string &, cmake::MessageType &);
  61. bool HandleLevel2(cmArgumentList &newArgs,
  62. std::string &errorString,
  63. cmake::MessageType &status);
  64. bool HandleLevel3(cmArgumentList &newArgs,
  65. std::string &errorString,
  66. cmake::MessageType &status);
  67. bool HandleLevel4(cmArgumentList &newArgs,
  68. std::string &errorString,
  69. cmake::MessageType &status);
  70. cmMakefile& Makefile;
  71. cmPolicies::PolicyStatus Policy12Status;
  72. cmPolicies::PolicyStatus Policy54Status;
  73. };
  74. #endif