mirror of
https://github.com/reactos/CMake.git
synced 2024-12-12 05:45:51 +00:00
cmSystemTools: MessageCallback and Message() accept std::string argument
This commit is contained in:
parent
062cfd991f
commit
82edd98300
@ -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";
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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&)>;
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user