diff options
author | Regina Pfeifer <regina@mailbox.org> | 2019-01-25 20:31:33 (GMT) |
---|---|---|
committer | Regina Pfeifer <regina@mailbox.org> | 2019-01-29 15:32:52 (GMT) |
commit | bcee24aecc1eaf6615eac9f24ae06acdf38845d3 (patch) | |
tree | 7a5ce493d66e1ff9a154bbd7503bd6e646624444 /Source/cmSystemTools.h | |
parent | 9620cb935a49e7b4955f5b1d0ffa2e93b4327591 (diff) | |
download | CMake-bcee24aecc1eaf6615eac9f24ae06acdf38845d3.zip CMake-bcee24aecc1eaf6615eac9f24ae06acdf38845d3.tar.gz CMake-bcee24aecc1eaf6615eac9f24ae06acdf38845d3.tar.bz2 |
Use `std::function` for callbacks
Diffstat (limited to 'Source/cmSystemTools.h')
-rw-r--r-- | Source/cmSystemTools.h | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index b1d5751..754929d 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -10,6 +10,7 @@ #include "cmProcessOutput.h" #include "cmsys/Process.h" #include "cmsys/SystemTools.hxx" // IWYU pragma: export +#include <functional> #include <stddef.h> #include <string> #include <vector> @@ -55,15 +56,14 @@ public: */ static std::string TrimWhitespace(const std::string& s); - typedef void (*MessageCallback)(const char*, const char*, bool&, void*); + using MessageCallback = std::function<void(const char*, const char*, bool&)>; /** * Set the function used by GUIs to display error messages * Function gets passed: message as a const char*, * title as a const char*, and a reference to bool that when * set to false, will disable further messages (cancel). */ - static void SetMessageCallback(MessageCallback f, - void* clientData = nullptr); + static void SetMessageCallback(MessageCallback f); /** * Display an error message. @@ -81,19 +81,18 @@ public: Message(m.c_str(), title); } - typedef void (*OutputCallback)(const char*, size_t length, void*); + using OutputCallback = std::function<void(const char*, size_t)>; ///! Send a string to stdout static void Stdout(const std::string& s); - static void SetStdoutCallback(OutputCallback, void* clientData = nullptr); + static void SetStdoutCallback(OutputCallback f); ///! Send a string to stderr static void Stderr(const std::string& s); - static void SetStderrCallback(OutputCallback, void* clientData = nullptr); + static void SetStderrCallback(OutputCallback f); - typedef bool (*InterruptCallback)(void*); - static void SetInterruptCallback(InterruptCallback f, - void* clientData = nullptr); + using InterruptCallback = std::function<bool()>; + static void SetInterruptCallback(InterruptCallback f); static bool GetInterruptFlag(); ///! Return true if there was an error at any point. @@ -548,14 +547,6 @@ private: static bool s_FatalErrorOccured; static bool s_DisableMessages; static bool s_DisableRunCommandOutput; - static MessageCallback s_MessageCallback; - static OutputCallback s_StdoutCallback; - static OutputCallback s_StderrCallback; - static InterruptCallback s_InterruptCallback; - static void* s_MessageCallbackClientData; - static void* s_StdoutCallbackClientData; - static void* s_StderrCallbackClientData; - static void* s_InterruptCallbackClientData; }; #endif |