cmSourceFileLocation: Make copyable and assignable.
This allows using it in containers and algorithms.
This commit is contained in:
parent
0ed5ce4cd8
commit
b1cbba68ce
|
@ -16,6 +16,42 @@
|
||||||
#include "cmGlobalGenerator.h"
|
#include "cmGlobalGenerator.h"
|
||||||
#include "cmSystemTools.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
|
||||||
::cmSourceFileLocation(cmMakefile const* mf, const std::string& name)
|
::cmSourceFileLocation(cmMakefile const* mf, const std::string& name)
|
||||||
|
@ -59,6 +95,7 @@ void cmSourceFileLocation::Update(cmSourceFileLocation const& loc)
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmSourceFileLocation::DirectoryUseSource()
|
void cmSourceFileLocation::DirectoryUseSource()
|
||||||
{
|
{
|
||||||
|
assert(this->Makefile);
|
||||||
if(this->AmbiguousDirectory)
|
if(this->AmbiguousDirectory)
|
||||||
{
|
{
|
||||||
this->Directory =
|
this->Directory =
|
||||||
|
@ -71,6 +108,7 @@ void cmSourceFileLocation::DirectoryUseSource()
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmSourceFileLocation::DirectoryUseBinary()
|
void cmSourceFileLocation::DirectoryUseBinary()
|
||||||
{
|
{
|
||||||
|
assert(this->Makefile);
|
||||||
if(this->AmbiguousDirectory)
|
if(this->AmbiguousDirectory)
|
||||||
{
|
{
|
||||||
this->Directory =
|
this->Directory =
|
||||||
|
@ -83,6 +121,7 @@ void cmSourceFileLocation::DirectoryUseBinary()
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmSourceFileLocation::UpdateExtension(const std::string& name)
|
void cmSourceFileLocation::UpdateExtension(const std::string& name)
|
||||||
{
|
{
|
||||||
|
assert(this->Makefile);
|
||||||
// Check the extension.
|
// Check the extension.
|
||||||
std::string ext = cmSystemTools::GetFilenameLastExtension(name);
|
std::string ext = cmSystemTools::GetFilenameLastExtension(name);
|
||||||
if(!ext.empty()) { ext = ext.substr(1); }
|
if(!ext.empty()) { ext = ext.substr(1); }
|
||||||
|
@ -152,6 +191,7 @@ bool
|
||||||
cmSourceFileLocation
|
cmSourceFileLocation
|
||||||
::MatchesAmbiguousExtension(cmSourceFileLocation const& loc) const
|
::MatchesAmbiguousExtension(cmSourceFileLocation const& loc) const
|
||||||
{
|
{
|
||||||
|
assert(this->Makefile);
|
||||||
// This location's extension is not ambiguous but loc's extension
|
// This location's extension is not ambiguous but loc's extension
|
||||||
// is. See if the names match as-is.
|
// is. See if the names match as-is.
|
||||||
if(this->Name == loc.Name)
|
if(this->Name == loc.Name)
|
||||||
|
@ -188,6 +228,7 @@ cmSourceFileLocation
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
|
bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
|
||||||
{
|
{
|
||||||
|
assert(this->Makefile);
|
||||||
if(this->AmbiguousExtension && loc.AmbiguousExtension)
|
if(this->AmbiguousExtension && loc.AmbiguousExtension)
|
||||||
{
|
{
|
||||||
// Both extensions are ambiguous. Since only the old fixed set of
|
// Both extensions are ambiguous. Since only the old fixed set of
|
||||||
|
|
|
@ -34,6 +34,9 @@ public:
|
||||||
* instance with an initial name.
|
* instance with an initial name.
|
||||||
*/
|
*/
|
||||||
cmSourceFileLocation(cmMakefile const* mf, const std::string& name);
|
cmSourceFileLocation(cmMakefile const* mf, const std::string& name);
|
||||||
|
cmSourceFileLocation();
|
||||||
|
cmSourceFileLocation(const cmSourceFileLocation& loc);
|
||||||
|
cmSourceFileLocation& operator=(const cmSourceFileLocation& loc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the givne source file location could refers to the
|
* Return whether the givne source file location could refers to the
|
||||||
|
|
Loading…
Reference in New Issue