summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Tools/ProtoProxy/Connection.cpp14
-rw-r--r--Tools/ProtoProxy/Connection.h4
m---------lib/TCLAP0
-rw-r--r--src/Bindings/ManualBindings.h4
-rw-r--r--src/CommandOutput.cpp4
-rw-r--r--src/CommandOutput.h4
-rw-r--r--src/Logger.cpp20
-rw-r--r--src/Logger.h14
-rw-r--r--src/OSSupport/File.cpp8
-rw-r--r--src/OSSupport/File.h6
-rw-r--r--src/StringUtils.cpp24
-rw-r--r--src/StringUtils.h14
-rw-r--r--src/Vector3.h13
13 files changed, 50 insertions, 79 deletions
diff --git a/Tools/ProtoProxy/Connection.cpp b/Tools/ProtoProxy/Connection.cpp
index 3049826b6..4c72c7097 100644
--- a/Tools/ProtoProxy/Connection.cpp
+++ b/Tools/ProtoProxy/Connection.cpp
@@ -10,8 +10,6 @@
#include "mbedTLS++/CryptoKey.h"
#include "../../src/Logger.h"
-#include "fmt/printf.h"
-
#ifdef _WIN32
#include <direct.h> // For _mkdir()
#endif
@@ -284,12 +282,12 @@ void cConnection::Run(void)
-void cConnection::vLog(const char * a_Format, fmt::printf_args a_Args)
+void cConnection::vLog(const char * a_Format, fmt::printf_args a_ArgList)
{
// Log to file:
cCSLock Lock(m_CSLog);
fmt::fprintf(m_LogFile, "[%5.3f] ", GetRelativeTime());
- fmt::vfprintf(m_LogFile, a_Format, a_Args);
+ fmt::vfprintf(m_LogFile, a_Format, a_ArgList);
fmt::fprintf(m_LogFile, "\n");
#ifdef _DEBUG
fflush(m_LogFile);
@@ -303,7 +301,7 @@ void cConnection::vLog(const char * a_Format, fmt::printf_args a_Args)
-void cConnection::vDataLog(const void * a_Data, size_t a_Size, const char * a_Format, fmt::printf_args a_Args)
+void cConnection::vDataLog(const void * a_Data, size_t a_Size, const char * a_Format, fmt::printf_args a_ArgList)
{
AString Hex;
CreateHexDump(Hex, a_Data, a_Size, 16);
@@ -311,13 +309,11 @@ void cConnection::vDataLog(const void * a_Data, size_t a_Size, const char * a_Fo
// Log to file:
cCSLock Lock(m_CSLog);
fmt::fprintf(m_LogFile, "[%5.3f] ", GetRelativeTime());
- fmt::vfprintf(m_LogFile, a_Format, a_Args);
+ fmt::vfprintf(m_LogFile, a_Format, a_ArgList);
fmt::fprintf(m_LogFile, "\n%s\n", Hex);
- /*
// Log to screen:
- std::cout << FullMsg;
- //*/
+ // std::cout << FullMsg;
}
diff --git a/Tools/ProtoProxy/Connection.h b/Tools/ProtoProxy/Connection.h
index e52e1fa6d..6c13efba2 100644
--- a/Tools/ProtoProxy/Connection.h
+++ b/Tools/ProtoProxy/Connection.h
@@ -59,7 +59,7 @@ public:
void Run(void);
- void vLog(const char * a_Format, fmt::printf_args);
+ void vLog(const char * a_Format, fmt::printf_args a_ArgList);
template <typename... Args>
void Log(const char * a_Format, const Args & ... a_Args)
@@ -67,7 +67,7 @@ public:
vLog(a_Format, fmt::make_printf_args(a_Args...));
}
- void vDataLog(const void * a_Data, size_t a_Size, const char * a_Format, fmt::printf_args);
+ void vDataLog(const void * a_Data, size_t a_Size, const char * a_Format, fmt::printf_args a_ArgList);
template <typename... Args>
void DataLog(const void * a_Data, size_t a_Size, const char * a_Format, const Args & ... a_Args)
diff --git a/lib/TCLAP b/lib/TCLAP
-Subproject 12cee38782897cfe60a1611615c200c45cd99ea
+Subproject 07472612522e4da6b96f589ccd1d20607c28c2b
diff --git a/src/Bindings/ManualBindings.h b/src/Bindings/ManualBindings.h
index 137956046..a23c5d2e4 100644
--- a/src/Bindings/ManualBindings.h
+++ b/src/Bindings/ManualBindings.h
@@ -53,9 +53,9 @@ public:
static int tolua_do_error(lua_State * L, const char * a_pMsg, tolua_Error * a_pToLuaError);
static int vlua_do_error(lua_State * L, const char * a_pFormat, fmt::printf_args a_ArgList);
template <typename... Args>
- static int lua_do_error(lua_State * L, const char * a_Format, const Args & ... args)
+ static int lua_do_error(lua_State * L, const char * a_Format, const Args & ... a_Args)
{
- return vlua_do_error(L, a_Format, fmt::make_printf_args(args...));
+ return vlua_do_error(L, a_Format, fmt::make_printf_args(a_Args...));
}
diff --git a/src/CommandOutput.cpp b/src/CommandOutput.cpp
index 2d363da06..f4e223ed4 100644
--- a/src/CommandOutput.cpp
+++ b/src/CommandOutput.cpp
@@ -13,9 +13,9 @@
////////////////////////////////////////////////////////////////////////////////
// cCommandOutputCallback:
-void cCommandOutputCallback::vOut(const char * a_Fmt, fmt::printf_args args)
+void cCommandOutputCallback::vOut(const char * a_Fmt, fmt::printf_args a_ArgList)
{
- AString Output = ::vPrintf(a_Fmt, args);
+ AString Output = ::vPrintf(a_Fmt, a_ArgList);
Output.append("\n");
Out(Output);
}
diff --git a/src/CommandOutput.h b/src/CommandOutput.h
index cb40b05a6..91d3f61d7 100644
--- a/src/CommandOutput.h
+++ b/src/CommandOutput.h
@@ -21,9 +21,9 @@ public:
/** Syntax sugar function, calls Out() with Printf()-ed parameters; appends a newline" */
template <typename... Args>
- void Out(const char * a_Fmt, const Args & ... a_Args)
+ void Out(const char * a_Format, const Args & ... a_Args)
{
- vOut(a_Fmt, fmt::make_printf_args(a_Args...));
+ vOut(a_Format, fmt::make_printf_args(a_Args...));
}
/** Called when the command wants to output anything; may be called multiple times */
diff --git a/src/Logger.cpp b/src/Logger.cpp
index eac240790..e8306aa30 100644
--- a/src/Logger.cpp
+++ b/src/Logger.cpp
@@ -84,9 +84,7 @@ void cLogger::LogLine(std::string_view a_Line, eLogLevel a_LogLevel)
-void cLogger::LogPrintf(
- std::string_view a_Format, eLogLevel a_LogLevel, fmt::printf_args a_ArgList
-)
+void cLogger::LogPrintf(std::string_view a_Format, eLogLevel a_LogLevel, fmt::printf_args a_ArgList)
{
fmt::memory_buffer Buffer;
WriteLogOpener(Buffer);
@@ -100,9 +98,7 @@ void cLogger::LogPrintf(
-void cLogger::LogFormat(
- std::string_view a_Format, eLogLevel a_LogLevel, fmt::format_args a_ArgList
-)
+void cLogger::LogFormat(std::string_view a_Format, eLogLevel a_LogLevel, fmt::format_args a_ArgList)
{
fmt::memory_buffer Buffer;
WriteLogOpener(Buffer);
@@ -152,9 +148,7 @@ void cLogger::DetachListener(cListener * a_Listener)
////////////////////////////////////////////////////////////////////////////////
// Global functions
-void Logger::LogFormat(
- std::string_view a_Format, eLogLevel a_LogLevel, fmt::format_args a_ArgList
-)
+void Logger::LogFormat(std::string_view a_Format, eLogLevel a_LogLevel, fmt::format_args a_ArgList)
{
cLogger::GetInstance().LogFormat(a_Format, a_LogLevel, a_ArgList);
}
@@ -163,9 +157,7 @@ void Logger::LogFormat(
-void Logger::LogPrintf(
- std::string_view a_Format, eLogLevel a_LogLevel, fmt::printf_args a_ArgList
-)
+void Logger::LogPrintf(std::string_view a_Format, eLogLevel a_LogLevel, fmt::printf_args a_ArgList)
{
cLogger::GetInstance().LogPrintf(a_Format, a_LogLevel, a_ArgList);
}
@@ -178,7 +170,3 @@ void Logger::LogSimple(std::string_view a_Message, eLogLevel a_LogLevel)
{
cLogger::GetInstance().LogSimple(a_Message, a_LogLevel);
}
-
-
-
-
diff --git a/src/Logger.h b/src/Logger.h
index ef86b3313..fee2554be 100644
--- a/src/Logger.h
+++ b/src/Logger.h
@@ -50,14 +50,10 @@ public:
};
/** Log a message formatted with a printf style formatting string. */
- void LogPrintf(
- std::string_view a_Format, eLogLevel a_LogLevel, fmt::printf_args a_ArgList
- );
+ void LogPrintf(std::string_view a_Format, eLogLevel a_LogLevel, fmt::printf_args a_ArgList);
/** Log a message formatted with a python style formatting string. */
- void LogFormat(
- std::string_view a_Format, eLogLevel a_LogLevel, fmt::format_args a_ArgList
- );
+ void LogFormat(std::string_view a_Format, eLogLevel a_LogLevel, fmt::format_args a_ArgList);
/** Logs the simple text message at the specified log level. */
void LogSimple(std::string_view a_Message, eLogLevel a_LogLevel = eLogLevel::Regular);
@@ -65,8 +61,10 @@ public:
cAttachment AttachListener(std::unique_ptr<cListener> a_Listener);
static cLogger & GetInstance(void);
+
// Must be called before calling GetInstance in a multithreaded context
static void InitiateMultithreading();
+
private:
cCriticalSection m_CriticalSection;
@@ -74,8 +72,4 @@ private:
void DetachListener(cListener * a_Listener);
void LogLine(std::string_view a_Line, eLogLevel a_LogLevel);
-
};
-
-
-
diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp
index 2d26c3cd6..f860c37ca 100644
--- a/src/OSSupport/File.cpp
+++ b/src/OSSupport/File.cpp
@@ -695,10 +695,10 @@ AString cFile::GetExecutableExt(void)
-int cFile::vPrintf(const char * a_Fmt, fmt::printf_args a_ArgList)
+int cFile::vPrintf(const char * a_Format, fmt::printf_args a_ArgList)
{
fmt::memory_buffer Buffer;
- fmt::vprintf(Buffer, fmt::to_string_view(a_Fmt), a_ArgList);
+ fmt::vprintf(Buffer, fmt::to_string_view(a_Format), a_ArgList);
return Write(Buffer.data(), Buffer.size());
}
@@ -710,7 +710,3 @@ void cFile::Flush(void)
{
fflush(m_File);
}
-
-
-
-
diff --git a/src/OSSupport/File.h b/src/OSSupport/File.h
index 689900816..9987c41c7 100644
--- a/src/OSSupport/File.h
+++ b/src/OSSupport/File.h
@@ -168,11 +168,11 @@ public:
/** Returns the list of all items in the specified folder (files, folders, nix pipes, whatever's there). */
static AStringVector GetFolderContents(const AString & a_Folder); // Exported in ManualBindings.cpp
- int vPrintf(const char * a_Fmt, fmt::printf_args);
+ int vPrintf(const char * a_Format, fmt::printf_args a_ArgList);
template <typename... Args>
- int Printf(const char * a_Fmt, const Args & ... a_Args)
+ int Printf(const char * a_Format, const Args & ... a_Args)
{
- return vPrintf(a_Fmt, fmt::make_printf_args(a_Args...));
+ return vPrintf(a_Format, fmt::make_printf_args(a_Args...));
}
/** Flushes all the bufferef output into the file (only when writing) */
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp
index fc19decb3..e6fbcc6fe 100644
--- a/src/StringUtils.cpp
+++ b/src/StringUtils.cpp
@@ -52,34 +52,34 @@ static unsigned char HexToDec(char a_HexChar)
-AString & vPrintf(AString & str, const char * format, fmt::printf_args args)
+AString & vPrintf(AString & a_String, const char * a_Format, fmt::printf_args a_ArgList)
{
- ASSERT(format != nullptr);
- fmt::memory_buffer Buffer;
- fmt::vprintf(Buffer, fmt::to_string_view(format), args);
- str.assign(Buffer.data(), Buffer.size());
- return str;
+ ASSERT(a_Format != nullptr);
+ fmt::memory_buffer Buffer; // Save a string allocation compared to vsprintf
+ fmt::vprintf(Buffer, fmt::to_string_view(a_Format), a_ArgList);
+ a_String.assign(Buffer.data(), Buffer.size());
+ return a_String;
}
-AString vPrintf(const char * format, fmt::printf_args args)
+AString vPrintf(const char * a_Format, fmt::printf_args a_ArgList)
{
- ASSERT(format != nullptr);
- return fmt::vsprintf(format, args);
+ ASSERT(a_Format != nullptr);
+ return fmt::vsprintf(a_Format, a_ArgList);
}
-AString & vAppendPrintf(AString & a_String, const char * format, fmt::printf_args args)
+AString & vAppendPrintf(AString & a_String, const char * a_Format, fmt::printf_args a_ArgList)
{
- ASSERT(format != nullptr);
+ ASSERT(a_Format != nullptr);
fmt::memory_buffer Buffer;
- fmt::vprintf(Buffer, fmt::to_string_view(format), args);
+ fmt::vprintf(Buffer, fmt::to_string_view(a_Format), a_ArgList);
a_String.append(Buffer.data(), Buffer.size());
return a_String;
}
diff --git a/src/StringUtils.h b/src/StringUtils.h
index 0013762a2..12cd06140 100644
--- a/src/StringUtils.h
+++ b/src/StringUtils.h
@@ -23,25 +23,25 @@ typedef std::map<AString, AString> AStringMap;
/** Output the formatted text into the string.
Returns a_Dst. */
-extern AString & vPrintf(AString & a_Dst, const char * format, fmt::printf_args args);
+extern AString & vPrintf(AString & a_Dst, const char * a_Format, fmt::printf_args a_ArgList);
template <typename... Args>
-AString & Printf(AString & a_Dst, const char * a_Format, const Args & ... args)
+AString & Printf(AString & a_Dst, const char * a_Format, const Args & ... a_Args)
{
- return vPrintf(a_Dst, a_Format, fmt::make_printf_args(args...));
+ return vPrintf(a_Dst, a_Format, fmt::make_printf_args(a_Args...));
}
/** Output the formatted text into string
Returns the formatted string by value. */
-extern AString vPrintf(const char * format, fmt::printf_args args);
+extern AString vPrintf(const char * a_Format, fmt::printf_args a_ArgList);
template <typename... Args>
-AString Printf(const char * a_Format, const Args & ... args)
+AString Printf(const char * a_Format, const Args & ... a_Args)
{
- return vPrintf(a_Format, fmt::make_printf_args(args...));
+ return vPrintf(a_Format, fmt::make_printf_args(a_Args...));
}
/** Add the formated string to the existing data in the string.
Returns a_Dst. */
-extern AString & vAppendPrintf(AString & a_Dst, const char * a_Format, fmt::printf_args args);
+extern AString & vAppendPrintf(AString & a_Dst, const char * a_Format, fmt::printf_args a_ArgList);
template <typename... Args>
extern AString & AppendPrintf(AString & a_Dst, const char * a_Format, const Args & ... a_Args)
{
diff --git a/src/Vector3.h b/src/Vector3.h
index 05c9c66de..0c7008763 100644
--- a/src/Vector3.h
+++ b/src/Vector3.h
@@ -400,26 +400,25 @@ public:
-namespace fmt
-{
+/** Allows formatting a Vector<T> using the same format specifiers as for T
+e.g. `fmt::format("{0:0.2f}", Vector3f{0.0231f, 1.2146f, 1.0f}) == "{0.02, 1.21, 1.00}"` */
template <typename What>
-class formatter<Vector3<What>>:
- public fmt::formatter<What>
+class fmt::formatter<Vector3<What>> : public fmt::formatter<What>
{
using Super = fmt::formatter<What>;
template <typename FormatContext, size_t Len>
void Write(FormatContext & a_Ctx, const char (& a_Str)[Len])
{
- auto Itr = std::copy_n(&a_Str[0], Len - 1, a_Ctx.out());
+ const auto Itr = std::copy_n(&a_Str[0], Len - 1, a_Ctx.out());
a_Ctx.advance_to(Itr);
}
template <typename FormatContext>
void Write(FormatContext & a_Ctx, const What & a_Arg)
{
- auto Itr = Super::format(a_Arg, a_Ctx);
+ const auto Itr = Super::format(a_Arg, a_Ctx);
a_Ctx.advance_to(Itr);
}
@@ -440,8 +439,6 @@ public:
}
};
-}
-