From 48a9e91b02090ba263cd46ef5c33ba3d2aa873ba Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 4 May 2015 22:38:37 +0200 Subject: cmState: Add an accessor for Parent snapshot and a validity check. --- Source/cmState.cxx | 21 +++++++++++++++++++++ Source/cmState.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 67a2274..82a2939 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -522,3 +522,24 @@ void cmState::Snapshot::SetCurrentBinaryDirectory(std::string const& dir) cmSystemTools::CollapseFullPath( this->State->OutputLocations[this->Position]); } + +bool cmState::Snapshot::IsValid() const +{ + return this->State ? true : false; +} + +cmState::Snapshot cmState::Snapshot::GetParent() const +{ + Snapshot snapshot; + if (!this->State) + { + return snapshot; + } + PositionType parentPos = this->State->ParentPositions[this->Position]; + if (parentPos > 0) + { + snapshot = Snapshot(this->State, parentPos); + } + + return snapshot; +} diff --git a/Source/cmState.h b/Source/cmState.h index d10fae3..ed58c64 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -36,6 +36,9 @@ public: const char* GetCurrentBinaryDirectory() const; void SetCurrentBinaryDirectory(std::string const& dir); + bool IsValid() const; + Snapshot GetParent() const; + private: friend class cmState; cmState* State; -- cgit v0.12