From 83a5e453f8c0dc0fc9b6bdee9723478aafefd0da Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 3 Feb 2014 21:20:33 -0500 Subject: [PATCH] stringapi: Use strings for test names --- Source/cmCTest.cxx | 5 ++--- Source/cmCTest.h | 6 +++--- Source/cmMakefile.cxx | 21 +++++++-------------- Source/cmMakefile.h | 4 ++-- Source/cmSetTestsPropertiesCommand.cxx | 2 +- Source/cmSetTestsPropertiesCommand.h | 2 +- Source/cmTest.cxx | 6 +----- Source/cmTest.h | 4 ++-- 8 files changed, 19 insertions(+), 31 deletions(-) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 39b623d3c..72bb7fd76 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2126,7 +2126,7 @@ void cmCTest::HandleCommandLineArguments(size_t &i, if(this->CheckArgument(arg, "--overwrite") && i < args.size() - 1) { i++; - this->AddCTestConfigurationOverwrite(args[i].c_str()); + this->AddCTestConfigurationOverwrite(args[i]); } if(this->CheckArgument(arg, "-A", "--add-notes") && i < args.size() - 1) { @@ -2840,9 +2840,8 @@ void cmCTest::AddSubmitFile(Part part, const char* name) } //---------------------------------------------------------------------- -void cmCTest::AddCTestConfigurationOverwrite(const char* encstr) +void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr) { - std::string overStr = encstr; size_t epos = overStr.find("="); if ( epos == overStr.npos ) { diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 6418f0987..1eb0e01a8 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -70,8 +70,8 @@ public: { PartInfo(): Enabled(false) {} - void SetName(const char* name) { this->Name = name; } - const char* GetName() const { return this->Name.c_str(); } + void SetName(const std::string& name) { this->Name = name; } + const std::string& GetName() const { return this->Name; } void Enable() { this->Enabled = true; } operator bool() const { return this->Enabled; } @@ -349,7 +349,7 @@ public: //! Add overwrite to ctest configuration. // The format is key=value - void AddCTestConfigurationOverwrite(const char* encstr); + void AddCTestConfigurationOverwrite(const std::string& encstr); //! Create XML file that contains all the notes specified int GenerateNotesFile(const std::vector &files); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 97628f386..ff0576ed1 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3852,34 +3852,27 @@ cmTarget* cmMakefile::FindTarget(const std::string& name, } //---------------------------------------------------------------------------- -cmTest* cmMakefile::CreateTest(const char* testName) +cmTest* cmMakefile::CreateTest(const std::string& testName) { - if ( !testName ) - { - return 0; - } cmTest* test = this->GetTest(testName); if ( test ) { return test; } test = new cmTest(this); - test->SetName(testName); + test->SetName(testName.c_str()); this->Tests[testName] = test; return test; } //---------------------------------------------------------------------------- -cmTest* cmMakefile::GetTest(const char* testName) const +cmTest* cmMakefile::GetTest(const std::string& testName) const { - if(testName) + std::map::const_iterator + mi = this->Tests.find(testName); + if(mi != this->Tests.end()) { - std::map::const_iterator - mi = this->Tests.find(testName); - if(mi != this->Tests.end()) - { - return mi->second; - } + return mi->second; } return 0; } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index a8ad1e21b..044324ef3 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -782,12 +782,12 @@ public: void AddMacro(const char* name, const char* signature); ///! Add a new cmTest to the list of tests for this makefile. - cmTest* CreateTest(const char* testName); + cmTest* CreateTest(const std::string& testName); /** Get a cmTest pointer for a given test name, if the name is * not found, then a null pointer is returned. */ - cmTest* GetTest(const char* testName) const; + cmTest* GetTest(const std::string& testName) const; /** * Get a list of macros as a ; separated string diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx index 3d52cf242..c725d358a 100644 --- a/Source/cmSetTestsPropertiesCommand.cxx +++ b/Source/cmSetTestsPropertiesCommand.cxx @@ -91,7 +91,7 @@ bool cmSetTestsPropertiesCommand bool cmSetTestsPropertiesCommand -::SetOneTest(const char *tname, +::SetOneTest(const std::string& tname, std::vector &propertyPairs, cmMakefile *mf, std::string &errors) { diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h index 9e85495a9..7f8d57d13 100644 --- a/Source/cmSetTestsPropertiesCommand.h +++ b/Source/cmSetTestsPropertiesCommand.h @@ -36,7 +36,7 @@ public: cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand); - static bool SetOneTest(const char *tname, + static bool SetOneTest(const std::string& tname, std::vector &propertyPairs, cmMakefile *mf, std::string &errors); diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index 4ff71ac9a..28a7bb17c 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -38,12 +38,8 @@ cmListFileBacktrace const& cmTest::GetBacktrace() const } //---------------------------------------------------------------------------- -void cmTest::SetName(const char* name) +void cmTest::SetName(const std::string& name) { - if ( !name ) - { - name = ""; - } this->Name = name; } diff --git a/Source/cmTest.h b/Source/cmTest.h index 1becbf79e..a5795c3dd 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -31,8 +31,8 @@ public: ~cmTest(); ///! Set the test name - void SetName(const char* name); - const char* GetName() const { return this->Name.c_str(); } + void SetName(const std::string& name); + std::string GetName() const { return this->Name; } void SetCommand(std::vector const& command); std::vector const& GetCommand() const