1
0
Fork 0

Update submodules

This commit is contained in:
Tiger Wang 2020-05-04 19:21:48 +01:00
parent 07f3f7ec30
commit 330626ab22
13 changed files with 51 additions and 80 deletions

View File

@ -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;
}

View File

@ -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)

@ -1 +1 @@
Subproject commit 12cee38782897cfe60a1611615c200c45cd99eaf
Subproject commit 07472612522e4da6b96f589ccd1d20607c28c2b8

View File

@ -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...));
}

View File

@ -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);
}

View File

@ -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 */

View File

@ -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);
}

View File

@ -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);
};

View File

@ -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);
}

View File

@ -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) */

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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:
}
};
}