1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 11:19:10 +00:00

Provide some sample conversions to plFormat for testing and copying

This commit is contained in:
2014-05-18 19:59:27 -07:00
parent 2cb19d3308
commit 933ae6ec17
12 changed files with 51 additions and 52 deletions

View File

@ -49,7 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#pragma hdrstop
#include "hsTemplates.h"
#include "plString.h"
#include "plFormat.h"
///////////////////////////////////////////////////////////////////////////
@ -535,7 +535,7 @@ std::vector<plString> DisplaySystemVersion()
if ( osvi.dwMajorVersion <= 4 )
{
versionStrs.push_back(plString::Format("version %d.%d %s (Build %d)\n",
versionStrs.push_back(plFormat("version {}.{} {} (Build {})\n",
osvi.dwMajorVersion,
osvi.dwMinorVersion,
osvi.szCSDVersion,
@ -543,7 +543,7 @@ std::vector<plString> DisplaySystemVersion()
}
else
{
versionStrs.push_back(plString::Format("%s (Build %d)\n",
versionStrs.push_back(plFormat("{} (Build {})\n",
osvi.szCSDVersion,
osvi.dwBuildNumber & 0xFFFF));
}

View File

@ -204,8 +204,8 @@ plString hsStream::ReadSafeWStringLong()
uint32_t hsStream::WriteSafeString(const plString &string)
{
int len = string.GetSize();
hsAssert(len<0xf000, plString::Format("string len of %d is too long for WriteSafeString %s, use WriteSafeStringLong",
len, string.c_str()).c_str() );
hsAssert(len<0xf000, plFormat("string len of {} is too long for WriteSafeString {}, use WriteSafeStringLong",
len, string).c_str() );
WriteLE16(len | 0xf000);
if (len > 0)
@ -226,7 +226,7 @@ uint32_t hsStream::WriteSafeWString(const plString &string)
{
plStringBuffer<uint16_t> wbuff = string.ToUtf16();
uint32_t len = wbuff.GetSize();
hsAssert(len<0xf000, plString::Format("string len of %d is too long for WriteSafeWString, use WriteSafeWStringLong",
hsAssert(len<0xf000, plFormat("string len of {} is too long for WriteSafeWString, use WriteSafeWStringLong",
len).c_str() );
WriteLE16(len | 0xf000);

View File

@ -187,10 +187,8 @@ plFileName plFileName::Join(const plFileName &base, const plFileName &path)
char last = base.fName.CharAt(base.GetSize() - 1);
char first = path.fName.CharAt(0);
if (last != '/' && last != '\\') {
if (first != '/' && first != '\\') {
return plString::Format("%s" PATH_SEPARATOR_STR "%s",
base.fName.c_str(), path.fName.c_str());
}
if (first != '/' && first != '\\')
return plFormat("{}" PATH_SEPARATOR_STR "{}", base, path);
return base.fName + path.fName;
} else if (first != '/' && first != '\\') {
return base.fName + path.fName;
@ -549,7 +547,7 @@ plString plFileSystem::ConvertFileSize(uint64_t size)
{
const char* labels[] = { "KiB", "MiB", "GiB", "TiB", "PiB", "EiB" };
if (size < 1024)
return plString::Format("%i B");
return plFormat("{} B", size);
uint64_t last_div = size;
for (size_t i = 0; i < arrsize(labels); ++i) {
@ -566,5 +564,5 @@ plString plFileSystem::ConvertFileSize(uint64_t size)
}
// this should never happen
return plString::Format("%i %s", last_div, labels[arrsize(labels) - 1]);
return plFormat("{} {}", last_div, labels[arrsize(labels) - 1]);
}

View File

@ -44,7 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#pragma hdrstop
#include "plProduct.h"
#include "plString.h"
#include "plFormat.h"
static_assert(PRODUCT_BUILD_ID > 0, "Build ID cannot be zero");
static_assert(PRODUCT_BUILD_TYPE > 0, "Build Type cannot be zero");
@ -89,8 +89,8 @@ const char *plProduct::UUID() { return PRODUCT_UUID; }
plString plProduct::ProductString()
{
static plString _cache = plString::Format(
"%s.%u.%u - " RELEASE_ACCESS "." RELEASE_TYPE,
CoreName().c_str(), BranchId(), BuildId());
static plString _cache = plFormat(
"{}.{}.{} - " RELEASE_ACCESS "." RELEASE_TYPE,
CoreName(), BranchId(), BuildId());
return _cache;
}

View File

@ -47,6 +47,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#pragma hdrstop
#include "plString.h"
#include "plFormat.h"
#include <regex>
const plString plString::Null;
@ -609,7 +610,7 @@ bool plString::REMatch(const char *pattern, CaseSensitivity sense) const
if (std::regex_match(c_str(), re))
return true;
} catch (const std::regex_error& e) {
hsAssert(0, plString::Format("Regex match error: %s", e.what()).c_str());
hsAssert(0, plFormat("Regex match error: {}", e.what()).c_str());
}
return false;
@ -633,7 +634,7 @@ std::vector<plString> plString::RESearch(const char *pattern,
for (size_t i = 0; i < matches.size(); ++i)
substrings[i] = matches[i].str().c_str();
} catch (const std::regex_error& e) {
hsAssert(0, plString::Format("Regex search error: %s", e.what()).c_str());
hsAssert(0, plFormat("Regex search error: {}", e.what()).c_str());
}
return substrings;