1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 file Copyright.txt or https://cmake.org/licensing for details. */ 3 4 #pragma once 5 6 #include "cmConfigure.h" // IWYU pragma: keep 7 8 #include <string> 9 #include <vector> 10 11 #include <cm/string_view> 12 13 #include "cmLinkedTree.h" 14 #include "cmPolicies.h" 15 #include "cmStateTypes.h" 16 #include "cmValue.h" 17 18 class cmState; 19 class cmStateDirectory; 20 21 class cmStateSnapshot 22 { 23 public: 24 cmStateSnapshot(cmState* state = nullptr); 25 cmStateSnapshot(cmState* state, cmStateDetail::PositionType position); 26 27 cmValue GetDefinition(std::string const& name) const; 28 bool IsInitialized(std::string const& name) const; 29 void SetDefinition(std::string const& name, cm::string_view value); 30 void RemoveDefinition(std::string const& name); 31 std::vector<std::string> ClosureKeys() const; 32 bool RaiseScope(std::string const& var, const char* varDef); 33 34 void SetListFile(std::string const& listfile); 35 36 std::string const& GetExecutionListFile() const; 37 38 std::vector<cmStateSnapshot> GetChildren(); 39 40 bool IsValid() const; 41 cmStateSnapshot GetBuildsystemDirectory() const; 42 cmStateSnapshot GetBuildsystemDirectoryParent() const; 43 cmStateSnapshot GetCallStackParent() const; 44 cmStateSnapshot GetCallStackBottom() const; 45 cmStateEnums::SnapshotType GetType() const; 46 47 void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); 48 cmPolicies::PolicyStatus GetPolicy(cmPolicies::PolicyID id, 49 bool parent_scope = false) const; 50 bool HasDefinedPolicyCMP0011(); 51 void PushPolicy(cmPolicies::PolicyMap const& entry, bool weak); 52 bool PopPolicy(); 53 bool CanPopPolicyScope(); 54 55 cmState* GetState() const; 56 57 cmStateDirectory GetDirectory() const; 58 59 void SetProjectName(std::string const& name); 60 std::string GetProjectName() const; 61 62 void InitializeFromParent_ForSubdirsCommand(); 63 64 struct StrictWeakOrder 65 { 66 bool operator()(const cmStateSnapshot& lhs, 67 const cmStateSnapshot& rhs) const; 68 }; 69 70 void SetDirectoryDefinitions(); 71 void SetDefaultDefinitions(); 72 73 private: 74 friend bool operator==(const cmStateSnapshot& lhs, 75 const cmStateSnapshot& rhs); 76 friend bool operator!=(const cmStateSnapshot& lhs, 77 const cmStateSnapshot& rhs); 78 friend class cmState; 79 friend class cmStateDirectory; 80 friend struct StrictWeakOrder; 81 82 void InitializeFromParent(); 83 84 cmState* State; 85 cmStateDetail::PositionType Position; 86 }; 87 88 bool operator==(const cmStateSnapshot& lhs, const cmStateSnapshot& rhs); 89 bool operator!=(const cmStateSnapshot& lhs, const cmStateSnapshot& rhs); 90