summaryrefslogtreecommitdiffstats
path: root/Source/cmSourceFileLocation.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-02-26 12:26:05 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-03-31 21:18:43 (GMT)
commitb1cbba68ce44bf8d78a6e41ff465461f0abf83a9 (patch)
tree2eadc633a8b0d830e3e528cf2e9b6fd39675de9c /Source/cmSourceFileLocation.cxx
parent0ed5ce4cd8cdd7613a5fa43c9a9fc48f210c90f6 (diff)
downloadCMake-b1cbba68ce44bf8d78a6e41ff465461f0abf83a9.zip
CMake-b1cbba68ce44bf8d78a6e41ff465461f0abf83a9.tar.gz
CMake-b1cbba68ce44bf8d78a6e41ff465461f0abf83a9.tar.bz2
cmSourceFileLocation: Make copyable and assignable.
This allows using it in containers and algorithms.
Diffstat (limited to 'Source/cmSourceFileLocation.cxx')
-rw-r--r--Source/cmSourceFileLocation.cxx41
1 files changed, 41 insertions, 0 deletions
diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx
index 30a53cb..3e78b29 100644
--- a/Source/cmSourceFileLocation.cxx
+++ b/Source/cmSourceFileLocation.cxx
@@ -16,6 +16,42 @@
#include "cmGlobalGenerator.h"
#include "cmSystemTools.h"
+#include "assert.h"
+
+//----------------------------------------------------------------------------
+cmSourceFileLocation::cmSourceFileLocation()
+ : Makefile(0), AmbiguousDirectory(true), AmbiguousExtension(true)
+{
+
+}
+
+//----------------------------------------------------------------------------
+cmSourceFileLocation::cmSourceFileLocation(const cmSourceFileLocation& loc)
+ : Makefile(loc.Makefile)
+{
+ this->AmbiguousDirectory = loc.AmbiguousDirectory;
+ this->AmbiguousExtension = loc.AmbiguousExtension;
+ this->Directory = loc.Directory;
+ this->Name = loc.Name;
+}
+
+//----------------------------------------------------------------------------
+cmSourceFileLocation&
+cmSourceFileLocation::operator=(const cmSourceFileLocation& loc)
+{
+ if(this == &loc)
+ {
+ return *this;
+ }
+ this->Makefile = loc.Makefile;
+ this->AmbiguousDirectory = loc.AmbiguousDirectory;
+ this->AmbiguousExtension = loc.AmbiguousExtension;
+ this->Directory = loc.Directory;
+ this->Name = loc.Name;
+ this->UpdateExtension(this->Name);
+ return *this;
+}
+
//----------------------------------------------------------------------------
cmSourceFileLocation
::cmSourceFileLocation(cmMakefile const* mf, const std::string& name)
@@ -59,6 +95,7 @@ void cmSourceFileLocation::Update(cmSourceFileLocation const& loc)
//----------------------------------------------------------------------------
void cmSourceFileLocation::DirectoryUseSource()
{
+ assert(this->Makefile);
if(this->AmbiguousDirectory)
{
this->Directory =
@@ -71,6 +108,7 @@ void cmSourceFileLocation::DirectoryUseSource()
//----------------------------------------------------------------------------
void cmSourceFileLocation::DirectoryUseBinary()
{
+ assert(this->Makefile);
if(this->AmbiguousDirectory)
{
this->Directory =
@@ -83,6 +121,7 @@ void cmSourceFileLocation::DirectoryUseBinary()
//----------------------------------------------------------------------------
void cmSourceFileLocation::UpdateExtension(const std::string& name)
{
+ assert(this->Makefile);
// Check the extension.
std::string ext = cmSystemTools::GetFilenameLastExtension(name);
if(!ext.empty()) { ext = ext.substr(1); }
@@ -152,6 +191,7 @@ bool
cmSourceFileLocation
::MatchesAmbiguousExtension(cmSourceFileLocation const& loc) const
{
+ assert(this->Makefile);
// This location's extension is not ambiguous but loc's extension
// is. See if the names match as-is.
if(this->Name == loc.Name)
@@ -188,6 +228,7 @@ cmSourceFileLocation
//----------------------------------------------------------------------------
bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
{
+ assert(this->Makefile);
if(this->AmbiguousExtension && loc.AmbiguousExtension)
{
// Both extensions are ambiguous. Since only the old fixed set of