Now that fmt plays nice with gcc let's actually use it: replace std::to_string, boost lexical_cast and a couple miscellaneous llformats with fmt. (Alchemy sync-ish)

This commit is contained in:
Router Gray
2020-05-20 14:38:30 -05:00
parent 34a7ebf53f
commit 3e78b74474
31 changed files with 92 additions and 113 deletions

View File

@@ -299,6 +299,7 @@ target_link_libraries(
${Boost_SYSTEM_LIBRARY}
${CORESERVICES_LIBRARY}
${URIPARSER_LIBRARY}
fmt::fmt
nlohmann_json::nlohmann_json
absl::strings
${RT_LIBRARY}

View File

@@ -34,6 +34,16 @@
#ifndef LL_LLFORMAT_H
#define LL_LLFORMAT_H
#if defined(LL_CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated"
#endif
#include <fmt/format.h>
#include <fmt/printf.h>
#if defined(LL_CLANG)
#pragma clang diagnostic pop
#endif
// Use as follows:
// LL_INFOS() << llformat("Test:%d (%.2f %.2f)", idx, x, y) << LL_ENDL;
//

View File

@@ -1354,8 +1354,7 @@ void LLStringUtil::formatNumber(std::string& numStr, std::string decimals)
if (convertToS32(numStr, intStr))
{
strStream << intStr;
numStr = strStream.str();
numStr = fmt::to_string(intStr);
}
}
else
@@ -1435,14 +1434,14 @@ bool LLStringUtil::formatDatetime(std::string& replacement, std::string token,
{
struct tm * gmt = gmtime (&loc_seconds);
LLStringUtil::format_map_t args;
args["[MDAY]"] = llformat ("%d", gmt->tm_mday);
args["[MDAY]"] = fmt::to_string(gmt->tm_mday);
replacement = LLStringOps::sDayFormat;
LLStringUtil::format(replacement, args);
}
else if (code == "%-d")
{
struct tm * gmt = gmtime (&loc_seconds);
replacement = llformat ("%d", gmt->tm_mday); // day of the month without leading zero
replacement = fmt::to_string(gmt->tm_mday); // day of the month without leading zero
}
else if( !LLStringOps::sAM.empty() && !LLStringOps::sPM.empty() && code == "%p" )
{