From c9522fb740200ccef6230cec452c48efb31e5394 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 11 May 2023 22:05:17 +0200 Subject: Removed all Printf-family functions from StringUtils. Replaced them with fmt::format calls, including changes to the format strings. Also changed the format strings to use FMT_STRING, so that the format is checked compile-time against the arguments. Also fixed code-style violations already present in the code. --- src/CommandOutput.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src/CommandOutput.h') diff --git a/src/CommandOutput.h b/src/CommandOutput.h index 91d3f61d7..6ee859970 100644 --- a/src/CommandOutput.h +++ b/src/CommandOutput.h @@ -17,20 +17,18 @@ class cCommandOutputCallback public: virtual ~cCommandOutputCallback() {} // Force a virtual destructor in subclasses - void vOut(const char * a_Fmt, fmt::printf_args); + /** Called when the command wants to output anything; may be called multiple times */ + virtual void Out(const AString & a_Text) = 0; - /** Syntax sugar function, calls Out() with Printf()-ed parameters; appends a newline" */ - template - void Out(const char * a_Format, const Args & ... a_Args) + /** Outputs the specified text, plus a newline. */ + void OutLn(const AString & aText) { - vOut(a_Format, fmt::make_printf_args(a_Args...)); + Out(aText); + Out("\n"); } - /** Called when the command wants to output anything; may be called multiple times */ - virtual void Out(const AString & a_Text) = 0; - /** Called when the command processing has been finished */ - virtual void Finished(void) {} + virtual void Finished() {} } ; @@ -63,10 +61,10 @@ public: // cCommandOutputCallback overrides: virtual void Out(const AString & a_Text) override; - virtual void Finished(void) override {} + virtual void Finished() override {} /** Returns the accumulated command output in a string. */ - const AString & GetAccum(void) const { return m_Accum; } + const AString & GetAccum() const { return m_Accum; } protected: /** Output is stored here until the command finishes processing */ @@ -83,7 +81,7 @@ class cLogCommandOutputCallback : { public: // cStringAccumCommandOutputCallback overrides: - virtual void Finished(void) override; + virtual void Finished() override; } ; @@ -96,7 +94,7 @@ class cLogCommandDeleteSelfOutputCallback: { using Super = cLogCommandOutputCallback; - virtual void Finished(void) override + virtual void Finished() override { Super::Finished(); delete this; -- cgit v1.2.3