summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-02-08 13:47:57 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-02-08 13:49:35 (GMT)
commit89ca5d7fdce7730f38a719683059bbe02e6fb19d (patch)
tree8f9141729231e42ee47a2837d986801ee423607b /Source
parentbf1279450496db727a646afb29109cb9eba3c7b4 (diff)
parent82edd98300b9d050dd28fdfa1e6ea7b18ecca22c (diff)
downloadCMake-89ca5d7fdce7730f38a719683059bbe02e6fb19d.zip
CMake-89ca5d7fdce7730f38a719683059bbe02e6fb19d.tar.gz
CMake-89ca5d7fdce7730f38a719683059bbe02e6fb19d.tar.bz2
Merge topic 'message-stdstring'
82edd98300 cmSystemTools: MessageCallback and Message() accept std::string argument Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2929
Diffstat (limited to 'Source')
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx2
-rw-r--r--Source/CursesDialog/ccmake.cxx2
-rw-r--r--Source/CursesDialog/cmCursesForm.h4
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx3
-rw-r--r--Source/CursesDialog/cmCursesMainForm.h2
-rw-r--r--Source/QtDialog/QCMake.cxx6
-rw-r--r--Source/QtDialog/QCMake.h2
-rw-r--r--Source/cmServer.cxx7
-rw-r--r--Source/cmServer.h2
-rw-r--r--Source/cmSystemTools.cxx6
-rw-r--r--Source/cmSystemTools.h8
-rw-r--r--Source/cmakemain.cxx25
12 files changed, 35 insertions, 34 deletions
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 2fd4c7a..3856569 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -118,7 +118,7 @@ public:
: CM(cm)
{
cmSystemTools::SetMessageCallback(
- [&s](const char* msg, const char* /*unused*/) {
+ [&s](const std::string& msg, const char* /*unused*/) {
s += msg;
s += "\n";
});
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index f2982a6..745c6bb 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -150,7 +150,7 @@ int main(int argc, char const* const* argv)
}
cmSystemTools::SetMessageCallback(
- [myform](const char* message, const char* title) {
+ [myform](const std::string& message, const char* title) {
myform->AddError(message, title);
});
diff --git a/Source/CursesDialog/cmCursesForm.h b/Source/CursesDialog/cmCursesForm.h
index ddb67de..7842905 100644
--- a/Source/CursesDialog/cmCursesForm.h
+++ b/Source/CursesDialog/cmCursesForm.h
@@ -9,6 +9,8 @@
#include "cmsys/FStream.hxx"
+#include <string>
+
class cmCursesForm
{
public:
@@ -34,7 +36,7 @@ public:
// Description:
// During a CMake run, an error handle should add errors
// to be displayed afterwards.
- virtual void AddError(const char*, const char*) {}
+ virtual void AddError(const std::string&, const char*) {}
// Description:
// Turn debugging on. This will create ccmakelog.txt.
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 8ca7802..f6a1a57 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -647,7 +647,8 @@ int cmCursesMainForm::Generate()
return 0;
}
-void cmCursesMainForm::AddError(const char* message, const char* /*unused*/)
+void cmCursesMainForm::AddError(const std::string& message,
+ const char* /*unused*/)
{
this->Errors.emplace_back(message);
}
diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h
index cc6482f..c09ce2a 100644
--- a/Source/CursesDialog/cmCursesMainForm.h
+++ b/Source/CursesDialog/cmCursesMainForm.h
@@ -81,7 +81,7 @@ public:
* During a CMake run, an error handle should add errors
* to be displayed afterwards.
*/
- void AddError(const char* message, const char* title) override;
+ void AddError(const std::string& message, const char* title) override;
/**
* Used to do a configure. If argument is specified, it does only the check
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index a073c30..6442d05 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -25,7 +25,7 @@ QCMake::QCMake(QObject* p)
cmSystemTools::SetRunCommandHideConsole(true);
cmSystemTools::SetMessageCallback(
- [this](const char* msg, const char* title) {
+ [this](std::string const& msg, const char* title) {
this->messageCallback(msg, title);
});
cmSystemTools::SetStdoutCallback(
@@ -359,9 +359,9 @@ void QCMake::progressCallback(const char* msg, float percent)
QCoreApplication::processEvents();
}
-void QCMake::messageCallback(const char* msg, const char* /*title*/)
+void QCMake::messageCallback(std::string const& msg, const char* /*title*/)
{
- emit this->errorMessage(QString::fromLocal8Bit(msg));
+ emit this->errorMessage(QString::fromStdString(msg));
QCoreApplication::processEvents();
}
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index ef4d2a1..8492606 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -169,7 +169,7 @@ protected:
bool interruptCallback();
void progressCallback(const char* msg, float percent);
- void messageCallback(const char* msg, const char* title);
+ void messageCallback(std::string const& msg, const char* title);
void stdoutCallback(std::string const& msg);
void stderrCallback(std::string const& msg);
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index e740c05..719e6b1 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -97,7 +97,7 @@ void cmServer::ProcessRequest(cmConnection* connection,
}
cmSystemTools::SetMessageCallback(
- [&request](const char* msg, const char* title) {
+ [&request](const std::string& msg, const char* title) {
reportMessage(msg, title, request);
});
@@ -165,15 +165,14 @@ void cmServer::reportProgress(const char* msg, float progress,
}
}
-void cmServer::reportMessage(const char* msg, const char* title,
+void cmServer::reportMessage(const std::string& msg, const char* title,
const cmServerRequest& request)
{
- assert(msg);
std::string titleString;
if (title) {
titleString = title;
}
- request.ReportMessage(std::string(msg), titleString);
+ request.ReportMessage(msg, titleString);
}
cmServerResponse cmServer::SetProtocolVersion(const cmServerRequest& request)
diff --git a/Source/cmServer.h b/Source/cmServer.h
index e1ed27a..3edc887 100644
--- a/Source/cmServer.h
+++ b/Source/cmServer.h
@@ -121,7 +121,7 @@ public:
private:
static void reportProgress(const char* msg, float progress,
const cmServerRequest& request);
- static void reportMessage(const char* msg, const char* title,
+ static void reportMessage(const std::string& msg, const char* title,
const cmServerRequest& request);
// Handle requests:
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index b3e6e62..89bf2f8 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -323,16 +323,16 @@ void cmSystemTools::Stdout(const std::string& s)
}
}
-void cmSystemTools::Message(const char* m1, const char* title)
+void cmSystemTools::Message(const std::string& m, const char* title)
{
if (s_DisableMessages) {
return;
}
if (s_MessageCallback) {
- s_MessageCallback(m1, title);
+ s_MessageCallback(m, title);
return;
}
- std::cerr << m1 << std::endl << std::flush;
+ std::cerr << m << std::endl << std::flush;
}
void cmSystemTools::ReportLastSystemError(const char* msg)
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 798bcba..88758a6 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -56,7 +56,7 @@ public:
*/
static std::string TrimWhitespace(const std::string& s);
- using MessageCallback = std::function<void(const char*, const char*)>;
+ using MessageCallback = std::function<void(const std::string&, const char*)>;
/**
* Set the function used by GUIs to display error messages
* Function gets passed: message as a const char*,
@@ -74,11 +74,7 @@ public:
/**
* Display a message.
*/
- static void Message(const char* m, const char* title = nullptr);
- static void Message(const std::string& m, const char* title = nullptr)
- {
- Message(m.c_str(), title);
- }
+ static void Message(const std::string& m, const char* title = nullptr);
using OutputCallback = std::function<void(std::string const&)>;
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 890b74e..a49246b 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -142,8 +142,8 @@ static std::string cmakemainGetStack(cmake* cm)
return msg;
}
-static void cmakemainMessageCallback(const char* m, const char* /*unused*/,
- cmake* cm)
+static void cmakemainMessageCallback(const std::string& m,
+ const char* /*unused*/, cmake* cm)
{
std::cerr << m << cmakemainGetStack(cm) << std::endl << std::flush;
}
@@ -319,9 +319,10 @@ int do_cmake(int ac, char const* const* av)
cmake cm(role, mode);
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
- cmSystemTools::SetMessageCallback([&cm](const char* msg, const char* title) {
- cmakemainMessageCallback(msg, title, &cm);
- });
+ cmSystemTools::SetMessageCallback(
+ [&cm](const std::string& msg, const char* title) {
+ cmakemainMessageCallback(msg, title, &cm);
+ });
cm.SetProgressCallback([&cm](const char* msg, float prog) {
cmakemainProgressCallback(msg, prog, &cm);
});
@@ -499,9 +500,10 @@ static int do_build(int ac, char const* const* av)
}
cmake cm(cmake::RoleInternal, cmState::Unknown);
- cmSystemTools::SetMessageCallback([&cm](const char* msg, const char* title) {
- cmakemainMessageCallback(msg, title, &cm);
- });
+ cmSystemTools::SetMessageCallback(
+ [&cm](const std::string& msg, const char* title) {
+ cmakemainMessageCallback(msg, title, &cm);
+ });
cm.SetProgressCallback([&cm](const char* msg, float prog) {
cmakemainProgressCallback(msg, prog, &cm);
});
@@ -541,9 +543,10 @@ static int do_open(int ac, char const* const* av)
}
cmake cm(cmake::RoleInternal, cmState::Unknown);
- cmSystemTools::SetMessageCallback([&cm](const char* msg, const char* title) {
- cmakemainMessageCallback(msg, title, &cm);
- });
+ cmSystemTools::SetMessageCallback(
+ [&cm](const std::string& msg, const char* title) {
+ cmakemainMessageCallback(msg, title, &cm);
+ });
cm.SetProgressCallback([&cm](const char* msg, float prog) {
cmakemainProgressCallback(msg, prog, &cm);
});