diff --git a/include/GFModuleCommonUtils.hpp b/include/GFModuleCommonUtils.hpp index 3176784..2e18cc5 100644 --- a/include/GFModuleCommonUtils.hpp +++ b/include/GFModuleCommonUtils.hpp @@ -43,7 +43,7 @@ #define UDUP(v) UnStrDup(v) #define QDUP(v) QStrDup(v) -#define LISTEN(event) GFModuleListenEvent(GFGetModuleID(), DUP(event)); +#define LISTEN(event) GFModuleListenEvent(GFGetModuleID(), DUP(event)) #define EXECUTE_MODULE() \ auto GFExecuteModule(GFModuleEvent* p_event) -> int { \ @@ -51,14 +51,18 @@ #define END_EXECUTE_MODULE() } -#define CB_SUCC(event) \ - CB(event, GFGetModuleID(), {{"ret", "0"}}); \ - return 0; +#define CB_SUCC(event) \ + { \ + CB(event, GFGetModuleID(), {{"ret", "0"}}); \ + return 0; \ + } -#define CB_ERR(event, ret, err) \ - CB(event, GFGetModuleID(), \ - {{"ret", QString::number(ret)}, {"reason", QString(err)}}); \ - return ret; +#define CB_ERR(event, ret, err) \ + { \ + CB(event, GFGetModuleID(), \ + {{"ret", QString::number(ret)}, {"err", QString(err)}}); \ + return ret; \ + } inline void MLogDebug(const QString& s) { GFModuleLogDebug(s.toUtf8()); } inline void MLogInfo(const QString& s) { GFModuleLogInfo(s.toUtf8()); } @@ -292,11 +296,6 @@ inline auto CharArrayToQStringList(char** pl_components, return list; } -template -auto FormatString(const QString& format, Args... args) -> QString { - return FormatStringHelper(format, args...); -} - template auto FormatStringHelper(const QString& format, T arg) -> QString { return format.arg(arg); @@ -305,4 +304,13 @@ auto FormatStringHelper(const QString& format, T arg) -> QString { template auto FormatStringHelper(const QString& format, T arg, Args... args) -> QString { return FormatStringHelper(format.arg(arg), args...); -} \ No newline at end of file +} + +inline auto FormatStringHelper(const QString& format) -> QString { + return format; +} + +template +auto FormatString(const QString& format, Args... args) -> QString { + return FormatStringHelper(format, args...); +}