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/Bindings/LuaJson.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/Bindings/LuaJson.cpp') diff --git a/src/Bindings/LuaJson.cpp b/src/Bindings/LuaJson.cpp index 1cd88cf96..1077b6e56 100644 --- a/src/Bindings/LuaJson.cpp +++ b/src/Bindings/LuaJson.cpp @@ -42,7 +42,7 @@ public: /** Constructs a new instance of the exception based on the provided values directly. */ explicit CannotSerializeException(int a_ValueIndex, const char * a_ErrorMsg): Super(a_ErrorMsg), - m_ValueName(Printf("%d", a_ValueIndex)) + m_ValueName(fmt::format(FMT_STRING("{}"), a_ValueIndex)) { } @@ -58,7 +58,7 @@ public: Used for prefixing the value name's path along the call stack that lead to the main exception. */ explicit CannotSerializeException(const CannotSerializeException & a_Parent, int a_ValueNamePrefixIndex): Super(a_Parent.what()), - m_ValueName(Printf("%d", a_ValueNamePrefixIndex) + "." + a_Parent.m_ValueName) + m_ValueName(fmt::format(FMT_STRING("{}"), a_ValueNamePrefixIndex) + "." + a_Parent.m_ValueName) { } @@ -299,7 +299,7 @@ static int tolua_cJson_Parse(lua_State * a_LuaState) AString ParseError; if (!JsonUtils::ParseString(input, root, &ParseError)) { - L.Push(cLuaState::Nil, Printf("Parsing Json failed: %s", ParseError)); + L.Push(cLuaState::Nil, fmt::format(FMT_STRING("Parsing Json failed: {}"), ParseError)); return 2; } @@ -338,7 +338,10 @@ static int tolua_cJson_Serialize(lua_State * a_LuaState) catch (const CannotSerializeException & exc) { lua_pushnil(L); - L.Push(Printf("Cannot serialize into Json, value \"%s\" caused an error \"%s\"", exc.GetValueName().c_str(), exc.what())); + L.Push(fmt::format( + FMT_STRING("Cannot serialize into Json, value \"{}\" caused an error \"{}\""), + exc.GetValueName(), exc.what() + )); return 2; } lua_pop(L, 1); -- cgit v1.2.3