cmConditionEvaluator.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #include <list>
  15. class cmConditionEvaluator
  16. {
  17. public:
  18. typedef std::list<cmExpandedCommandArgument> cmArgumentList;
  19. cmConditionEvaluator(cmMakefile& makefile);
  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,
  25. cmake::MessageType &status);
  26. private:
  27. // Filter the given variable definition based on policy CMP0054.
  28. const char* GetDefinitionIfUnquoted(
  29. const cmExpandedCommandArgument& argument) const;
  30. const char* GetVariableOrString(
  31. const cmExpandedCommandArgument& argument) const;
  32. bool IsKeyword(std::string const& keyword,
  33. cmExpandedCommandArgument& argument) const;
  34. bool GetBooleanValue(
  35. cmExpandedCommandArgument& arg) const;
  36. bool GetBooleanValueOld(
  37. cmExpandedCommandArgument const& arg, bool one) const;
  38. bool GetBooleanValueWithAutoDereference(
  39. cmExpandedCommandArgument &newArg,
  40. std::string &errorString,
  41. cmake::MessageType &status,
  42. bool oneArg = false) const;
  43. void IncrementArguments(
  44. cmArgumentList &newArgs,
  45. cmArgumentList::iterator &argP1,
  46. cmArgumentList::iterator &argP2) const;
  47. void HandlePredicate(bool value, int &reducible,
  48. cmArgumentList::iterator &arg,
  49. cmArgumentList &newArgs,
  50. cmArgumentList::iterator &argP1,
  51. cmArgumentList::iterator &argP2) const;
  52. void HandleBinaryOp(bool value, int &reducible,
  53. cmArgumentList::iterator &arg,
  54. cmArgumentList &newArgs,
  55. cmArgumentList::iterator &argP1,
  56. cmArgumentList::iterator &argP2);
  57. bool HandleLevel0(cmArgumentList &newArgs,
  58. std::string &errorString,
  59. cmake::MessageType &status);
  60. bool HandleLevel1(cmArgumentList &newArgs,
  61. std::string &, cmake::MessageType &);
  62. bool HandleLevel2(cmArgumentList &newArgs,
  63. std::string &errorString,
  64. cmake::MessageType &status);
  65. bool HandleLevel3(cmArgumentList &newArgs,
  66. std::string &errorString,
  67. cmake::MessageType &status);
  68. bool HandleLevel4(cmArgumentList &newArgs,
  69. std::string &errorString,
  70. cmake::MessageType &status);
  71. cmMakefile& Makefile;
  72. cmPolicies::PolicyStatus Policy12Status;
  73. cmPolicies::PolicyStatus Policy54Status;
  74. };
  75. #endif