summaryrefslogtreecommitdiffstats
path: root/Source/cmCMakePolicyCommand.cxx
diff options
context:
space:
mode:
authorAsit Dhal <dhal.asitk@gmail.com>2019-09-15 17:11:02 (GMT)
committerBrad King <brad.king@kitware.com>2019-09-18 18:18:46 (GMT)
commit9dba84cfa5e85e51ee6d6799f03a26656063ef8b (patch)
tree22fb29536def399e2ab763ac202a52467d45d7e2 /Source/cmCMakePolicyCommand.cxx
parent1423507a71199fd76b457ad9b215a6caca70ee58 (diff)
downloadCMake-9dba84cfa5e85e51ee6d6799f03a26656063ef8b.zip
CMake-9dba84cfa5e85e51ee6d6799f03a26656063ef8b.tar.gz
CMake-9dba84cfa5e85e51ee6d6799f03a26656063ef8b.tar.bz2
Refactor: Use cmStrCat to construct error strings
Replace string construction using std::stringstream with cmStrCat and cmWrap.
Diffstat (limited to 'Source/cmCMakePolicyCommand.cxx')
-rw-r--r--Source/cmCMakePolicyCommand.cxx47
1 files changed, 21 insertions, 26 deletions
diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx
index 9b1aea9..b7f08d2 100644
--- a/Source/cmCMakePolicyCommand.cxx
+++ b/Source/cmCMakePolicyCommand.cxx
@@ -2,14 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCMakePolicyCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
namespace {
bool HandleSetMode(std::vector<std::string> const& args,
@@ -60,9 +59,7 @@ bool cmCMakePolicyCommand(std::vector<std::string> const& args,
return HandleGetWarningMode(args, status);
}
- std::ostringstream e;
- e << "given unknown first argument \"" << args[0] << "\"";
- status.SetError(e.str());
+ status.SetError(cmStrCat("given unknown first argument \"", args[0], "\""));
return false;
}
@@ -82,9 +79,8 @@ bool HandleSetMode(std::vector<std::string> const& args,
} else if (args[2] == "NEW") {
policyStatus = cmPolicies::NEW;
} else {
- std::ostringstream e;
- e << "SET given unrecognized policy status \"" << args[2] << "\"";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("SET given unrecognized policy status \"", args[2], "\""));
return false;
}
@@ -128,10 +124,9 @@ bool HandleGetMode(std::vector<std::string> const& args,
// Lookup the policy number.
cmPolicies::PolicyID pid;
if (!cmPolicies::GetPolicyID(id.c_str(), pid)) {
- std::ostringstream e;
- e << "GET given policy \"" << id << "\" which is not known to this "
- << "version of CMake.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("GET given policy \"", id,
+ "\" which is not known to this version of CMake."));
return false;
}
@@ -155,12 +150,14 @@ bool HandleGetMode(std::vector<std::string> const& args,
case cmPolicies::REQUIRED_ALWAYS:
// The policy is required to be set before anything needs it.
{
- std::ostringstream e;
- e << cmPolicies::GetRequiredPolicyError(pid) << "\n"
- << "The call to cmake_policy(GET " << id << " ...) at which this "
- << "error appears requests the policy, and this version of CMake "
- << "requires that the policy be set to NEW before it is checked.";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ cmPolicies::GetRequiredPolicyError(pid), "\n",
+ "The call to cmake_policy(GET ", id,
+ " ...) at which this "
+ "error appears requests the policy, and this version of CMake ",
+ "requires that the policy be set to NEW before it is checked."));
}
}
@@ -188,10 +185,9 @@ bool HandleVersionMode(std::vector<std::string> const& args,
: std::string();
if (dd != std::string::npos &&
(version_min.empty() || version_max.empty())) {
- std::ostringstream e;
- e << "VERSION \"" << version_string
- << R"(" does not have a version on both sides of "...".)";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("VERSION \"", version_string,
+ R"(" does not have a version on both sides of "...".)"));
return false;
}
@@ -215,10 +211,9 @@ bool HandleGetWarningMode(std::vector<std::string> const& args,
// Lookup the policy number.
cmPolicies::PolicyID pid;
if (!cmPolicies::GetPolicyID(id.c_str(), pid)) {
- std::ostringstream e;
- e << "GET_WARNING given policy \"" << id
- << "\" which is not known to this version of CMake.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("GET_WARNING given policy \"", id,
+ "\" which is not known to this version of CMake."));
return false;
}