Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/core
diff options
context:
space:
mode:
Diffstat (limited to 'source/core')
-rw-r--r--source/core/StarAudio.cpp12
-rw-r--r--source/core/StarBTreeDatabase.cpp14
-rw-r--r--source/core/StarBiMap.hpp6
-rw-r--r--source/core/StarBuffer.cpp4
-rw-r--r--source/core/StarByteArray.cpp4
-rw-r--r--source/core/StarByteArray.hpp2
-rw-r--r--source/core/StarCasting.hpp4
-rw-r--r--source/core/StarColor.cpp4
-rw-r--r--source/core/StarCompression.cpp16
-rw-r--r--source/core/StarException_unix.cpp10
-rw-r--r--source/core/StarException_windows.cpp6
-rw-r--r--source/core/StarFile.cpp4
-rw-r--r--source/core/StarFile_unix.cpp34
-rw-r--r--source/core/StarFile_windows.cpp54
-rw-r--r--source/core/StarFont.cpp2
-rw-r--r--source/core/StarFormattedJson.cpp34
-rw-r--r--source/core/StarHostAddress.cpp10
-rw-r--r--source/core/StarIODevice.cpp4
-rw-r--r--source/core/StarIdMap.hpp2
-rw-r--r--source/core/StarImage.cpp20
-rw-r--r--source/core/StarImageProcessing.cpp40
-rw-r--r--source/core/StarJson.cpp32
-rw-r--r--source/core/StarJsonBuilder.cpp2
-rw-r--r--source/core/StarJsonBuilder.hpp8
-rw-r--r--source/core/StarJsonExtra.cpp8
-rw-r--r--source/core/StarJsonExtra.hpp12
-rw-r--r--source/core/StarJsonPatch.cpp12
-rw-r--r--source/core/StarJsonPath.cpp10
-rw-r--r--source/core/StarJsonPath.hpp26
-rw-r--r--source/core/StarJsonRpc.cpp12
-rw-r--r--source/core/StarLexicalCast.hpp2
-rw-r--r--source/core/StarList.hpp4
-rw-r--r--source/core/StarLockFile_unix.cpp4
-rw-r--r--source/core/StarLockFile_windows.cpp2
-rw-r--r--source/core/StarLogging.cpp4
-rw-r--r--source/core/StarLogging.hpp2
-rw-r--r--source/core/StarLua.cpp8
-rw-r--r--source/core/StarLua.hpp18
-rw-r--r--source/core/StarMap.hpp10
-rw-r--r--source/core/StarMultiArray.hpp6
-rw-r--r--source/core/StarNetElementContainers.hpp4
-rw-r--r--source/core/StarNetImpl.hpp4
-rw-r--r--source/core/StarOptionParser.cpp48
-rw-r--r--source/core/StarOrderedMap.hpp16
-rw-r--r--source/core/StarSignalHandler_windows.cpp8
-rw-r--r--source/core/StarSmallVector.hpp6
-rw-r--r--source/core/StarSocket.cpp20
-rw-r--r--source/core/StarStaticVector.hpp8
-rw-r--r--source/core/StarString.cpp4
-rw-r--r--source/core/StarString.hpp2
-rw-r--r--source/core/StarStringView.cpp4
-rw-r--r--source/core/StarTcp.cpp16
-rw-r--r--source/core/StarThread_unix.cpp16
-rw-r--r--source/core/StarThread_windows.cpp6
-rw-r--r--source/core/StarTime.cpp8
-rw-r--r--source/core/StarTime_unix.cpp14
-rw-r--r--source/core/StarTime_windows.cpp14
-rw-r--r--source/core/StarUdp.cpp6
-rw-r--r--source/core/StarUnicode.cpp2
-rw-r--r--source/core/StarUuid.cpp2
-rw-r--r--source/core/StarWorkerPool.cpp2
61 files changed, 339 insertions, 339 deletions
diff --git a/source/core/StarAudio.cpp b/source/core/StarAudio.cpp
index 7e4cd31..ef5d2f4 100644
--- a/source/core/StarAudio.cpp
+++ b/source/core/StarAudio.cpp
@@ -59,13 +59,13 @@ namespace {
uint32_t fileSize = readLEType<uint32_t>(device);
fileSize += sigLength + sizeof(fileSize);
if (fileSize != device->size())
- throw AudioException(strf("Wav file is wrong size, reports %d is actually %d", fileSize, device->size()));
+ throw AudioException(strf("Wav file is wrong size, reports {} is actually {}", fileSize, device->size()));
device->readFull(waveSig.get(), sigLength);
if ((strcmp(riffSig.get(), "RIFF") != 0) || (strcmp(waveSig.get(), "WAVE") != 0)) { // bytes are not magic
auto p = [](char a) { return isprint(a) ? a : '?'; };
- throw AudioException(strf("Wav file has wrong magic bytes, got `%c%c%c%c' and `%c%c%c%c' but expected `RIFF' and `WAVE'",
+ throw AudioException(strf("Wav file has wrong magic bytes, got `{}{}{}{}' and `{}{}{}{}' but expected `RIFF' and `WAVE'",
p(riffSig[0]), p(riffSig[1]), p(riffSig[2]), p(riffSig[3]), p(waveSig[0]), p(waveSig[1]), p(waveSig[2]), p(waveSig[3])));
}
@@ -74,7 +74,7 @@ namespace {
device->readFull(fmtSig.get(), sigLength);
if (strcmp(fmtSig.get(), "fmt ") != 0) { // friendship is magic
auto p = [](char a) { return isprint(a) ? a : '?'; };
- throw AudioException(strf("Wav file fmt subchunk has wrong magic bytes, got `%c%c%c%c' but expected `fmt '",
+ throw AudioException(strf("Wav file fmt subchunk has wrong magic bytes, got `{}{}{}{}' but expected `fmt '",
p(fmtSig[0]),
p(fmtSig[1]),
p(fmtSig[2]),
@@ -84,7 +84,7 @@ namespace {
uint32_t fmtSubchunkSize = readLEType<uint32_t>(device);
fmtSubchunkSize += sigLength;
if (fmtSubchunkSize < 20)
- throw AudioException(strf("fmt subchunk is sized wrong, expected 20 got %d. Is this wav file not PCM?", fmtSubchunkSize));
+ throw AudioException(strf("fmt subchunk is sized wrong, expected 20 got {}. Is this wav file not PCM?", fmtSubchunkSize));
uint16_t audioFormat = readLEType<uint16_t>(device);
if (audioFormat != 1)
@@ -110,14 +110,14 @@ namespace {
device->readFull(dataSig.get(), sigLength);
if (strcmp(dataSig.get(), "data") != 0) { // magic or more magic?
auto p = [](char a) { return isprint(a) ? a : '?'; };
- throw AudioException(strf("Wav file data subchunk has wrong magic bytes, got `%c%c%c%c' but expected `data'",
+ throw AudioException(strf("Wav file data subchunk has wrong magic bytes, got `{}{}{}{}' but expected `data'",
p(dataSig[0]), p(dataSig[1]), p(dataSig[2]), p(dataSig[3])));
}
uint32_t wavDataSize = readLEType<uint32_t>(device);
size_t wavDataOffset = (size_t)device->pos();
if (wavDataSize + wavDataOffset > (size_t)device->size()) {
- throw AudioException(strf("Wav file data size reported is inconsistent with file size, got %d but expected %d",
+ throw AudioException(strf("Wav file data size reported is inconsistent with file size, got {} but expected {}",
device->size(), wavDataSize + wavDataOffset));
}
diff --git a/source/core/StarBTreeDatabase.cpp b/source/core/StarBTreeDatabase.cpp
index 6983df8..4ac321f 100644
--- a/source/core/StarBTreeDatabase.cpp
+++ b/source/core/StarBTreeDatabase.cpp
@@ -886,7 +886,7 @@ void BTreeDatabase::updateBlock(BlockIndex blockIndex, ByteArray const& block) {
void BTreeDatabase::rawReadBlock(BlockIndex blockIndex, size_t blockOffset, char* block, size_t size) const {
if (blockOffset > m_blockSize || size > m_blockSize - blockOffset)
- throw DBException::format("Read past end of block, offset: %s size %s", blockOffset, size);
+ throw DBException::format("Read past end of block, offset: {} size {}", blockOffset, size);
if (size <= 0)
return;
@@ -896,7 +896,7 @@ void BTreeDatabase::rawReadBlock(BlockIndex blockIndex, size_t blockOffset, char
void BTreeDatabase::rawWriteBlock(BlockIndex blockIndex, size_t blockOffset, char const* block, size_t size) const {
if (blockOffset > m_blockSize || size > m_blockSize - blockOffset)
- throw DBException::format("Write past end of block, offset: %s size %s", blockOffset, size);
+ throw DBException::format("Write past end of block, offset: {} size {}", blockOffset, size);
if (size <= 0)
return;
@@ -910,7 +910,7 @@ auto BTreeDatabase::readFreeIndexBlock(BlockIndex blockIndex) -> FreeIndexBlock
ByteArray magic(2, 0);
rawReadBlock(blockIndex, 0, magic.ptr(), 2);
if (magic != ByteArray(FreeIndexMagic, 2))
- throw DBException::format("Internal exception! block %s missing free index block marker!", blockIndex);
+ throw DBException::format("Internal exception! block {} missing free index block marker!", blockIndex);
FreeIndexBlock freeIndexBlock;
DataStreamBuffer buffer(max(sizeof(BlockIndex), (size_t)4));
@@ -1124,20 +1124,20 @@ void BTreeDatabase::doCommit() {
void BTreeDatabase::checkIfOpen(char const* methodName, bool shouldBeOpen) const {
if (shouldBeOpen && !m_open)
- throw DBException::format("BTreeDatabase method '%s' called when not open, must be open.", methodName);
+ throw DBException::format("BTreeDatabase method '{}' called when not open, must be open.", methodName);
else if (!shouldBeOpen && m_open)
- throw DBException::format("BTreeDatabase method '%s' called when open, cannot call when open.", methodName);
+ throw DBException::format("BTreeDatabase method '{}' called when open, cannot call when open.", methodName);
}
void BTreeDatabase::checkBlockIndex(size_t blockIndex) const {
BlockIndex blockCount = (m_deviceSize - HeaderSize) / m_blockSize;
if (blockIndex >= blockCount)
- throw DBException::format("blockIndex: %s out of block range", blockIndex);
+ throw DBException::format("blockIndex: {} out of block range", blockIndex);
}
void BTreeDatabase::checkKeySize(ByteArray const& k) const {
if (k.size() != m_keySize)
- throw DBException::format("Wrong key size %s", k.size());
+ throw DBException::format("Wrong key size {}", k.size());
}
uint32_t BTreeDatabase::maxFreeIndexLength() const {
diff --git a/source/core/StarBiMap.hpp b/source/core/StarBiMap.hpp
index 3953fde..8e3d616 100644
--- a/source/core/StarBiMap.hpp
+++ b/source/core/StarBiMap.hpp
@@ -179,7 +179,7 @@ template <typename LeftT, typename RightT, typename LeftMapT, typename RightMapT
BiMap<LeftT, RightT, LeftMapT, RightMapT>::BiMap(std::initializer_list<value_type> list) {
for (value_type const& v : list) {
if (!insert(v.first, v.second))
- throw MapException::format("Repeat pair in BiMap initializer_list construction: (%s, %s)", outputAny(v.first), outputAny(v.second));
+ throw MapException::format("Repeat pair in BiMap initializer_list construction: ({}, {})", outputAny(v.first), outputAny(v.second));
}
}
@@ -324,10 +324,10 @@ bool BiMap<LeftT, RightT, LeftMapT, RightMapT>::insert(Left const& left, Right c
template <typename LeftT, typename RightT, typename LeftMapT, typename RightMapT>
void BiMap<LeftT, RightT, LeftMapT, RightMapT>::add(Left const& left, Right const& right) {
if (m_leftMap.contains(left))
- throw MapException(strf("BiMap already contains left side value '%s'", outputAny(left)));
+ throw MapException(strf("BiMap already contains left side value '{}'", outputAny(left)));
if (m_rightMap.contains(right))
- throw MapException(strf("BiMap already contains right side value '%s'", outputAny(right)));
+ throw MapException(strf("BiMap already contains right side value '{}'", outputAny(right)));
insert(left, right);
}
diff --git a/source/core/StarBuffer.cpp b/source/core/StarBuffer.cpp
index e99615c..3212e0a 100644
--- a/source/core/StarBuffer.cpp
+++ b/source/core/StarBuffer.cpp
@@ -90,7 +90,7 @@ void Buffer::open(IOMode mode) {
}
String Buffer::deviceName() const {
- return strf("Buffer <%s>", (void*)this);
+ return strf("Buffer <{}>", (void*)this);
}
StreamOffset Buffer::size() {
@@ -244,7 +244,7 @@ size_t ExternalBuffer::writeAbsolute(StreamOffset, char const*, size_t) {
}
String ExternalBuffer::deviceName() const {
- return strf("ExternalBuffer <%s>", (void*)this);
+ return strf("ExternalBuffer <{}>", (void*)this);
}
StreamOffset ExternalBuffer::size() {
diff --git a/source/core/StarByteArray.cpp b/source/core/StarByteArray.cpp
index 944071b..6414c46 100644
--- a/source/core/StarByteArray.cpp
+++ b/source/core/StarByteArray.cpp
@@ -85,14 +85,14 @@ void ByteArray::reserve(size_t newCapacity) {
if (!m_data) {
auto newMem = (char*)Star::malloc(newCapacity);
if (!newMem)
- throw MemoryException::format("Could not set new ByteArray capacity %s\n", newCapacity);
+ throw MemoryException::format("Could not set new ByteArray capacity {}\n", newCapacity);
m_data = newMem;
m_capacity = newCapacity;
} else {
newCapacity = max({m_capacity * 2, newCapacity, (size_t)8});
auto newMem = (char*)Star::realloc(m_data, newCapacity);
if (!newMem)
- throw MemoryException::format("Could not set new ByteArray capacity %s\n", newCapacity);
+ throw MemoryException::format("Could not set new ByteArray capacity {}\n", newCapacity);
m_data = newMem;
m_capacity = newCapacity;
}
diff --git a/source/core/StarByteArray.hpp b/source/core/StarByteArray.hpp
index 9f63643..cb5633b 100644
--- a/source/core/StarByteArray.hpp
+++ b/source/core/StarByteArray.hpp
@@ -242,7 +242,7 @@ inline char ByteArray::operator[](size_t i) const {
inline char ByteArray::at(size_t i) const {
if (i >= m_size)
- throw OutOfRangeException(strf("Out of range in ByteArray::at(%s)", i));
+ throw OutOfRangeException(strf("Out of range in ByteArray::at({})", i));
return m_data[i];
}
diff --git a/source/core/StarCasting.hpp b/source/core/StarCasting.hpp
index 64305af..0c2ed12 100644
--- a/source/core/StarCasting.hpp
+++ b/source/core/StarCasting.hpp
@@ -61,11 +61,11 @@ shared_ptr<Type1 const> as(shared_ptr<Type2 const> const& p) {
template <typename Type, typename Ptr>
auto convert(Ptr const& p) -> decltype(as<Type>(p)) {
if (!p)
- throw PointerConvertException::format("Could not convert from nullptr to %s", typeid(Type).name());
+ throw PointerConvertException::format("Could not convert from nullptr to {}", typeid(Type).name());
else if (auto a = as<Type>(p))
return a;
else
- throw PointerConvertException::format("Could not convert from %s to %s", typeid(*p).name(), typeid(Type).name());
+ throw PointerConvertException::format("Could not convert from {} to {}", typeid(*p).name(), typeid(Type).name());
}
template <typename Type1, typename Type2>
diff --git a/source/core/StarColor.cpp b/source/core/StarColor.cpp
index 915620d..e0d6842 100644
--- a/source/core/StarColor.cpp
+++ b/source/core/StarColor.cpp
@@ -221,7 +221,7 @@ Color::Color(const String& name) {
if (i != NamedColors.end())
*this = i->second;
else
- throw ColorException(strf("Named color %s not found", name), false);
+ throw ColorException(strf("Named color {} not found", name), false);
}
}
@@ -622,7 +622,7 @@ Vec4B Color::hexToVec4B(StringView s) {
} else if (s.utf8Size() == 8) {
hexDecode(s.utf8Ptr(), 8, (char*)cbytes.data(), 4);
} else {
- throw ColorException(strf("Improper size for hex string '%s' in Color::hexToVec4B", s), false);
+ throw ColorException(strf("Improper size for hex string '{}' in Color::hexToVec4B", s), false);
}
return Vec4B(move(cbytes));
diff --git a/source/core/StarCompression.cpp b/source/core/StarCompression.cpp
index e8d282c..2aaf17f 100644
--- a/source/core/StarCompression.cpp
+++ b/source/core/StarCompression.cpp
@@ -23,7 +23,7 @@ void compressData(ByteArray const& in, ByteArray& out, CompressionLevel compress
strm.opaque = Z_NULL;
int deflate_res = deflateInit(&strm, compression);
if (deflate_res != Z_OK)
- throw IOException(strf("Failed to initialise deflate (%d)", deflate_res));
+ throw IOException(strf("Failed to initialise deflate ({})", deflate_res));
strm.next_in = (unsigned char*)in.ptr();
strm.avail_in = in.size();
@@ -40,7 +40,7 @@ void compressData(ByteArray const& in, ByteArray& out, CompressionLevel compress
deflateEnd(&strm);
if (deflate_res != Z_STREAM_END)
- throw IOException(strf("Internal error in uncompressData, deflate_res is %s", deflate_res));
+ throw IOException(strf("Internal error in uncompressData, deflate_res is {}", deflate_res));
out.append((char const*)temp_buffer, BUFSIZE - strm.avail_out);
}
@@ -66,7 +66,7 @@ void uncompressData(ByteArray const& in, ByteArray& out) {
strm.opaque = Z_NULL;
int inflate_res = inflateInit(&strm);
if (inflate_res != Z_OK)
- throw IOException(strf("Failed to initialise inflate (%d)", inflate_res));
+ throw IOException(strf("Failed to initialise inflate ({})", inflate_res));
strm.next_in = (unsigned char*)in.ptr();
strm.avail_in = in.size();
@@ -86,7 +86,7 @@ void uncompressData(ByteArray const& in, ByteArray& out) {
inflateEnd(&strm);
if (inflate_res != Z_STREAM_END)
- throw IOException(strf("Internal error in uncompressData, inflate_res is %s", inflate_res));
+ throw IOException(strf("Internal error in uncompressData, inflate_res is {}", inflate_res));
out.append((char const*)temp_buffer, BUFSIZE - strm.avail_out);
}
@@ -134,7 +134,7 @@ void CompressedFile::seek(StreamOffset offset, IOSeek seekMode) {
StreamOffset endPos = pos();
if (retCode < 0) {
- throw IOException::format("Seek error: %s", gzerror((gzFile)m_file, 0));
+ throw IOException::format("Seek error: {}", gzerror((gzFile)m_file, 0));
} else if ((seekMode == IOSeek::Relative && begPos + offset != endPos)
|| (seekMode == IOSeek::Absolute && offset != endPos)) {
throw EofException("Error, unexpected end of file found");
@@ -153,7 +153,7 @@ size_t CompressedFile::read(char* data, size_t len) {
if (ret == 0)
throw EofException("Error, unexpected end of file found");
else if (ret == -1)
- throw IOException::format("Read error: %s", gzerror((gzFile)m_file, 0));
+ throw IOException::format("Read error: {}", gzerror((gzFile)m_file, 0));
else
return (size_t)ret;
}
@@ -164,7 +164,7 @@ size_t CompressedFile::write(const char* data, size_t len) {
int ret = gzwrite((gzFile)m_file, data, len);
if (ret == 0)
- throw IOException::format("Write error: %s", gzerror((gzFile)m_file, 0));
+ throw IOException::format("Write error: {}", gzerror((gzFile)m_file, 0));
else
return (size_t)ret;
}
@@ -210,7 +210,7 @@ void CompressedFile::open(IOMode mode) {
m_file = gzopen(m_filename.utf8Ptr(), modeString.utf8Ptr());
if (!m_file)
- throw IOException::format("Cannot open filename '%s'", m_filename);
+ throw IOException::format("Cannot open filename '{}'", m_filename);
}
void CompressedFile::close() {
diff --git a/source/core/StarException_unix.cpp b/source/core/StarException_unix.cpp
index 578c0b4..71ffd2b 100644
--- a/source/core/StarException_unix.cpp
+++ b/source/core/StarException_unix.cpp
@@ -112,23 +112,23 @@ OutputProxy outputException(std::exception const& e, bool fullStacktrace) {
}
void printStack(char const* message) {
- Logger::info("Stack Trace (%s)...\n%s", message, outputStack(captureStack()));
+ Logger::info("Stack Trace ({})...\n{}", message, outputStack(captureStack()));
}
void fatalError(char const* message, bool showStackTrace) {
if (showStackTrace)
- Logger::error("Fatal Error: %s\n%s", message, outputStack(captureStack()));
+ Logger::error("Fatal Error: {}\n{}", message, outputStack(captureStack()));
else
- Logger::error("Fatal Error: %s", message);
+ Logger::error("Fatal Error: {}", message);
std::abort();
}
void fatalException(std::exception const& e, bool showStackTrace) {
if (showStackTrace)
- Logger::error("Fatal Exception caught: %s\nCaught at:\n%s", outputException(e, true), outputStack(captureStack()));
+ Logger::error("Fatal Exception caught: {}\nCaught at:\n{}", outputException(e, true), outputStack(captureStack()));
else
- Logger::error("Fatal Exception caught: %s", outputException(e, showStackTrace));
+ Logger::error("Fatal Exception caught: {}", outputException(e, showStackTrace));
std::abort();
}
diff --git a/source/core/StarException_windows.cpp b/source/core/StarException_windows.cpp
index 7fd386c..54254d4 100644
--- a/source/core/StarException_windows.cpp
+++ b/source/core/StarException_windows.cpp
@@ -127,9 +127,9 @@ OutputProxy outputStack(StackCapture stack) {
symbol->MaxNameLen = MAX_SYM_NAME;
DWORD64 displacement = 0;
- format(os, "[%i] %p", i, stack.first[i]);
+ format(os, "[{}] {}", i, (void*)stack.first[i]);
if (SymFromAddr(process, stack.first[i], &displacement, symbol))
- format(os, " %s", symbol->Name);
+ format(os, " {}", symbol->Name);
if (i + 1 < stack.second)
os << std::endl;
@@ -224,7 +224,7 @@ OutputProxy outputException(std::exception const& e, bool fullStacktrace) {
}
void printStack(char const* message) {
- Logger::info("Stack Trace (%s)...\n%s", message, outputStack(captureStack()));
+ Logger::info("Stack Trace ({})...\n{}", message, outputStack(captureStack()));
}
void fatalError(char const* message, bool showStackTrace) {
diff --git a/source/core/StarFile.cpp b/source/core/StarFile.cpp
index 738a088..ec09ff7 100644
--- a/source/core/StarFile.cpp
+++ b/source/core/StarFile.cpp
@@ -104,8 +104,8 @@ void File::overwriteFileWithRename(String const& data, String const& filename, S
void File::backupFileInSequence(String const& targetFile, unsigned maximumBackups, String const& backupExtensionPrefix) {
for (unsigned i = maximumBackups; i > 0; --i) {
- String curExtension = i == 1 ? "" : strf("%s%s", backupExtensionPrefix, i - 1);
- String nextExtension = strf("%s%s", backupExtensionPrefix, i);
+ String curExtension = i == 1 ? "" : strf("{}{}", backupExtensionPrefix, i - 1);
+ String nextExtension = strf("{}{}", backupExtensionPrefix, i);
if (File::isFile(targetFile + curExtension))
File::copy(targetFile + curExtension, targetFile + nextExtension);
diff --git a/source/core/StarFile_unix.cpp b/source/core/StarFile_unix.cpp
index aa22bc8..abc9fe0 100644
--- a/source/core/StarFile_unix.cpp
+++ b/source/core/StarFile_unix.cpp
@@ -46,19 +46,19 @@ String File::currentDirectory() {
void File::changeDirectory(const String& dirName) {
if (::chdir(dirName.utf8Ptr()) != 0)
- throw IOException(strf("could not change directory to %s", dirName));
+ throw IOException(strf("could not change directory to {}", dirName));
}
void File::makeDirectory(String const& dirName) {
if (::mkdir(dirName.utf8Ptr(), 0777) != 0)
- throw IOException(strf("could not create directory '%s', %s", dirName, strerror(errno)));
+ throw IOException(strf("could not create directory '{}', {}", dirName, strerror(errno)));
}
List<pair<String, bool>> File::dirList(const String& dirName, bool skipDots) {
List<std::pair<String, bool>> fileList;
DIR* directory = ::opendir(dirName.utf8Ptr());
if (directory == NULL)
- throw IOException::format("dirList failed on dir: '%s'", dirName);
+ throw IOException::format("dirList failed on dir: '{}'", dirName);
for (dirent* entry = ::readdir(directory); entry != NULL; entry = ::readdir(directory)) {
String entryString = entry->d_name;
@@ -113,13 +113,13 @@ String File::fullPath(const String& fileName) {
char buffer[PATH_MAX];
if (::realpath(fileName.utf8Ptr(), buffer) == NULL)
- throw IOException::format("realpath failed on file: '%s' problem path was: '%s'", fileName, buffer);
+ throw IOException::format("realpath failed on file: '{}' problem path was: '{}'", fileName, buffer);
return String(buffer);
}
String File::temporaryFileName() {
- return relativeTo(P_tmpdir, strf("starbound.tmpfile.%s", hexEncode(Random::randBytes(16))));
+ return relativeTo(P_tmpdir, strf("starbound.tmpfile.{}", hexEncode(Random::randBytes(16))));
}
FilePtr File::temporaryFile() {
@@ -131,16 +131,16 @@ FilePtr File::ephemeralFile() {
ByteArray path = ByteArray::fromCStringWithNull(relativeTo(P_tmpdir, "starbound.tmpfile.XXXXXXXX").utf8Ptr());
auto res = mkstemp(path.ptr());
if (res < 0)
- throw IOException::format("tmpfile error: %s", strerror(errno));
+ throw IOException::format("tmpfile error: {}", strerror(errno));
if (::unlink(path.ptr()) < 0)
- throw IOException::format("Could not remove mkstemp file when creating ephemeralFile: %s", strerror(errno));
+ throw IOException::format("Could not remove mkstemp file when creating ephemeralFile: {}", strerror(errno));
file->m_file = handleFromFd(res);
file->setMode(IOMode::ReadWrite);
return file;
}
String File::temporaryDirectory() {
- String dirname = relativeTo(P_tmpdir, strf("starbound.tmpdir.%s", hexEncode(Random::randBytes(16))));
+ String dirname = relativeTo(P_tmpdir, strf("starbound.tmpdir.{}", hexEncode(Random::randBytes(16))));
makeDirectory(dirname);
return dirname;
}
@@ -171,12 +171,12 @@ bool File::isDirectory(String const& path) {
void File::remove(String const& filename) {
if (::remove(filename.utf8Ptr()) < 0)
- throw IOException::format("remove error: %s", strerror(errno));
+ throw IOException::format("remove error: {}", strerror(errno));
}
void File::rename(String const& source, String const& target) {
if (::rename(source.utf8Ptr(), target.utf8Ptr()) < 0)
- throw IOException::format("rename error: %s", strerror(errno));
+ throw IOException::format("rename error: {}", strerror(errno));
}
void File::overwriteFileWithRename(char const* data, size_t len, String const& filename, String const& newSuffix) {
@@ -200,11 +200,11 @@ void* File::fopen(char const* filename, IOMode mode) {
int fd = ::open(filename, oflag, 0666);
if (fd < 0)
- throw IOException::format("Error opening file '%s', error: %s", filename, strerror(errno));
+ throw IOException::format("Error opening file '{}', error: {}", filename, strerror(errno));
if (mode & IOMode::Append) {
if (lseek(fd, 0, SEEK_END) < 0)
- throw IOException::format("Error opening file '%s', cannot seek: %s", filename, strerror(errno));
+ throw IOException::format("Error opening file '{}', cannot seek: {}", filename, strerror(errno));
}
return handleFromFd(fd);
@@ -221,7 +221,7 @@ void File::fseek(void* f, StreamOffset offset, IOSeek seekMode) {
retCode = lseek(fd, offset, SEEK_END);
if (retCode < 0)
- throw IOException::format("Seek error: %s", strerror(errno));
+ throw IOException::format("Seek error: {}", strerror(errno));
}
StreamOffset File::ftell(void* f) {
@@ -237,7 +237,7 @@ size_t File::fread(void* file, char* data, size_t len) {
if (ret < 0) {
if (errno == EAGAIN || errno == EINTR)
return 0;
- throw IOException::format("Read error: %s", strerror(errno));
+ throw IOException::format("Read error: {}", strerror(errno));
} else {
return ret;
}
@@ -252,7 +252,7 @@ size_t File::fwrite(void* file, char const* data, size_t len) {
if (ret < 0) {
if (errno == EAGAIN || errno == EINTR)
return 0;
- throw IOException::format("Write error: %s", strerror(errno));
+ throw IOException::format("Write error: {}", strerror(errno));
} else {
return ret;
}
@@ -269,7 +269,7 @@ void File::fsync(void* file) {
void File::fclose(void* file) {
if (::close(fdFromHandle(file)) < 0)
- throw IOException::format("Close error: %s", strerror(errno));
+ throw IOException::format("Close error: {}", strerror(errno));
}
StreamOffset File::fsize(void* file) {
@@ -289,7 +289,7 @@ size_t File::pwrite(void* file, char const* data, size_t len, StreamOffset posit
void File::resize(void* f, StreamOffset size) {
if (::ftruncate(fdFromHandle(f), size) < 0)
- throw IOException::format("resize error: %s", strerror(errno));
+ throw IOException::format("resize error: {}", strerror(errno));
}
}
diff --git a/source/core/StarFile_windows.cpp b/source/core/StarFile_windows.cpp
index bb13ffc..0b5c286 100644
--- a/source/core/StarFile_windows.cpp
+++ b/source/core/StarFile_windows.cpp
@@ -42,13 +42,13 @@ String File::currentDirectory() {
void File::changeDirectory(const String& dirName) {
if (!SetCurrentDirectoryW(stringToUtf16(dirName).get()))
- throw IOException(strf("could not change directory to %s", dirName));
+ throw IOException(strf("could not change directory to {}", dirName));
}
void File::makeDirectory(String const& dirName) {
if (CreateDirectoryW(stringToUtf16(dirName).get(), NULL) == 0) {
auto error = GetLastError();
- throw IOException(strf("could not create directory '%s', %s", dirName, error));
+ throw IOException(strf("could not create directory '{}', {}", dirName, error));
}
}
@@ -85,9 +85,9 @@ String File::fullPath(const String& path) {
fullpath_size = GetFullPathNameW(stringToUtf16(path).get(), (DWORD)MAX_PATH, buffer, (WCHAR**)&lpszLastNamePart);
if (0 == fullpath_size)
- throw IOException::format("GetFullPathName failed on path: '%s'", path);
+ throw IOException::format("GetFullPathName failed on path: '{}'", path);
if (fullpath_size >= MAX_PATH)
- throw IOException::format("GetFullPathName failed on path: '%s'", path);
+ throw IOException::format("GetFullPathName failed on path: '{}'", path);
return utf16ToString(buffer);
}
@@ -99,7 +99,7 @@ List<std::pair<String, bool>> File::dirList(const String& dirName, bool skipDots
hFind = FindFirstFileW(stringToUtf16(File::relativeTo(dirName, "*")).get(), &findFileData);
if (hFind == INVALID_HANDLE_VALUE)
- throw IOException(strf("Invalid file handle in dirList of '%s', error is %u", dirName, GetLastError()));
+ throw IOException(strf("Invalid file handle in dirList of '{}', error is %u", dirName, GetLastError()));
while (true) {
String entry = utf16ToString(findFileData.cFileName);
@@ -113,7 +113,7 @@ List<std::pair<String, bool>> File::dirList(const String& dirName, bool skipDots
FindClose(hFind);
if ((dwError != ERROR_NO_MORE_FILES) && (dwError != NO_ERROR))
- throw IOException(strf("FindNextFile error in dirList of '%s'. Error is %u", dirName, dwError));
+ throw IOException(strf("FindNextFile error in dirList of '{}'. Error is %u", dirName, dwError));
return fileList;
}
@@ -158,10 +158,10 @@ String File::temporaryFileName() {
WCHAR tempPath[MAX_PATH];
if (!GetTempPathW(MAX_PATH, tempPath)) {
auto error = GetLastError();
- throw IOException(strf("Could not call GetTempPath %s", error));
+ throw IOException(strf("Could not call GetTempPath {}", error));
}
- return relativeTo(utf16ToString(tempPath), strf("starbound.tmpfile.%s", hexEncode(Random::randBytes(16))));
+ return relativeTo(utf16ToString(tempPath), strf("starbound.tmpfile.{}", hexEncode(Random::randBytes(16))));
}
FilePtr File::temporaryFile() {
@@ -179,10 +179,10 @@ String File::temporaryDirectory() {
WCHAR tempPath[MAX_PATH];
if (!GetTempPathW(MAX_PATH, tempPath)) {
auto error = GetLastError();
- throw IOException(strf("Could not call GetTempPath %s", error));
+ throw IOException(strf("Could not call GetTempPath {}", error));
}
- String dirname = relativeTo(utf16ToString(tempPath), strf("starbound.tmpdir.%s", hexEncode(Random::randBytes(16))));
+ String dirname = relativeTo(utf16ToString(tempPath), strf("starbound.tmpdir.{}", hexEncode(Random::randBytes(16))));
makeDirectory(dirname);
return dirname;
}
@@ -191,11 +191,11 @@ void File::remove(String const& filename) {
if (isDirectory(filename)) {
if (!RemoveDirectoryW(stringToUtf16(filename).get())) {
auto error = GetLastError();
- throw IOException(strf("Rename error: %s", error));
+ throw IOException(strf("Rename error: {}", error));
}
} else if (::_wremove(stringToUtf16(filename).get()) < 0) {
auto error = errno;
- throw IOException::format("remove error: %s", strerror(error));
+ throw IOException::format("remove error: {}", strerror(error));
}
}
@@ -207,22 +207,22 @@ void File::rename(String const& source, String const& target) {
if (!DeleteFileW(stringToUtf16(temp).get())) {
auto error = GetLastError();
if (error != ERROR_FILE_NOT_FOUND)
- throw IOException(strf("error deleting existing temp file: %s", error));
+ throw IOException(strf("error deleting existing temp file: {}", error));
}
if (!MoveFileExW(stringToUtf16(target).get(), stringToUtf16(temp).get(), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH)) {
auto error = GetLastError();
- throw IOException(strf("error temporary file '%s': %s", temp, GetLastError()));
+ throw IOException(strf("error temporary file '{}': {}", temp, GetLastError()));
}
}
if (!MoveFileExW(stringToUtf16(source).get(), stringToUtf16(target).get(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH)) {
auto error = GetLastError();
- throw IOException(strf("Rename error: %s", error));
+ throw IOException(strf("Rename error: {}", error));
}
if (replace && !DeleteFileW(stringToUtf16(temp).get())) {
auto error = GetLastError();
- throw IOException(strf("error deleting temp file '%s': %s", temp, GetLastError()));
+ throw IOException(strf("error deleting temp file '{}': {}", temp, GetLastError()));
}
}
@@ -266,19 +266,19 @@ void* File::fopen(char const* filename, IOMode mode) {
creationDisposition, 0, NULL);
if (file == INVALID_HANDLE_VALUE)
- throw IOException::format("could not open file '%s' %s", filename, GetLastError());
+ throw IOException::format("could not open file '{}' {}", filename, GetLastError());
LARGE_INTEGER szero;
szero.QuadPart = 0;
if (!SetFilePointerEx(file, szero, NULL, 0)) {
CloseHandle(file);
- throw IOException::format("could not set file pointer in fopen '%s' %s", filename, GetLastError());
+ throw IOException::format("could not set file pointer in fopen '{}' {}", filename, GetLastError());
}
if (mode & IOMode::Truncate) {
if (!SetEndOfFile(file)) {
CloseHandle(file);
- throw IOException::format("could not set end of file in fopen '%s' %s", filename, GetLastError());
+ throw IOException::format("could not set end of file in fopen '{}' {}", filename, GetLastError());
}
}
@@ -286,11 +286,11 @@ void* File::fopen(char const* filename, IOMode mode) {
LARGE_INTEGER size;
if (GetFileSizeEx(file, &size) == 0) {
CloseHandle(file);
- throw IOException::format("could not get file size in fopen '%s' %s", filename, GetLastError());
+ throw IOException::format("could not get file size in fopen '{}' {}", filename, GetLastError());
}
if (!SetFilePointerEx(file, size, NULL, 0)) {
CloseHandle(file);
- throw IOException::format("could not set file pointer in fopen '%s' %s", filename, GetLastError());
+ throw IOException::format("could not set file pointer in fopen '{}' {}", filename, GetLastError());
}
}
@@ -331,7 +331,7 @@ size_t File::fread(void* f, char* data, size_t len) {
if (ret == 0) {
auto err = GetLastError();
if (err != ERROR_IO_PENDING)
- throw IOException::format("read error %s", err);
+ throw IOException::format("read error {}", err);
}
return numRead;
@@ -348,7 +348,7 @@ size_t File::fwrite(void* f, char const* data, size_t len) {
if (ret == 0) {
auto err = GetLastError();
if (err != ERROR_IO_PENDING)
- throw IOException::format("write error %s", err);
+ throw IOException::format("write error {}", err);
}
return numWritten;
@@ -357,7 +357,7 @@ size_t File::fwrite(void* f, char const* data, size_t len) {
void File::fsync(void* f) {
HANDLE file = (HANDLE)f;
if (FlushFileBuffers(file) == 0)
- throw IOException::format("fsync error %s", GetLastError());
+ throw IOException::format("fsync error {}", GetLastError());
}
void File::fclose(void* f) {
@@ -369,7 +369,7 @@ StreamOffset File::fsize(void* f) {
HANDLE file = (HANDLE)f;
LARGE_INTEGER size;
if (GetFileSizeEx(file, &size) == 0)
- throw IOException::format("could not get file size in fsize %s", GetLastError());
+ throw IOException::format("could not get file size in fsize {}", GetLastError());
return size.QuadPart;
}
@@ -381,7 +381,7 @@ size_t File::pread(void* f, char* data, size_t len, StreamOffset position) {
if (ret == 0) {
auto err = GetLastError();
if (err != ERROR_IO_PENDING)
- throw IOException::format("pread error %s", err);
+ throw IOException::format("pread error {}", err);
}
return numRead;
@@ -395,7 +395,7 @@ size_t File::pwrite(void* f, char const* data, size_t len, StreamOffset position
if (ret == 0) {
auto err = GetLastError();
if (err != ERROR_IO_PENDING)
- throw IOException::format("pwrite error %s", err);
+ throw IOException::format("pwrite error {}", err);
}
return numWritten;
diff --git a/source/core/StarFont.cpp b/source/core/StarFont.cpp
index e16a2be..6308784 100644
--- a/source/core/StarFont.cpp
+++ b/source/core/StarFont.cpp
@@ -66,7 +66,7 @@ void Font::setPixelSize(unsigned pixelSize) {
return;
if (FT_Set_Pixel_Sizes(m_fontImpl->face, pixelSize, 0))
- throw FontException(strf("Cannot set font pixel size to: %s", pixelSize));
+ throw FontException(strf("Cannot set font pixel size to: {}", pixelSize));
m_pixelSize = pixelSize;
}
diff --git a/source/core/StarFormattedJson.cpp b/source/core/StarFormattedJson.cpp
index f31f3ba..d7bd8c7 100644
--- a/source/core/StarFormattedJson.cpp
+++ b/source/core/StarFormattedJson.cpp
@@ -105,21 +105,21 @@ Json const& FormattedJson::toJson() const {
FormattedJson FormattedJson::get(String const& key) const {
if (type() != Json::Type::Object)
- throw JsonException::format("Cannot call get with key on FormattedJson type %s, must be Object type", typeName());
+ throw JsonException::format("Cannot call get with key on FormattedJson type {}, must be Object type", typeName());
Maybe<pair<ElementLocation, ElementLocation>> entry = m_objectEntryLocations.maybe(key);
if (entry.isNothing())
- throw JsonException::format("No such key in FormattedJson::get(\"%s\")", key);
+ throw JsonException::format("No such key in FormattedJson::get(\"{}\")", key);
return getFormattedJson(entry->second);
}
FormattedJson FormattedJson::get(size_t index) const {
if (type() != Json::Type::Array)
- throw JsonException::format("Cannot call get with index on FormattedJson type %s, must be Array type", typeName());
+ throw JsonException::format("Cannot call get with index on FormattedJson type {}, must be Array type", typeName());
if (index >= m_arrayElementLocations.size())
- throw JsonException::format("FormattedJson::get(%s) out of range", index);
+ throw JsonException::format("FormattedJson::get({}) out of range", index);
ElementLocation loc = m_arrayElementLocations.at(index);
return getFormattedJson(loc);
@@ -263,14 +263,14 @@ FormattedJson FormattedJson::prepend(String const& key, FormattedJson const& val
FormattedJson FormattedJson::insertBefore(String const& key, FormattedJson const& value, String const& beforeKey) const {
if (!m_objectEntryLocations.contains(beforeKey))
- throw JsonException::format("Cannot insert before key \"%s\", which does not exist", beforeKey);
+ throw JsonException::format("Cannot insert before key \"{}\", which does not exist", beforeKey);
ElementLocation loc = m_objectEntryLocations.get(beforeKey).first;
return objectInsert(key, value, loc);
}
FormattedJson FormattedJson::insertAfter(String const& key, FormattedJson const& value, String const& afterKey) const {
if (!m_objectEntryLocations.contains(afterKey))
- throw JsonException::format("Cannot insert after key \"%s\", which does not exist", afterKey);
+ throw JsonException::format("Cannot insert after key \"{}\", which does not exist", afterKey);
ElementLocation loc = m_objectEntryLocations.get(afterKey).second;
return objectInsert(key, value, loc + 1);
}
@@ -303,7 +303,7 @@ void removeValueFromArray(List<JsonElement>& elements, size_t loc) {
FormattedJson FormattedJson::eraseKey(String const& key) const {
if (type() != Json::Type::Object)
- throw JsonException::format("Cannot call erase with key on FormattedJson type %s, must be Object type", typeName());
+ throw JsonException::format("Cannot call erase with key on FormattedJson type {}, must be Object type", typeName());
Maybe<pair<ElementLocation, ElementLocation>> maybeEntry = m_objectEntryLocations.maybe(key);
if (maybeEntry.isNothing())
@@ -319,10 +319,10 @@ FormattedJson FormattedJson::eraseKey(String const& key) const {
FormattedJson FormattedJson::insert(size_t index, FormattedJson const& value) const {
if (type() != Json::Type::Array)
throw JsonException::format(
- "Cannot call insert with index on FormattedJson type %s, must be Array type", typeName());
+ "Cannot call insert with index on FormattedJson type {}, must be Array type", typeName());
if (index > m_arrayElementLocations.size())
- throw JsonException::format("FormattedJson::insert(%s) out of range", index);
+ throw JsonException::format("FormattedJson::insert({}) out of range", index);
ElementList elements = m_elements;
ElementLocation insertPosition = elements.size();
@@ -335,7 +335,7 @@ FormattedJson FormattedJson::insert(size_t index, FormattedJson const& value) co
FormattedJson FormattedJson::append(FormattedJson const& value) const {
if (type() != Json::Type::Array)
- throw JsonException::format("Cannot call append on FormattedJson type %s, must be Array type", typeName());
+ throw JsonException::format("Cannot call append on FormattedJson type {}, must be Array type", typeName());
ElementList elements = m_elements;
insertWithCommaAndFormatting(elements, elements.size(), true, {ValueElement{value}});
@@ -344,10 +344,10 @@ FormattedJson FormattedJson::append(FormattedJson const& value) const {
FormattedJson FormattedJson::set(size_t index, FormattedJson const& value) const {
if (type() != Json::Type::Array)
- throw JsonException::format("Cannot call set with index on FormattedJson type %s, must be Array type", typeName());
+ throw JsonException::format("Cannot call set with index on FormattedJson type {}, must be Array type", typeName());
if (index >= m_arrayElementLocations.size())
- throw JsonException::format("FormattedJson::set(%s) out of range", index);
+ throw JsonException::format("FormattedJson::set({}) out of range", index);
ElementLocation loc = m_arrayElementLocations.at(index);
ElementList elements = m_elements;
@@ -357,10 +357,10 @@ FormattedJson FormattedJson::set(size_t index, FormattedJson const& value) const
FormattedJson FormattedJson::eraseIndex(size_t index) const {
if (type() != Json::Type::Array)
- throw JsonException::format("Cannot call set with index on FormattedJson type %s, must be Array type", typeName());
+ throw JsonException::format("Cannot call set with index on FormattedJson type {}, must be Array type", typeName());
if (index >= m_arrayElementLocations.size())
- throw JsonException::format("FormattedJson::eraseIndex(%s) out of range", index);
+ throw JsonException::format("FormattedJson::eraseIndex({}) out of range", index);
ElementLocation loc = m_arrayElementLocations.at(index);
ElementList elements = m_elements;
@@ -390,7 +390,7 @@ String FormattedJson::typeName() const {
String FormattedJson::toFormattedDouble() const {
if (!isType(Json::Type::Float))
- throw JsonException::format("Cannot call toFormattedDouble on Json type %s, must be Float", typeName());
+ throw JsonException::format("Cannot call toFormattedDouble on Json type {}, must be Float", typeName());
if (m_formatting.isValid())
return *m_formatting;
return toJson().repr();
@@ -398,7 +398,7 @@ String FormattedJson::toFormattedDouble() const {
String FormattedJson::toFormattedInt() const {
if (!isType(Json::Type::Int))
- throw JsonException::format("Cannot call toFormattedInt on Json type %s, must be Int", typeName());
+ throw JsonException::format("Cannot call toFormattedInt on Json type {}, must be Int", typeName());
if (m_formatting.isValid())
return *m_formatting;
return toJson().repr();
@@ -454,7 +454,7 @@ FormattedJson FormattedJson::array(ElementList const& elements) {
FormattedJson FormattedJson::objectInsert(String const& key, FormattedJson const& value, ElementLocation loc) const {
if (type() != Json::Type::Object)
- throw JsonException::format("Cannot call set with key on FormattedJson type %s, must be Object type", typeName());
+ throw JsonException::format("Cannot call set with key on FormattedJson type {}, must be Object type", typeName());
Maybe<pair<ElementLocation, ElementLocation>> maybeEntry = m_objectEntryLocations.maybe(key);
if (maybeEntry.isValid()) {
diff --git a/source/core/StarHostAddress.cpp b/source/core/StarHostAddress.cpp
index f65f179..5459a7e 100644
--- a/source/core/StarHostAddress.cpp
+++ b/source/core/StarHostAddress.cpp
@@ -133,7 +133,7 @@ void HostAddress::set(String const& address) {
hints.ai_flags = AI_ADDRCONFIG;
if (::getaddrinfo(address.utf8Ptr(), NULL, &hints, &result) != 0)
- throw NetworkException(strf("Failed to determine address for '%s' (%s)", address, netErrorString()));
+ throw NetworkException(strf("Failed to determine address for '{}' ({})", address, netErrorString()));
for (ptr = result; ptr != NULL; ptr = ptr->ai_next) {
NetworkMode mode;
@@ -171,12 +171,12 @@ void HostAddress::set(NetworkMode mode, uint8_t const* addr) {
std::ostream& operator<<(std::ostream& os, HostAddress const& address) {
switch (address.mode()) {
case NetworkMode::IPv4:
- format(os, "%d.%d.%d.%d", address.octet(0), address.octet(1), address.octet(2), address.octet(3));
+ format(os, "{}.{}.{}.{}", address.octet(0), address.octet(1), address.octet(2), address.octet(3));
break;
case NetworkMode::IPv6:
format(os,
- "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x",
+ "{:02x}{:02x}:{:02x}{:02x}:{:02x}{:02x}:{:02x}{:02x}:{:02x}{:02x}:{:02x}{:02x}:{:02x}{:02x}:{:02x}{:02x}",
address.octet(0),
address.octet(1),
address.octet(2),
@@ -196,7 +196,7 @@ std::ostream& operator<<(std::ostream& os, HostAddress const& address) {
break;
default:
- throw NetworkException(strf("Unknown address mode (%d)", (int)address.mode()));
+ throw NetworkException(strf("Unknown address mode ({})", (int)address.mode()));
}
return os;
}
@@ -224,7 +224,7 @@ Either<String, HostAddressWithPort> HostAddressWithPort::lookupWithPort(String c
auto portNum = maybeLexicalCast<uint16_t>(port);
if (!portNum)
- return makeLeft(strf("Could not parse port portion of HostAddressWithPort '%s'", port));
+ return makeLeft(strf("Could not parse port portion of HostAddressWithPort '{}'", port));
auto hostAddress = HostAddress::lookup(host);
if (hostAddress.isLeft())
diff --git a/source/core/StarIODevice.cpp b/source/core/StarIODevice.cpp
index 1274e89..2b79bb3 100644
--- a/source/core/StarIODevice.cpp
+++ b/source/core/StarIODevice.cpp
@@ -42,7 +42,7 @@ void IODevice::writeFull(char const* data, size_t len) {
void IODevice::open(IOMode mode) {
if (mode != m_mode)
- throw IOException::format("Cannot reopen device '%s", deviceName());
+ throw IOException::format("Cannot reopen device '{}", deviceName());
}
void IODevice::close() {
@@ -52,7 +52,7 @@ void IODevice::close() {
void IODevice::sync() {}
String IODevice::deviceName() const {
- return strf("IODevice <%s>", (void*)this);
+ return strf("IODevice <{}>", (void*)this);
}
bool IODevice::atEnd() {
diff --git a/source/core/StarIdMap.hpp b/source/core/StarIdMap.hpp
index 15946da..1f97c55 100644
--- a/source/core/StarIdMap.hpp
+++ b/source/core/StarIdMap.hpp
@@ -102,7 +102,7 @@ auto IdMapWrapper<BaseMap>::nextId() -> IdType {
template <typename BaseMap>
void IdMapWrapper<BaseMap>::add(IdType id, MappedType mappedType) {
if (!BaseMap::insert(make_pair(move(id), move(mappedType))).second)
- throw IdMapException::format("IdMapWrapper::add(id, value) called with pre-existing id '%s'", outputAny(id));
+ throw IdMapException::format("IdMapWrapper::add(id, value) called with pre-existing id '{}'", outputAny(id));
}
template <typename BaseMap>
diff --git a/source/core/StarImage.cpp b/source/core/StarImage.cpp
index bd3e838..1494503 100644
--- a/source/core/StarImage.cpp
+++ b/source/core/StarImage.cpp
@@ -7,7 +7,7 @@ namespace Star {
Image Image::readPng(IODevicePtr device) {
auto logPngError = [](png_structp png_ptr, png_const_charp c) {
- Logger::debug("PNG error in file: '%s', %s", (char*)png_get_error_ptr(png_ptr), c);
+ Logger::debug("PNG error in file: '{}', {}", (char*)png_get_error_ptr(png_ptr), c);
};
auto readPngData = [](png_structp pngPtr, png_bytep data, png_size_t length) {
@@ -19,7 +19,7 @@ Image Image::readPng(IODevicePtr device) {
device->readFull((char*)header, sizeof(header));
if (png_sig_cmp(header, 0, sizeof(header)))
- throw ImageException(strf("File %s is not a png image!", device->deviceName()));
+ throw ImageException(strf("File {} is not a png image!", device->deviceName()));
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (!png_ptr)
@@ -94,7 +94,7 @@ Image Image::readPng(IODevicePtr device) {
if (bitdepth != 8 || (channels != 3 && channels != 4)) {
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
- throw ImageException(strf("Unsupported PNG pixel format in file %s", device->deviceName()));
+ throw ImageException(strf("Unsupported PNG pixel format in file {}", device->deviceName()));
}
Image image(img_width, img_height, channels == 3 ? PixelFormat::RGB24 : PixelFormat::RGBA32);
@@ -112,7 +112,7 @@ Image Image::readPng(IODevicePtr device) {
tuple<Vec2U, PixelFormat> Image::readPngMetadata(IODevicePtr device) {
auto logPngError = [](png_structp png_ptr, png_const_charp c) {
- Logger::debug("PNG error in file: '%s', %s", (char*)png_get_error_ptr(png_ptr), c);
+ Logger::debug("PNG error in file: '{}', {}", (char*)png_get_error_ptr(png_ptr), c);
};
auto readPngData = [](png_structp pngPtr, png_bytep data, png_size_t length) {
@@ -124,7 +124,7 @@ tuple<Vec2U, PixelFormat> Image::readPngMetadata(IODevicePtr device) {
device->readFull((char*)header, sizeof(header));
if (png_sig_cmp(header, 0, sizeof(header)))
- throw ImageException(strf("File %s is not a png image!", device->deviceName()));
+ throw ImageException(strf("File {} is not a png image!", device->deviceName()));
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (!png_ptr)
@@ -267,7 +267,7 @@ void Image::reset(unsigned width, unsigned height, Maybe<PixelFormat> pf) {
newData = (uint8_t*)Star::realloc(m_data, imageSize);
if (!newData)
- throw MemoryException::format("Could not allocate memory for new Image size %s\n", imageSize);
+ throw MemoryException::format("Could not allocate memory for new Image size {}\n", imageSize);
m_data = newData;
memset(m_data, 0, imageSize);
@@ -316,7 +316,7 @@ void Image::fillRect(Vec2U const& pos, Vec2U const& size, Vec4B const& c) {
void Image::set(Vec2U const& pos, Vec4B const& c) {
if (pos[0] >= m_width || pos[1] >= m_height) {
- throw ImageException(strf("%s out of range in Image::set", pos));
+ throw ImageException(strf("{} out of range in Image::set", pos));
} else if (bytesPerPixel() == 4) {
size_t offset = pos[1] * m_width * 4 + pos[0] * 4;
m_data[offset] = c[0];
@@ -333,7 +333,7 @@ void Image::set(Vec2U const& pos, Vec4B const& c) {
void Image::set(Vec2U const& pos, Vec3B const& c) {
if (pos[0] >= m_width || pos[1] >= m_height) {
- throw ImageException(strf("%s out of range in Image::set", pos));
+ throw ImageException(strf("{} out of range in Image::set", pos));
} else if (bytesPerPixel() == 4) {
size_t offset = pos[1] * m_width * 4 + pos[0] * 4;
m_data[offset] = c[0];
@@ -351,7 +351,7 @@ void Image::set(Vec2U const& pos, Vec3B const& c) {
Vec4B Image::get(Vec2U const& pos) const {
Vec4B c;
if (pos[0] >= m_width || pos[1] >= m_height) {
- throw ImageException(strf("%s out of range in Image::get", pos));
+ throw ImageException(strf("{} out of range in Image::get", pos));
} else if (bytesPerPixel() == 4) {
size_t offset = pos[1] * m_width * 4 + pos[0] * 4;
c[0] = m_data[offset];
@@ -422,7 +422,7 @@ Vec4B Image::clamprgb(Vec2I const& pos) const {
Image Image::subImage(Vec2U const& pos, Vec2U const& size) const {
if (pos[0] + size[0] > m_width || pos[1] + size[1] > m_height)
- throw ImageException(strf("call to subImage with pos %s size %s out of image bounds (%s, %s)", pos, size, m_width, m_height));
+ throw ImageException(strf("call to subImage with pos {} size {} out of image bounds ({}, {})", pos, size, m_width, m_height));
Image sub(size[0], size[1], m_pixelFormat);
diff --git a/source/core/StarImageProcessing.cpp b/source/core/StarImageProcessing.cpp
index 2c79b58..bf4d01a 100644
--- a/source/core/StarImageProcessing.cpp
+++ b/source/core/StarImageProcessing.cpp
@@ -199,7 +199,7 @@ ImageOperation imageOperationFromString(StringView string) {
hexDecode(hexPtr, 8, c, 4);
}
else if (!which || (ptr != end && ++ptr != end))
- throw ImageOperationException(strf("Improper size for hex string '%s' in imageOperationFromString", StringView(hexPtr, hexLen)), false);
+ throw ImageOperationException(strf("Improper size for hex string '{}' in imageOperationFromString", StringView(hexPtr, hexLen)), false);
else // we're in A of A=B. In vanilla only A=B pairs are evaluated, so only throw an exception if B is also there.
return move(operation);
@@ -341,7 +341,7 @@ ImageOperation imageOperationFromString(StringView string) {
return FlipImageOperation{FlipImageOperation::FlipXY};
} else {
- throw ImageOperationException(strf("Could not recognize ImageOperation type %s", type), false);
+ throw ImageOperationException(strf("Could not recognize ImageOperation type {}", type), false);
}
} catch (OutOfRangeException const& e) {
throw ImageOperationException("Error reading ImageOperation", e);
@@ -352,52 +352,52 @@ ImageOperation imageOperationFromString(StringView string) {
String imageOperationToString(ImageOperation const& operation) {
if (auto op = operation.ptr<HueShiftImageOperation>()) {
- return strf("hueshift=%s", op->hueShiftAmount * 360.0f);
+ return strf("hueshift={}", op->hueShiftAmount * 360.0f);
} else if (auto op = operation.ptr<SaturationShiftImageOperation>()) {
- return strf("saturation=%s", op->saturationShiftAmount * 100.0f);
+ return strf("saturation={}", op->saturationShiftAmount * 100.0f);
} else if (auto op = operation.ptr<BrightnessMultiplyImageOperation>()) {
- return strf("brightness=%s", (op->brightnessMultiply - 1.0f) * 100.0f);
+ return strf("brightness={}", (op->brightnessMultiply - 1.0f) * 100.0f);
} else if (auto op = operation.ptr<FadeToColorImageOperation>()) {
- return strf("fade=%s=%s", Color::rgb(op->color).toHex(), op->amount);
+ return strf("fade={}={}", Color::rgb(op->color).toHex(), op->amount);
} else if (auto op = operation.ptr<ScanLinesImageOperation>()) {
- return strf("scanlines=%s=%s=%s=%s",
+ return strf("scanlines={}={}={}={}",
Color::rgb(op->fade1.color).toHex(),
op->fade1.amount,
Color::rgb(op->fade2.color).toHex(),
op->fade2.amount);
} else if (auto op = operation.ptr<SetColorImageOperation>()) {
- return strf("setcolor=%s", Color::rgb(op->color).toHex());
+ return strf("setcolor={}", Color::rgb(op->color).toHex());
} else if (auto op = operation.ptr<ColorReplaceImageOperation>()) {
String str = "replace";
for (auto const& pair : op->colorReplaceMap)
- str += strf(";%s=%s", Color::rgba(pair.first).toHex(), Color::rgba(pair.second).toHex());
+ str += strf(";{}={}", Color::rgba(pair.first).toHex(), Color::rgba(pair.second).toHex());
return str;
} else if (auto op = operation.ptr<AlphaMaskImageOperation>()) {
if (op->mode == AlphaMaskImageOperation::Additive)
- return strf("addmask=%s;%s;%s", op->maskImages.join("+"), op->offset[0], op->offset[1]);
+ return strf("addmask={};{};{}", op->maskImages.join("+"), op->offset[0], op->offset[1]);
else if (op->mode == AlphaMaskImageOperation::Subtractive)
- return strf("submask=%s;%s;%s", op->maskImages.join("+"), op->offset[0], op->offset[1]);
+ return strf("submask={};{};{}", op->maskImages.join("+"), op->offset[0], op->offset[1]);
} else if (auto op = operation.ptr<BlendImageOperation>()) {
if (op->mode == BlendImageOperation::Multiply)
- return strf("blendmult=%s;%s;%s", op->blendImages.join("+"), op->offset[0], op->offset[1]);
+ return strf("blendmult={};{};{}", op->blendImages.join("+"), op->offset[0], op->offset[1]);
else if (op->mode == BlendImageOperation::Screen)
- return strf("blendscreen=%s;%s;%s", op->blendImages.join("+"), op->offset[0], op->offset[1]);
+ return strf("blendscreen={};{};{}", op->blendImages.join("+"), op->offset[0], op->offset[1]);
} else if (auto op = operation.ptr<MultiplyImageOperation>()) {
- return strf("multiply=%s", Color::rgba(op->color).toHex());
+ return strf("multiply={}", Color::rgba(op->color).toHex());
} else if (auto op = operation.ptr<BorderImageOperation>()) {
if (op->outlineOnly)
- return strf("outline=%d;%s;%s", op->pixels, Color::rgba(op->startColor).toHex(), Color::rgba(op->endColor).toHex());
+ return strf("outline={};{};{}", op->pixels, Color::rgba(op->startColor).toHex(), Color::rgba(op->endColor).toHex());
else
- return strf("border=%d;%s;%s", op->pixels, Color::rgba(op->startColor).toHex(), Color::rgba(op->endColor).toHex());
+ return strf("border={};{};{}", op->pixels, Color::rgba(op->startColor).toHex(), Color::rgba(op->endColor).toHex());
} else if (auto op = operation.ptr<ScaleImageOperation>()) {
if (op->mode == ScaleImageOperation::Nearest)
- return strf("scalenearest=%s", op->scale);
+ return strf("scalenearest={}", op->scale);
else if (op->mode == ScaleImageOperation::Bilinear)
- return strf("scalebilinear=%s", op->scale);
+ return strf("scalebilinear={}", op->scale);
else if (op->mode == ScaleImageOperation::Bicubic)
- return strf("scalebicubic=%s", op->scale);
+ return strf("scalebicubic={}", op->scale);
} else if (auto op = operation.ptr<CropImageOperation>()) {
- return strf("crop=%s;%s;%s;%s", op->subset.xMin(), op->subset.xMax(), op->subset.yMin(), op->subset.yMax());
+ return strf("crop={};{};{};{}", op->subset.xMin(), op->subset.xMax(), op->subset.yMin(), op->subset.yMax());
} else if (auto op = operation.ptr<FlipImageOperation>()) {
if (op->mode == FlipImageOperation::FlipX)
return "flipx";
diff --git a/source/core/StarJson.cpp b/source/core/StarJson.cpp
index 9639ce4..2892e1c 100644
--- a/source/core/StarJson.cpp
+++ b/source/core/StarJson.cpp
@@ -24,7 +24,7 @@ Json::Type Json::typeFromName(String const& t) {
else if (t == "null")
return Type::Null;
else
- throw JsonException(strf("String '%s' is not a valid json type", t));
+ throw JsonException(strf("String '{}' is not a valid json type", t));
}
String Json::typeName(Type t) {
@@ -180,7 +180,7 @@ double Json::toDouble() const {
if (type() == Type::Int)
return (double)m_data.get<int64_t>();
- throw JsonException::format("Improper conversion to double from %s", typeName());
+ throw JsonException::format("Improper conversion to double from {}", typeName());
}
float Json::toFloat() const {
@@ -189,7 +189,7 @@ float Json::toFloat() const {
bool Json::toBool() const {
if (type() != Type::Bool)
- throw JsonException::format("Improper conversion to bool from %s", typeName());
+ throw JsonException::format("Improper conversion to bool from {}", typeName());
return m_data.get<bool>();
}
@@ -199,7 +199,7 @@ int64_t Json::toInt() const {
} else if (type() == Type::Int) {
return m_data.get<int64_t>();
} else {
- throw JsonException::format("Improper conversion to int from %s", typeName());
+ throw JsonException::format("Improper conversion to int from {}", typeName());
}
}
@@ -209,43 +209,43 @@ uint64_t Json::toUInt() const {
} else if (type() == Type::Int) {
return (uint64_t)m_data.get<int64_t>();
} else {
- throw JsonException::format("Improper conversion to unsigned int from %s", typeName());
+ throw JsonException::format("Improper conversion to unsigned int from {}", typeName());
}
}
String Json::toString() const {
if (type() != Type::String)
- throw JsonException(strf("Cannot convert from %s to string", typeName()));
+ throw JsonException(strf("Cannot convert from {} to string", typeName()));
return *m_data.get<StringConstPtr>();
}
JsonArray Json::toArray() const {
if (type() != Type::Array)
- throw JsonException::format("Improper conversion to JsonArray from %s", typeName());
+ throw JsonException::format("Improper conversion to JsonArray from {}", typeName());
return *m_data.get<JsonArrayConstPtr>();
}
JsonObject Json::toObject() const {
if (type() != Type::Object)
- throw JsonException::format("Improper conversion to JsonObject from %s", typeName());
+ throw JsonException::format("Improper conversion to JsonObject from {}", typeName());
return *m_data.get<JsonObjectConstPtr>();
}
StringConstPtr Json::stringPtr() const {
if (type() != Type::String)
- throw JsonException(strf("Cannot convert from %s to string", typeName()));
+ throw JsonException(strf("Cannot convert from {} to string", typeName()));
return m_data.get<StringConstPtr>();
}
JsonArrayConstPtr Json::arrayPtr() const {
if (type() != Type::Array)
- throw JsonException::format("Improper conversion to JsonArray from %s", typeName());
+ throw JsonException::format("Improper conversion to JsonArray from {}", typeName());
return m_data.get<JsonArrayConstPtr>();
}
JsonObjectConstPtr Json::objectPtr() const {
if (type() != Type::Object)
- throw JsonException::format("Improper conversion to JsonObject from %s", typeName());
+ throw JsonException::format("Improper conversion to JsonObject from {}", typeName());
return m_data.get<JsonObjectConstPtr>();
}
@@ -330,7 +330,7 @@ bool Json::contains(String const& key) const {
Json Json::get(size_t index) const {
if (auto p = ptr(index))
return *p;
- throw JsonException(strf("Json::get(%s) out of range", index));
+ throw JsonException(strf("Json::get({}) out of range", index));
}
double Json::getDouble(size_t index) const {
@@ -422,7 +422,7 @@ JsonObject Json::getObject(size_t index, JsonObject def) const {
Json Json::get(String const& key) const {
if (auto p = ptr(key))
return *p;
- throw JsonException(strf("No such key in Json::get(\"%s\")", key));
+ throw JsonException(strf("No such key in Json::get(\"{}\")", key));
}
double Json::getDouble(String const& key) const {
@@ -822,7 +822,7 @@ Json Json::convert(Type u) const {
case Type::Object:
return toObject();
default:
- throw JsonException::format("Improper conversion to type %s", typeName(u));
+ throw JsonException::format("Improper conversion to type {}", typeName(u));
}
}
@@ -997,7 +997,7 @@ size_t hash<Json>::operator()(Json const& v) const {
Json const* Json::ptr(size_t index) const {
if (type() != Type::Array)
- throw JsonException::format("Cannot call get with index on Json type %s, must be Array type", typeName());
+ throw JsonException::format("Cannot call get with index on Json type {}, must be Array type", typeName());
auto const& list = *m_data.get<JsonArrayConstPtr>();
if (index >= list.size())
@@ -1007,7 +1007,7 @@ Json const* Json::ptr(size_t index) const {
Json const* Json::ptr(String const& key) const {
if (type() != Type::Object)
- throw JsonException::format("Cannot call get with key on Json type %s, must be Object type", typeName());
+ throw JsonException::format("Cannot call get with key on Json type {}, must be Object type", typeName());
auto const& map = m_data.get<JsonObjectConstPtr>();
auto i = map->find(key);
diff --git a/source/core/StarJsonBuilder.cpp b/source/core/StarJsonBuilder.cpp
index 432cef9..6084c40 100644
--- a/source/core/StarJsonBuilder.cpp
+++ b/source/core/StarJsonBuilder.cpp
@@ -21,7 +21,7 @@ void JsonBuilderStream::endObject() {
Json v = pop();
String k = pop().toString();
if (!object.insert(k, move(v)).second)
- throw JsonParsingException(strf("Json object contains a duplicate entry for key '%s'", k));
+ throw JsonParsingException(strf("Json object contains a duplicate entry for key '{}'", k));
}
}
}
diff --git a/source/core/StarJsonBuilder.hpp b/source/core/StarJsonBuilder.hpp
index cd2d42d..6be9e54 100644
--- a/source/core/StarJsonBuilder.hpp
+++ b/source/core/StarJsonBuilder.hpp
@@ -62,9 +62,9 @@ Json inputUtf8Json(InputIterator begin, InputIterator end, bool fragment) {
Utf32Input pend = parser.parse(wbegin, wend, fragment);
if (parser.error())
- throw JsonParsingException(strf("Error parsing json: %s at %s:%s", parser.error(), parser.line(), parser.column()));
+ throw JsonParsingException(strf("Error parsing json: {} at {}:{}", parser.error(), parser.line(), parser.column()));
else if (pend != wend)
- throw JsonParsingException(strf("Error extra data at end of input at %s:%s", parser.line(), parser.column()));
+ throw JsonParsingException(strf("Error extra data at end of input at {}:{}", parser.line(), parser.column()));
return stream.takeTop();
}
@@ -85,9 +85,9 @@ Jsonlike inputUtf32Json(InputIterator begin, InputIterator end, bool fragment) {
InputIterator pend = parser.parse(begin, end, fragment);
if (parser.error()) {
- throw JsonParsingException(strf("Error parsing json: %s at %s:%s", parser.error(), parser.line(), parser.column()));
+ throw JsonParsingException(strf("Error parsing json: {} at {}:{}", parser.error(), parser.line(), parser.column()));
} else if (pend != end) {
- throw JsonParsingException(strf("Error extra data at end of input at %s:%s", parser.line(), parser.column()));
+ throw JsonParsingException(strf("Error extra data at end of input at {}:{}", parser.line(), parser.column()));
}
return stream.takeTop();
diff --git a/source/core/StarJsonExtra.cpp b/source/core/StarJsonExtra.cpp
index d683ca1..ec6fe90 100644
--- a/source/core/StarJsonExtra.cpp
+++ b/source/core/StarJsonExtra.cpp
@@ -147,7 +147,7 @@ RectD jsonToRectD(Json const& v) {
auto upperRight = jsonToVec2D(v.get(1));
return RectD(lowerLeft, upperRight);
} catch (JsonException const& e) {
- throw JsonException(strf("Inner position not well formed in jsonToRectD: %s", outputException(e, true)));
+ throw JsonException(strf("Inner position not well formed in jsonToRectD: {}", outputException(e, true)));
}
}
@@ -178,7 +178,7 @@ RectI jsonToRectI(Json const& v) {
auto upperRight = jsonToVec2I(v.get(1));
return RectI(lowerLeft, upperRight);
} catch (JsonException const& e) {
- throw JsonException(strf("Inner position not well formed in jsonToRectI: %s", outputException(e, true)));
+ throw JsonException(strf("Inner position not well formed in jsonToRectI: {}", outputException(e, true)));
}
}
@@ -201,7 +201,7 @@ RectU jsonToRectU(Json const& v) {
auto upperRight = jsonToVec2U(v.get(1));
return RectU(lowerLeft, upperRight);
} catch (JsonException const& e) {
- throw JsonException(strf("Inner position not well formed in jsonToRectU: %s", outputException(e, true)));
+ throw JsonException(strf("Inner position not well formed in jsonToRectU: {}", outputException(e, true)));
}
}
@@ -226,7 +226,7 @@ Color jsonToColor(Json const& v) {
} else if (v.type() == Json::Type::String) {
return Color(v.toString());
} else {
- throw JsonException(strf("Json of type %s cannot be converted to color", v.typeName()));
+ throw JsonException(strf("Json of type {} cannot be converted to color", v.typeName()));
}
}
diff --git a/source/core/StarJsonExtra.hpp b/source/core/StarJsonExtra.hpp
index cfe7efb..66d89d6 100644
--- a/source/core/StarJsonExtra.hpp
+++ b/source/core/StarJsonExtra.hpp
@@ -106,7 +106,7 @@ Json jsonFromWeightedPool(WeightedPool<T> const& pool, Converter&& converter);
template <size_t Size>
Array<unsigned, Size> jsonToArrayU(Json const& v) {
if (v.size() != Size)
- throw JsonException(strf("Json array not of size %d in jsonToArrayU", Size).c_str());
+ throw JsonException(strf("Json array not of size {} in jsonToArrayU", Size).c_str());
Array<unsigned, Size> res;
for (size_t i = 0; i < Size; i++) {
@@ -119,7 +119,7 @@ Array<unsigned, Size> jsonToArrayU(Json const& v) {
template <size_t Size>
Array<size_t, Size> jsonToArrayS(Json const& v) {
if (v.size() != Size)
- throw JsonException(strf("Json array not of size %d in jsonToArrayS", Size).c_str());
+ throw JsonException(strf("Json array not of size {} in jsonToArrayS", Size).c_str());
Array<size_t, Size> res;
for (size_t i = 0; i < Size; i++) {
@@ -132,7 +132,7 @@ Array<size_t, Size> jsonToArrayS(Json const& v) {
template <size_t Size>
Array<int, Size> jsonToArrayI(Json const& v) {
if (v.size() != Size)
- throw JsonException(strf("Json array not of size %d in jsonToArrayI", Size).c_str());
+ throw JsonException(strf("Json array not of size {} in jsonToArrayI", Size).c_str());
Array<int, Size> res;
for (size_t i = 0; i < Size; i++) {
@@ -145,7 +145,7 @@ Array<int, Size> jsonToArrayI(Json const& v) {
template <size_t Size>
Array<float, Size> jsonToArrayF(Json const& v) {
if (v.size() != Size)
- throw JsonException(strf("Json array not of size %d in jsonToArrayF", Size).c_str());
+ throw JsonException(strf("Json array not of size {} in jsonToArrayF", Size).c_str());
Array<float, Size> res;
for (size_t i = 0; i < Size; i++) {
@@ -158,7 +158,7 @@ Array<float, Size> jsonToArrayF(Json const& v) {
template <size_t Size>
Array<double, Size> jsonToArrayD(Json const& v) {
if (v.size() != Size)
- throw JsonException(strf("Json array not of size %d in jsonToArrayD", Size).c_str());
+ throw JsonException(strf("Json array not of size {} in jsonToArrayD", Size).c_str());
Array<double, Size> res;
for (size_t i = 0; i < Size; i++) {
@@ -171,7 +171,7 @@ Array<double, Size> jsonToArrayD(Json const& v) {
template <size_t Size>
Array<String, Size> jsonToStringArray(Json const& v) {
if (v.size() != Size)
- throw JsonException(strf("Json array not of size %d in jsonToStringArray", Size).c_str());
+ throw JsonException(strf("Json array not of size {} in jsonToStringArray", Size).c_str());
Array<String, Size> res;
for (size_t i = 0; i < Size; i++) {
diff --git a/source/core/StarJsonPatch.cpp b/source/core/StarJsonPatch.cpp
index e1ab6de..34c6a82 100644
--- a/source/core/StarJsonPatch.cpp
+++ b/source/core/StarJsonPatch.cpp
@@ -12,7 +12,7 @@ Json jsonPatch(Json const& base, JsonArray const& patch) {
}
return res;
} catch (JsonException const& e) {
- throw JsonPatchException(strf("Could not apply patch to base. %s", e.what()));
+ throw JsonPatchException(strf("Could not apply patch to base. {}", e.what()));
}
}
@@ -32,9 +32,9 @@ namespace JsonPatching {
auto operation = op.getString("op");
return JsonPatching::functionMap.get(operation)(base, op);
} catch (JsonException const& e) {
- throw JsonPatchException(strf("Could not apply operation to base. %s", e.what()));
+ throw JsonPatchException(strf("Could not apply operation to base. {}", e.what()));
} catch (MapException const&) {
- throw JsonPatchException(strf("Invalid operation: %s", op.getString("op")));
+ throw JsonPatchException(strf("Invalid operation: {}", op.getString("op")));
}
}
@@ -49,7 +49,7 @@ namespace JsonPatching {
auto testValue = pointer.get(base);
if (!value) {
if (inverseTest)
- throw JsonPatchTestFail(strf("Test operation failure, expected %s to be missing.", op.getString("path")));
+ throw JsonPatchTestFail(strf("Test operation failure, expected {} to be missing.", op.getString("path")));
return base;
}
@@ -57,11 +57,11 @@ namespace JsonPatching {
return base;
}
- throw JsonPatchTestFail(strf("Test operation failure, expected %s found %s.", value, testValue));
+ throw JsonPatchTestFail(strf("Test operation failure, expected {} found {}.", value, testValue));
} catch (JsonPath::TraversalException& e) {
if (inverseTest)
return base;
- throw JsonPatchTestFail(strf("Test operation failure: %s", e.what()));
+ throw JsonPatchTestFail(strf("Test operation failure: {}", e.what()));
}
}
diff --git a/source/core/StarJsonPath.cpp b/source/core/StarJsonPath.cpp
index 9eb5fae..c03e883 100644
--- a/source/core/StarJsonPath.cpp
+++ b/source/core/StarJsonPath.cpp
@@ -8,21 +8,21 @@ namespace JsonPath {
buffer.clear();
if (*iterator != '/')
- throw ParsingException::format("Missing leading '/' in Json pointer \"%s\"", path);
+ throw ParsingException::format("Missing leading '/' in Json pointer \"{}\"", path);
iterator++;
while (iterator != end && *iterator != '/') {
if (*iterator == '~') {
++iterator;
if (iterator == end)
- throw ParsingException::format("Incomplete escape sequence in Json pointer \"%s\"", path);
+ throw ParsingException::format("Incomplete escape sequence in Json pointer \"{}\"", path);
if (*iterator == '0')
buffer.append('~');
else if (*iterator == '1')
buffer.append('/');
else
- throw ParsingException::format("Invalid escape sequence in Json pointer \"%s\"", path);
+ throw ParsingException::format("Invalid escape sequence in Json pointer \"{}\"", path);
++iterator;
} else
buffer.append(*iterator++);
@@ -38,7 +38,7 @@ namespace JsonPath {
buffer.clear();
if (*iterator == '.') {
- throw ParsingException::format("Entry starts with '.' in query path \"%s\"", path);
+ throw ParsingException::format("Entry starts with '.' in query path \"{}\"", path);
} else if (*iterator == '[') {
// Parse array number and ']'
@@ -49,7 +49,7 @@ namespace JsonPath {
buffer.append(*iterator++);
if (iterator == end || *iterator != ']')
- throw ParsingException::format("Array has no trailing ']' or has invalid character in query path \"%s\"", path);
+ throw ParsingException::format("Array has no trailing ']' or has invalid character in query path \"{}\"", path);
// Consume trailing ']'
++iterator;
diff --git a/source/core/StarJsonPath.hpp b/source/core/StarJsonPath.hpp
index 0f0efa9..bd60dad 100644
--- a/source/core/StarJsonPath.hpp
+++ b/source/core/StarJsonPath.hpp
@@ -143,24 +143,24 @@ namespace JsonPath {
if (value.type() == Json::Type::Array) {
if (buffer == "-")
- throw TraversalException::format("Tried to get key '%s' in non-object type in pathGet(\"%s\")", buffer, path);
+ throw TraversalException::format("Tried to get key '{}' in non-object type in pathGet(\"{}\")", buffer, path);
Maybe<size_t> i = maybeLexicalCast<size_t>(buffer);
if (!i)
- throw TraversalException::format("Cannot parse '%s' as index in pathGet(\"%s\")", buffer, path);
+ throw TraversalException::format("Cannot parse '{}' as index in pathGet(\"{}\")", buffer, path);
if (*i < value.size())
value = value.get(*i);
else
- throw TraversalException::format("Index %s out of range in pathGet(\"%s\")", buffer, path);
+ throw TraversalException::format("Index {} out of range in pathGet(\"{}\")", buffer, path);
} else if (value.type() == Json::Type::Object) {
if (value.contains(buffer))
value = value.get(buffer);
else
- throw TraversalException::format("No such key '%s' in pathGet(\"%s\")", buffer, path);
+ throw TraversalException::format("No such key '{}' in pathGet(\"{}\")", buffer, path);
} else {
- throw TraversalException::format("Tried to get key '%s' in non-object type in pathGet(\"%s\")", buffer, path);
+ throw TraversalException::format("Tried to get key '{}' in non-object type in pathGet(\"{}\")", buffer, path);
}
}
return value;
@@ -218,10 +218,10 @@ namespace JsonPath {
} else {
Maybe<size_t> i = maybeLexicalCast<size_t>(buffer);
if (!i)
- throw TraversalException::format("Cannot parse '%s' as index in pathApply(\"%s\")", buffer, path);
+ throw TraversalException::format("Cannot parse '{}' as index in pathApply(\"{}\")", buffer, path);
if (*i >= value.size())
- throw TraversalException::format("Index %s out of range in pathApply(\"%s\")", buffer, path);
+ throw TraversalException::format("Index {} out of range in pathApply(\"{}\")", buffer, path);
return value.set(*i, pathApply(buffer, value.get(*i), parser, path, iterator, op));
}
@@ -232,7 +232,7 @@ namespace JsonPath {
} else {
if (!value.contains(buffer))
- throw TraversalException::format("No such key '%s' in pathApply(\"%s\")", buffer, path);
+ throw TraversalException::format("No such key '{}' in pathApply(\"{}\")", buffer, path);
Jsonlike newChild = pathApply(buffer, value.get(buffer), parser, path, iterator, op);
iterator = current;
@@ -242,7 +242,7 @@ namespace JsonPath {
}
} else {
- throw TraversalException::format("Tried to get key '%s' in non-object type in pathApply(\"%s\")", buffer, path);
+ throw TraversalException::format("Tried to get key '{}' in non-object type in pathApply(\"{}\")", buffer, path);
}
}
@@ -262,16 +262,16 @@ namespace JsonPath {
return arrayOp(parent, {});
Maybe<size_t> i = maybeLexicalCast<size_t>(*key);
if (!i)
- throw TraversalException::format("Cannot parse '%s' as index in Json path \"%s\"", *key, path);
+ throw TraversalException::format("Cannot parse '{}' as index in Json path \"{}\"", *key, path);
if (i && *i > parent.size())
- throw TraversalException::format("Index %s out of range in Json path \"%s\"", *key, path);
+ throw TraversalException::format("Index {} out of range in Json path \"{}\"", *key, path);
if (i && *i == parent.size())
i = {};
return arrayOp(parent, i);
} else if (parent.type() == Json::Type::Object) {
return objectOp(parent, *key);
} else {
- throw TraversalException::format("Tried to set key '%s' in non-object type in pathSet(\"%s\")", *key, path);
+ throw TraversalException::format("Tried to set key '{}' in non-object type in pathSet(\"{}\")", *key, path);
}
};
}
@@ -297,7 +297,7 @@ namespace JsonPath {
EmptyPathOp<Jsonlike> emptyPathOp = [](Jsonlike const&) { return Json{}; };
ObjectOp<Jsonlike> objectOp = [](Jsonlike const& object, String const& key) {
if (!object.contains(key))
- throw TraversalException::format("Could not find \"%s\" to remove", key);
+ throw TraversalException::format("Could not find \"{}\" to remove", key);
return object.eraseKey(key);
};
ArrayOp<Jsonlike> arrayOp = [](Jsonlike const& array, Maybe<size_t> i) {
diff --git a/source/core/StarJsonRpc.cpp b/source/core/StarJsonRpc.cpp
index 60779b9..f6def8f 100644
--- a/source/core/StarJsonRpc.cpp
+++ b/source/core/StarJsonRpc.cpp
@@ -12,7 +12,7 @@ JsonRpc::JsonRpc() {
void JsonRpc::registerHandler(String const& handler, JsonRpcRemoteFunction func) {
if (m_handlers.contains(handler))
- throw JsonRpcException(strf("Handler by that name already exists '%s'", handler));
+ throw JsonRpcException(strf("Handler by that name already exists '{}'", handler));
m_handlers.add(handler, move(func));
}
@@ -23,7 +23,7 @@ void JsonRpc::registerHandlers(JsonRpcHandlers const& handlers) {
void JsonRpc::removeHandler(String const& handler) {
if (!m_handlers.contains(handler))
- throw JsonRpcException(strf("No such handler by the name '%s'", handler));
+ throw JsonRpcException(strf("No such handler by the name '{}'", handler));
m_handlers.remove(handler);
}
@@ -76,14 +76,14 @@ void JsonRpc::receive(ByteArray const& inbuffer) {
try {
auto handlerName = request.getString("handler");
if (!m_handlers.contains(handlerName))
- throw JsonRpcException(strf("Unknown handler '%s'", handlerName));
+ throw JsonRpcException(strf("Unknown handler '{}'", handlerName));
m_pending.append(JsonObject{
{"command", "response"},
{"id", request.get("id")},
{"result", m_handlers[handlerName](request.get("arguments"))}
});
} catch (std::exception& e) {
- Logger::error("Exception while handling variant rpc request handler call. %s", outputException(e, false));
+ Logger::error("Exception while handling variant rpc request handler call. {}", outputException(e, false));
JsonObject response;
response["command"] = "fail";
response["id"] = request.get("id");
@@ -98,7 +98,7 @@ void JsonRpc::receive(ByteArray const& inbuffer) {
auto responseHandler = m_pendingResponse.take(request.getUInt("id"));
responseHandler.fulfill(request.get("result"));
} catch (std::exception& e) {
- Logger::error("Exception while handling variant rpc response handler call. %s", outputException(e, true));
+ Logger::error("Exception while handling variant rpc response handler call. {}", outputException(e, true));
}
} else if (request.get("command") == "fail") {
@@ -106,7 +106,7 @@ void JsonRpc::receive(ByteArray const& inbuffer) {
auto responseHandler = m_pendingResponse.take(request.getUInt("id"));
responseHandler.fulfill({});
} catch (std::exception& e) {
- Logger::error("Exception while handling variant rpc failure handler call. %s", outputException(e, true));
+ Logger::error("Exception while handling variant rpc failure handler call. {}", outputException(e, true));
}
}
}
diff --git a/source/core/StarLexicalCast.hpp b/source/core/StarLexicalCast.hpp
index 6359591..40e6d6d 100644
--- a/source/core/StarLexicalCast.hpp
+++ b/source/core/StarLexicalCast.hpp
@@ -39,7 +39,7 @@ Type lexicalCast(StringView s, std::ios_base::fmtflags flags = std::ios_base::bo
if (m)
return m.take();
else
- throw BadLexicalCast(strf("Lexical cast failed on '%s'", s));
+ throw BadLexicalCast(strf("Lexical cast failed on '{}'", s));
}
template <class Type>
diff --git a/source/core/StarList.hpp b/source/core/StarList.hpp
index e097721..49d2f84 100644
--- a/source/core/StarList.hpp
+++ b/source/core/StarList.hpp
@@ -668,14 +668,14 @@ size_t RandomAccessListMixin<BaseList>::lastIndexOf(const_reference e, size_t ti
template <typename BaseList>
auto RandomAccessListMixin<BaseList>::at(size_t n) const -> const_reference {
if (n >= Base::size())
- throw OutOfRangeException(strf("out of range list::at(%s)", n));
+ throw OutOfRangeException(strf("out of range list::at({})", n));
return operator[](n);
}
template <typename BaseList>
auto RandomAccessListMixin<BaseList>::at(size_t n) -> reference {
if (n >= Base::size())
- throw OutOfRangeException(strf("out of range list::at(%s)", n));
+ throw OutOfRangeException(strf("out of range list::at({})", n));
return operator[](n);
}
diff --git a/source/core/StarLockFile_unix.cpp b/source/core/StarLockFile_unix.cpp
index 9677f2d..298c636 100644
--- a/source/core/StarLockFile_unix.cpp
+++ b/source/core/StarLockFile_unix.cpp
@@ -39,7 +39,7 @@ bool LockFile::lock(int64_t timeout) {
auto doFLock = [](String const& filename, bool block) -> shared_ptr<int> {
int fd = open(filename.utf8Ptr(), O_RDONLY | O_CREAT, 0644);
if (fd < 0)
- throw StarException(strf("Could not open lock file %s, %s\n", filename, strerror(errno)));
+ throw StarException(strf("Could not open lock file {}, {}\n", filename, strerror(errno)));
int ret;
if (block)
@@ -50,7 +50,7 @@ bool LockFile::lock(int64_t timeout) {
if (ret != 0) {
close(fd);
if (errno != EWOULDBLOCK)
- throw StarException(strf("Could not lock file %s, %s\n", filename, strerror(errno)));
+ throw StarException(strf("Could not lock file {}, {}\n", filename, strerror(errno)));
return {};
}
diff --git a/source/core/StarLockFile_windows.cpp b/source/core/StarLockFile_windows.cpp
index 1cf1473..33692fb 100644
--- a/source/core/StarLockFile_windows.cpp
+++ b/source/core/StarLockFile_windows.cpp
@@ -41,7 +41,7 @@ bool LockFile::lock(int64_t timeout) {
if (handle == INVALID_HANDLE_VALUE) {
if (GetLastError() == ERROR_SHARING_VIOLATION)
return {};
- throw StarException(strf("Could not open lock file %s, error code %s\n", filename, GetLastError()));
+ throw StarException(strf("Could not open lock file {}, error code {}\n", filename, GetLastError()));
}
return make_shared<HANDLE>(handle);
diff --git a/source/core/StarLogging.cpp b/source/core/StarLogging.cpp
index 2a7f88e..55cd27d 100644
--- a/source/core/StarLogging.cpp
+++ b/source/core/StarLogging.cpp
@@ -24,7 +24,7 @@ LogLevel LogSink::level() {
void StdoutLogSink::log(char const* msg, LogLevel level) {
MutexLocker locker(m_logMutex);
- coutf("[%s] %s\n", LogLevelNames.getRight(level), msg);
+ coutf("[{}] {}\n", LogLevelNames.getRight(level), msg);
}
FileLogSink::FileLogSink(String const& filename, LogLevel level, bool truncate) {
@@ -37,7 +37,7 @@ FileLogSink::FileLogSink(String const& filename, LogLevel level, bool truncate)
void FileLogSink::log(char const* msg, LogLevel level) {
MutexLocker locker(m_logMutex);
- auto line = strf("[%s] [%s] %s\n", Time::printCurrentDateAndTime("<hours>:<minutes>:<seconds>.<millis>"), LogLevelNames.getRight(level), msg);
+ auto line = strf("[{}] [{}] {}\n", Time::printCurrentDateAndTime("<hours>:<minutes>:<seconds>.<millis>"), LogLevelNames.getRight(level), msg);
m_output->write(line.data(), line.size());
}
diff --git a/source/core/StarLogging.hpp b/source/core/StarLogging.hpp
index d90e0e1..ae47e40 100644
--- a/source/core/StarLogging.hpp
+++ b/source/core/StarLogging.hpp
@@ -185,7 +185,7 @@ void Logger::error(char const* msg, Args const&... args) {
template <typename T>
void LogMap::set(String const& key, T const& t) {
- setValue(key, strf("%s", t));
+ setValue(key, strf("{}", t));
}
}
diff --git a/source/core/StarLua.cpp b/source/core/StarLua.cpp
index 6034c06..eb8541c 100644
--- a/source/core/StarLua.cpp
+++ b/source/core/StarLua.cpp
@@ -65,7 +65,7 @@ LuaCallbacks& LuaCallbacks::merge(LuaCallbacks const& callbacks) {
for (auto const& pair : callbacks.m_callbacks)
m_callbacks.add(pair.first, pair.second);
} catch (MapException const& e) {
- throw LuaException(strf("Failed to merge LuaCallbacks: %s", outputException(e, true)));
+ throw LuaException(strf("Failed to merge LuaCallbacks: {}", outputException(e, true)));
}
return *this;
@@ -481,7 +481,7 @@ void LuaEngine::threadPushFunction(int threadIndex, int functionIndex) {
int status = lua_status(thread);
lua_Debug ar;
if (status != LUA_OK || lua_getstack(thread, 0, &ar) > 0 || lua_gettop(thread) > 0)
- throw LuaException(strf("Cannot push function to active or errored thread with status %s", status));
+ throw LuaException(strf("Cannot push function to active or errored thread with status {}", status));
pushHandle(thread, functionIndex);
}
@@ -633,9 +633,9 @@ void LuaEngine::handleError(lua_State* state, int res) {
String error;
if (lua_isstring(state, -1))
- error = strf("Error code %s, %s", res, lua_tostring(state, -1));
+ error = strf("Error code {}, {}", res, lua_tostring(state, -1));
else
- error = strf("Error code %s, <unknown error>", res);
+ error = strf("Error code {}, <unknown error>", res);
lua_pop(state, 1);
diff --git a/source/core/StarLua.hpp b/source/core/StarLua.hpp
index 95b4499..9241ec4 100644
--- a/source/core/StarLua.hpp
+++ b/source/core/StarLua.hpp
@@ -1717,20 +1717,20 @@ T& LuaUserData::get() const {
template <typename Function>
void LuaCallbacks::registerCallback(String name, Function&& func) {
if (!m_callbacks.insert(name, LuaDetail::wrapFunction(forward<Function>(func))).second)
- throw LuaException::format("Lua callback '%s' was registered twice", name);
+ throw LuaException::format("Lua callback '{}' was registered twice", name);
}
template <typename Return, typename... Args, typename Function>
void LuaCallbacks::registerCallbackWithSignature(String name, Function&& func) {
if (!m_callbacks.insert(name, LuaDetail::wrapFunctionWithSignature<Return, Args...>(forward<Function>(func))).second)
- throw LuaException::format("Lua callback '%s' was registered twice", name);
+ throw LuaException::format("Lua callback '{}' was registered twice", name);
}
template <typename T>
template <typename Function>
void LuaMethods<T>::registerMethod(String name, Function&& func) {
if (!m_methods.insert(name, LuaDetail::wrapMethod(forward<Function>(move(func)))).second)
- throw LuaException::format("Lua method '%s' was registered twice", name);
+ throw LuaException::format("Lua method '{}' was registered twice", name);
}
template <typename T>
@@ -1738,7 +1738,7 @@ template <typename Return, typename... Args, typename Function>
void LuaMethods<T>::registerMethodWithSignature(String name, Function&& func) {
if (!m_methods.insert(name, LuaDetail::wrapMethodWithSignature<Return, Args...>(forward<Function>(move(func))))
.second)
- throw LuaException::format("Lua method '%s' was registered twice", name);
+ throw LuaException::format("Lua method '{}' was registered twice", name);
}
template <typename T>
@@ -1766,7 +1766,7 @@ Ret LuaContext::invokePath(String const& key, Args const&... args) const {
auto p = getPath(key);
if (auto f = p.ptr<LuaFunction>())
return f->invoke<Ret>(args...);
- throw LuaException::format("invokePath called on path '%s' which is not function type", key);
+ throw LuaException::format("invokePath called on path '{}' which is not function type", key);
}
template <typename T>
@@ -1867,14 +1867,14 @@ template <typename T>
T LuaEngine::luaTo(LuaValue&& v) {
if (auto res = luaMaybeTo<T>(move(v)))
return res.take();
- throw LuaConversionException::format("Error converting LuaValue to type '%s'", typeid(T).name());
+ throw LuaConversionException::format("Error converting LuaValue to type '{}'", typeid(T).name());
}
template <typename T>
T LuaEngine::luaTo(LuaValue const& v) {
if (auto res = luaMaybeTo<T>(v))
return res.take();
- throw LuaConversionException::format("Error converting LuaValue to type '%s'", typeid(T).name());
+ throw LuaConversionException::format("Error converting LuaValue to type '{}'", typeid(T).name());
}
template <typename Container>
@@ -2089,7 +2089,7 @@ template <typename T>
T* LuaEngine::getUserData(int handleIndex) {
int typeRef = m_registeredUserDataTypes.value(typeid(T), LUA_NOREF);
if (typeRef == LUA_NOREF)
- throw LuaException::format("Cannot convert userdata type of %s, not registered", typeid(T).name());
+ throw LuaException::format("Cannot convert userdata type of {}, not registered", typeid(T).name());
lua_checkstack(m_state, 3);
@@ -2103,7 +2103,7 @@ T* LuaEngine::getUserData(int handleIndex) {
lua_rawgeti(m_state, LUA_REGISTRYINDEX, typeRef);
if (!lua_rawequal(m_state, -1, -2)) {
lua_pop(m_state, 3);
- throw LuaException::format("Improper conversion from userdata to type %s", typeid(T).name());
+ throw LuaException::format("Improper conversion from userdata to type {}", typeid(T).name());
}
lua_pop(m_state, 3);
diff --git a/source/core/StarMap.hpp b/source/core/StarMap.hpp
index e4941f3..cf9c260 100644
--- a/source/core/StarMap.hpp
+++ b/source/core/StarMap.hpp
@@ -163,7 +163,7 @@ template <typename BaseMap>
auto MapMixin<BaseMap>::take(key_type const& k) -> mapped_type {
if (auto v = maybeTake(k))
return v.take();
- throw MapException(strf("Key '%s' not found in Map::take()", outputAny(k)));
+ throw MapException(strf("Key '{}' not found in Map::take()", outputAny(k)));
}
template <typename BaseMap>
@@ -182,7 +182,7 @@ template <typename BaseMap>
auto MapMixin<BaseMap>::get(key_type const& k) -> mapped_type& {
iterator i = Base::find(k);
if (i == Base::end())
- throw MapException(strf("Key '%s' not found in Map::get()", outputAny(k)));
+ throw MapException(strf("Key '{}' not found in Map::get()", outputAny(k)));
return i->second;
}
@@ -190,7 +190,7 @@ template <typename BaseMap>
auto MapMixin<BaseMap>::get(key_type const& k) const -> mapped_type const& {
const_iterator i = Base::find(k);
if (i == Base::end())
- throw MapException(strf("Key '%s' not found in Map::get()", outputAny(k)));
+ throw MapException(strf("Key '{}' not found in Map::get()", outputAny(k)));
return i->second;
}
@@ -236,7 +236,7 @@ auto MapMixin<BaseMap>::keyOf(mapped_type const& v) const -> key_type {
if (i->second == v)
return i->first;
}
- throw MapException(strf("Value '%s' not found in Map::keyOf()", outputAny(v)));
+ throw MapException(strf("Value '{}' not found in Map::keyOf()", outputAny(v)));
}
template <typename BaseMap>
@@ -267,7 +267,7 @@ template <typename BaseMap>
auto MapMixin<BaseMap>::add(key_type k, mapped_type v) -> mapped_type& {
auto pair = Base::insert(value_type(move(k), move(v)));
if (!pair.second)
- throw MapException(strf("Entry with key '%s' already present.", outputAny(k)));
+ throw MapException(strf("Entry with key '{}' already present.", outputAny(k)));
else
return pair.first->second;
}
diff --git a/source/core/StarMultiArray.hpp b/source/core/StarMultiArray.hpp
index f2cf155..3668c8a 100644
--- a/source/core/StarMultiArray.hpp
+++ b/source/core/StarMultiArray.hpp
@@ -291,7 +291,7 @@ template <typename Element, size_t Rank>
Element const& MultiArray<Element, Rank>::at(IndexArray const& index) const {
for (size_t i = Rank; i != 0; --i) {
if (index[i - 1] >= m_shape[i - 1])
- throw MultiArrayException(strf("Out of bounds on MultiArray::at(%s)", index));
+ throw MultiArrayException(strf("Out of bounds on MultiArray::at({})", index));
}
return m_data[storageIndex(index)];
@@ -301,7 +301,7 @@ template <typename Element, size_t Rank>
Element& MultiArray<Element, Rank>::at(IndexArray const& index) {
for (size_t i = Rank; i != 0; --i) {
if (index[i - 1] >= m_shape[i - 1])
- throw MultiArrayException(strf("Out of bounds on MultiArray::at(%s)", index));
+ throw MultiArrayException(strf("Out of bounds on MultiArray::at({})", index));
}
return m_data[storageIndex(index)];
@@ -323,7 +323,7 @@ template <typename Element, size_t Rank>
void MultiArray<Element, Rank>::set(IndexArray const& index, Element element) {
for (size_t i = Rank; i != 0; --i) {
if (index[i - 1] >= m_shape[i - 1])
- throw MultiArrayException(strf("Out of bounds on MultiArray::set(%s)", index));
+ throw MultiArrayException(strf("Out of bounds on MultiArray::set({})", index));
}
m_data[storageIndex(index)] = move(element);
diff --git a/source/core/StarNetElementContainers.hpp b/source/core/StarNetElementContainers.hpp
index 5c2fd71..2127076 100644
--- a/source/core/StarNetElementContainers.hpp
+++ b/source/core/StarNetElementContainers.hpp
@@ -266,7 +266,7 @@ auto NetElementMapWrapper<BaseMap>::insert(key_type k, mapped_type v) -> pair<co
template <typename BaseMap>
void NetElementMapWrapper<BaseMap>::add(key_type k, mapped_type v) {
if (!insert(value_type(move(k), move(v))).second)
- throw MapException::format("Entry with key '%s' already present.", outputAny(k));
+ throw MapException::format("Entry with key '{}' already present.", outputAny(k));
}
template <typename BaseMap>
@@ -321,7 +321,7 @@ template <typename BaseMap>
auto NetElementMapWrapper<BaseMap>::take(key_type const& k) -> mapped_type {
auto i = BaseMap::find(k);
if (i == BaseMap::end())
- throw MapException::format("Key '%s' not found in Map::take()", outputAny(k));
+ throw MapException::format("Key '{}' not found in Map::take()", outputAny(k));
auto m = move(i->second);
erase(i);
return m;
diff --git a/source/core/StarNetImpl.hpp b/source/core/StarNetImpl.hpp
index 80d75da..076b181 100644
--- a/source/core/StarNetImpl.hpp
+++ b/source/core/StarNetImpl.hpp
@@ -57,7 +57,7 @@ inline String netErrorString() {
return result;
#else
- return strf("%s - %s", errno, strerror(errno));
+ return strf("{} - {}", errno, strerror(errno));
#endif
}
@@ -144,7 +144,7 @@ struct SocketImpl {
int ret = ::setsockopt(socketDesc, level, optname, optval, len);
#endif
if (ret < 0)
- throw NetworkException(strf("setSockOpt failed to set %d, %d: %s", level, optname, netErrorString()));
+ throw NetworkException(strf("setSockOpt failed to set {}, {}: {}", level, optname, netErrorString()));
}
#ifdef STAR_SYSTEM_FAMILY_WINDOWS
diff --git a/source/core/StarOptionParser.cpp b/source/core/StarOptionParser.cpp
index ecf6e28..f849f43 100644
--- a/source/core/StarOptionParser.cpp
+++ b/source/core/StarOptionParser.cpp
@@ -17,12 +17,12 @@ void OptionParser::setAdditionalHelp(String help) {
void OptionParser::addSwitch(String const& flag, String description) {
if (!m_options.insert(flag, Switch{flag, move(description)}).second)
- throw OptionParserException::format("Duplicate switch '-%s' added", flag);
+ throw OptionParserException::format("Duplicate switch '-{}' added", flag);
}
void OptionParser::addParameter(String const& flag, String argument, RequirementMode requirementMode, String description) {
if (!m_options.insert(flag, Parameter{flag, move(argument), requirementMode, move(description)}).second)
- throw OptionParserException::format("Duplicate flag '-%s' added", flag);
+ throw OptionParserException::format("Duplicate flag '-{}' added", flag);
}
void OptionParser::addArgument(String argument, RequirementMode requirementMode, String description) {
@@ -46,7 +46,7 @@ pair<OptionParser::Options, StringList> OptionParser::parseOptions(StringList co
String flag = arg.substr(1);
auto option = m_options.maybe(flag);
if (!option) {
- errors.append(strf("No such option '-%s'", flag));
+ errors.append(strf("No such option '-{}'", flag));
continue;
}
@@ -55,12 +55,12 @@ pair<OptionParser::Options, StringList> OptionParser::parseOptions(StringList co
} else {
auto const& parameter = option->get<Parameter>();
if (!it.hasNext()) {
- errors.append(strf("Option '-%s' must be followed by an argument", flag));
+ errors.append(strf("Option '-{}' must be followed by an argument", flag));
continue;
}
String val = it.next();
if (parameter.requirementMode != Multiple && result.parameters.contains(flag)) {
- errors.append(strf("Option with argument '-%s' specified multiple times", flag));
+ errors.append(strf("Option with argument '-{}' specified multiple times", flag));
continue;
}
result.parameters[move(flag)].append(move(val));
@@ -75,7 +75,7 @@ pair<OptionParser::Options, StringList> OptionParser::parseOptions(StringList co
if (pair.second.is<Parameter>()) {
auto const& na = pair.second.get<Parameter>();
if (na.requirementMode == Required && !result.parameters.contains(pair.first))
- errors.append(strf("Missing required flag with argument '-%s'", pair.first));
+ errors.append(strf("Missing required flag with argument '-{}'", pair.first));
}
}
@@ -91,72 +91,72 @@ pair<OptionParser::Options, StringList> OptionParser::parseOptions(StringList co
}
if (result.arguments.size() < minimumArguments)
errors.append(strf(
- "Too few positional arguments given, expected at least %s got %s", minimumArguments, result.arguments.size()));
+ "Too few positional arguments given, expected at least {} got {}", minimumArguments, result.arguments.size()));
if (result.arguments.size() > maximumArguments)
errors.append(strf(
- "Too many positional arguments given, expected at most %s got %s", maximumArguments, result.arguments.size()));
+ "Too many positional arguments given, expected at most {} got {}", maximumArguments, result.arguments.size()));
return {move(result), move(errors)};
}
void OptionParser::printHelp(std::ostream& os) const {
if (!m_commandName.empty() && !m_summary.empty())
- format(os, "%s: %s\n\n", m_commandName, m_summary);
+ format(os, "{}: {}\n\n", m_commandName, m_summary);
else if (!m_commandName.empty())
- format(os, "%s:\n\n", m_commandName);
+ format(os, "{}:\n\n", m_commandName);
else if (!m_summary.empty())
- format(os, "%s\n\n", m_summary);
+ format(os, "{}\n\n", m_summary);
String cmdLineText;
for (auto const& p : m_options) {
if (p.second.is<Switch>()) {
- cmdLineText += strf(" [-%s]", p.first);
+ cmdLineText += strf(" [-{}]", p.first);
} else {
auto const& parameter = p.second.get<Parameter>();
if (parameter.requirementMode == Optional)
- cmdLineText += strf(" [-%s <%s>]", parameter.flag, parameter.argument);
+ cmdLineText += strf(" [-{} <{}>]", parameter.flag, parameter.argument);
else if (parameter.requirementMode == Required)
- cmdLineText += strf(" -%s <%s>", parameter.flag, parameter.argument);
+ cmdLineText += strf(" -{} <{}>", parameter.flag, parameter.argument);
else if (parameter.requirementMode == Multiple)
- cmdLineText += strf(" [-%s <%s>]...", parameter.flag, parameter.argument);
+ cmdLineText += strf(" [-{} <{}>]...", parameter.flag, parameter.argument);
}
}
for (auto const& p : m_arguments) {
if (p.requirementMode == Optional)
- cmdLineText += strf(" [<%s>]", p.argumentName);
+ cmdLineText += strf(" [<{}>]", p.argumentName);
else if (p.requirementMode == Required)
- cmdLineText += strf(" <%s>", p.argumentName);
+ cmdLineText += strf(" <{}>", p.argumentName);
else
- cmdLineText += strf(" [<%s>...]", p.argumentName);
+ cmdLineText += strf(" [<{}>...]", p.argumentName);
}
if (m_commandName.empty())
- format(os, "Command Line Usage:%s\n", cmdLineText);
+ format(os, "Command Line Usage:{}\n", cmdLineText);
else
- format(os, "Command Line Usage: %s%s\n", m_commandName, cmdLineText);
+ format(os, "Command Line Usage: {}{}\n", m_commandName, cmdLineText);
for (auto const& p : m_options) {
if (p.second.is<Switch>()) {
auto const& sw = p.second.get<Switch>();
if (!sw.description.empty())
- format(os, " -%s\t- %s\n", sw.flag, sw.description);
+ format(os, " -{}\t- {}\n", sw.flag, sw.description);
}
if (p.second.is<Parameter>()) {
auto const& parameter = p.second.get<Parameter>();
if (!parameter.description.empty())
- format(os, " -%s <%s>\t- %s\n", parameter.flag, parameter.argument, parameter.description);
+ format(os, " -{} <{}>\t- {}\n", parameter.flag, parameter.argument, parameter.description);
}
}
for (auto const& p : m_arguments) {
if (!p.description.empty())
- format(os, " <%s>\t- %s\n", p.argumentName, p.description);
+ format(os, " <{}>\t- {}\n", p.argumentName, p.description);
}
if (!m_additionalHelp.empty())
- format(os, "\n%s\n", m_additionalHelp);
+ format(os, "\n{}\n", m_additionalHelp);
}
}
diff --git a/source/core/StarOrderedMap.hpp b/source/core/StarOrderedMap.hpp
index 71fe816..4f2dc22 100644
--- a/source/core/StarOrderedMap.hpp
+++ b/source/core/StarOrderedMap.hpp
@@ -228,7 +228,7 @@ template <template <typename...> class Map, typename Key, typename Value, typena
auto OrderedMapWrapper<Map, Key, Value, Allocator, MapArgs...>::get(key_type const& k) -> mapped_type& {
auto i = m_map.find(k);
if (i == m_map.end())
- throw MapException(strf("Key '%s' not found in OrderedMap::get()", outputAny(k)));
+ throw MapException(strf("Key '{}' not found in OrderedMap::get()", outputAny(k)));
return i->second->second;
}
@@ -308,7 +308,7 @@ auto OrderedMapWrapper<Map, Key, Value, Allocator, MapArgs...>::keyOf(mapped_typ
if (i->second == v)
return i->first;
}
- throw MapException(strf("Value '%s' not found in OrderedMap::keyOf()", outputAny(v)));
+ throw MapException(strf("Value '{}' not found in OrderedMap::keyOf()", outputAny(v)));
}
template <template <typename...> class Map, typename Key, typename Value, typename Allocator, typename... MapArgs>
@@ -359,7 +359,7 @@ template <template <typename...> class Map, typename Key, typename Value, typena
auto OrderedMapWrapper<Map, Key, Value, Allocator, MapArgs...>::add(key_type k, mapped_type v) -> mapped_type& {
auto pair = insert(value_type(move(k), move(v)));
if (!pair.second)
- throw MapException(strf("Entry with key '%s' already present.", outputAny(k)));
+ throw MapException(strf("Entry with key '{}' already present.", outputAny(k)));
else
return pair.first->second;
}
@@ -405,7 +405,7 @@ auto OrderedMapWrapper<Map, Key, Value, Allocator, MapArgs...>::take(key_type co
m_order.erase(i->second);
return v;
} else {
- throw MapException(strf("Key '%s' not found in OrderedMap::take()", outputAny(k)));
+ throw MapException(strf("Key '{}' not found in OrderedMap::take()", outputAny(k)));
}
}
@@ -509,7 +509,7 @@ auto OrderedMapWrapper<Map, Key, Value, Allocator, MapArgs...>::indexOf(key_type
template <template <typename...> class Map, typename Key, typename Value, typename Allocator, typename... MapArgs>
auto OrderedMapWrapper<Map, Key, Value, Allocator, MapArgs...>::keyAt(size_t i) const -> key_type const& {
if (i >= size())
- throw MapException(strf("index %s out of range in OrderedMap::at()", i));
+ throw MapException(strf("index {} out of range in OrderedMap::at()", i));
auto it = begin();
std::advance(it, i);
@@ -524,7 +524,7 @@ auto OrderedMapWrapper<Map, Key, Value, Allocator, MapArgs...>::valueAt(size_t i
template <template <typename...> class Map, typename Key, typename Value, typename Allocator, typename... MapArgs>
auto OrderedMapWrapper<Map, Key, Value, Allocator, MapArgs...>::valueAt(size_t i) -> mapped_type& {
if (i >= size())
- throw MapException(strf("index %s out of range in OrderedMap::valueAt()", i));
+ throw MapException(strf("index {} out of range in OrderedMap::valueAt()", i));
auto it = m_order.begin();
std::advance(it, i);
@@ -612,7 +612,7 @@ template <template <typename...> class Map, typename Key, typename Value, typena
void OrderedMapWrapper<Map, Key, Value, Allocator, MapArgs...>::toBack(key_type const& k) {
auto i = m_map.find(k);
if (i == m_map.end())
- throw MapException(strf("Key not found in OrderedMap::toBack('%s')", outputAny(k)));
+ throw MapException(strf("Key not found in OrderedMap::toBack('{}')", outputAny(k)));
toBack(i->second);
}
@@ -621,7 +621,7 @@ template <template <typename...> class Map, typename Key, typename Value, typena
void OrderedMapWrapper<Map, Key, Value, Allocator, MapArgs...>::toFront(key_type const& k) {
auto i = m_map.find(k);
if (i == m_map.end())
- throw MapException(strf("Key not found in OrderedMap::toFront('%s')", outputAny(k)));
+ throw MapException(strf("Key not found in OrderedMap::toFront('{}')", outputAny(k)));
toFront(i->second);
}
diff --git a/source/core/StarSignalHandler_windows.cpp b/source/core/StarSignalHandler_windows.cpp
index 0445aba..29e93c5 100644
--- a/source/core/StarSignalHandler_windows.cpp
+++ b/source/core/StarSignalHandler_windows.cpp
@@ -59,19 +59,19 @@ struct SignalHandlerImpl {
else if (modeFlag == 8)
mode = "Execute";
else
- mode = strf("Mode(%s)", modeFlag);
- g_sehMessage = strf("Access violation detected at %s (%s of address %s)",
+ mode = strf("Mode({})", modeFlag);
+ g_sehMessage = strf("Access violation detected at {} ({} of address {})",
ExceptionInfo->ExceptionRecord->ExceptionAddress,
mode,
(PVOID)ExceptionInfo->ExceptionRecord->ExceptionInformation[1]);
} else {
g_sehMessage = msg;
- g_sehMessage = strf("%s (%p @ %s)",
+ g_sehMessage = strf("{} (%p @ {})",
g_sehMessage,
ExceptionInfo->ExceptionRecord->ExceptionCode,
ExceptionInfo->ExceptionRecord->ExceptionAddress);
for (DWORD i = 0; i < ExceptionInfo->ExceptionRecord->NumberParameters; i++)
- g_sehMessage = strf("%s [%s]", g_sehMessage, (PVOID)ExceptionInfo->ExceptionRecord->ExceptionInformation[i]);
+ g_sehMessage = strf("{} [{}]", g_sehMessage, (PVOID)ExceptionInfo->ExceptionRecord->ExceptionInformation[i]);
}
// setup a hijack into our own trampoline as if the failure actually was a
diff --git a/source/core/StarSmallVector.hpp b/source/core/StarSmallVector.hpp
index 38d32a3..2a77a3d 100644
--- a/source/core/StarSmallVector.hpp
+++ b/source/core/StarSmallVector.hpp
@@ -209,7 +209,7 @@ void SmallVector<Element, MaxStackSize>::reserve(size_t newCapacity) {
newCapacity = max(oldCapacity * 2, newCapacity);
auto newMem = (Element*)Star::malloc(newCapacity * sizeof(Element));
if (!newMem)
- throw MemoryException::format("Could not set new SmallVector capacity %s\n", newCapacity);
+ throw MemoryException::format("Could not set new SmallVector capacity {}\n", newCapacity);
size_t size = m_end - m_begin;
auto oldMem = m_begin;
@@ -238,14 +238,14 @@ void SmallVector<Element, MaxStackSize>::reserve(size_t newCapacity) {
template <typename Element, size_t MaxStackSize>
auto SmallVector<Element, MaxStackSize>::at(size_t i) -> reference {
if (i >= size())
- throw OutOfRangeException::format("out of range in SmallVector::at(%s)", i);
+ throw OutOfRangeException::format("out of range in SmallVector::at({})", i);
return m_begin[i];
}
template <typename Element, size_t MaxStackSize>
auto SmallVector<Element, MaxStackSize>::at(size_t i) const -> const_reference {
if (i >= size())
- throw OutOfRangeException::format("out of range in SmallVector::at(%s)", i);
+ throw OutOfRangeException::format("out of range in SmallVector::at({})", i);
return m_begin[i];
}
diff --git a/source/core/StarSocket.cpp b/source/core/StarSocket.cpp
index 95ffe7c..9b866b8 100644
--- a/source/core/StarSocket.cpp
+++ b/source/core/StarSocket.cpp
@@ -49,7 +49,7 @@ Maybe<SocketPollResult> Socket::poll(SocketPollQuery const& query, unsigned time
ret = ::select(0, &readfs, &writefs, &exceptfs, &time);
if (ret < 0)
- throw NetworkException::format("Error during call to select, '%s'", netErrorString());
+ throw NetworkException::format("Error during call to select, '{}'", netErrorString());
if (ret == 0)
return {};
@@ -82,7 +82,7 @@ Maybe<SocketPollResult> Socket::poll(SocketPollQuery const& query, unsigned time
ret = ::poll(pollfds.get(), query.size(), timeout);
if (ret < 0)
- throw NetworkException::format("Error during call to poll, '%s'", netErrorString());
+ throw NetworkException::format("Error during call to poll, '{}'", netErrorString());
if (ret == 0)
return {};
@@ -127,18 +127,18 @@ void Socket::bind(HostAddressWithPort const& addressWithPort) {
m_localAddress = addressWithPort;
setNativeFromAddress(m_localAddress, &sockAddr, &sockAddrLen);
if (::bind(m_impl->socketDesc, (struct sockaddr*)&sockAddr, sockAddrLen) < 0)
- throw NetworkException(strf("Cannot bind socket to %s: %s", m_localAddress, netErrorString()));
+ throw NetworkException(strf("Cannot bind socket to {}: {}", m_localAddress, netErrorString()));
m_socketMode = SocketMode::Bound;
- Logger::debug("bind %s (%d)", addressWithPort, m_impl->socketDesc);
+ Logger::debug("bind {} ({})", addressWithPort, m_impl->socketDesc);
}
void Socket::listen(int backlog) {
WriteLocker locker(m_mutex);
if (::listen(m_impl->socketDesc, backlog) != 0)
- throw NetworkException(strf("Could not listen on socket: '%s'", netErrorString()));
+ throw NetworkException(strf("Could not listen on socket: '{}'", netErrorString()));
}
void Socket::setTimeout(unsigned timeout) {
@@ -168,14 +168,14 @@ void Socket::setNonBlocking(bool nonBlocking) {
#ifdef WIN32
unsigned long mode = nonBlocking ? 1 : 0;
if (ioctlsocket(m_impl->socketDesc, FIONBIO, &mode) != 0)
- throw NetworkException::format("Cannot set socket non-blocking mode: %s", netErrorString());
+ throw NetworkException::format("Cannot set socket non-blocking mode: {}", netErrorString());
#else
int flags = fcntl(m_impl->socketDesc, F_GETFL, 0);
if (flags < 0)
- throw NetworkException::format("fcntl failure getting socket flags: %s", netErrorString());
+ throw NetworkException::format("fcntl failure getting socket flags: {}", netErrorString());
flags = nonBlocking ? (flags | O_NONBLOCK) : (flags & ~O_NONBLOCK);
if (fcntl(m_impl->socketDesc, F_SETFL, flags) != 0)
- throw NetworkException::format("fcntl failure setting non-blocking mode: %s", netErrorString());
+ throw NetworkException::format("fcntl failure setting non-blocking mode: {}", netErrorString());
#endif
}
@@ -216,7 +216,7 @@ Socket::Socket(SocketType type, NetworkMode networkMode)
m_impl->socketDesc = ::socket(AF_INET6, type == SocketType::Tcp ? SOCK_STREAM : SOCK_DGRAM, 0);
if (invalidSocketDescriptor(m_impl->socketDesc))
- throw NetworkException(strf("cannot create socket: %s", netErrorString()));
+ throw NetworkException(strf("cannot create socket: {}", netErrorString()));
m_socketMode = SocketMode::Shutdown;
setTimeout(60000);
@@ -231,7 +231,7 @@ Socket::Socket(NetworkMode networkMode, SocketImplPtr impl, SocketMode socketMod
void Socket::checkOpen(char const* methodName) const {
if (m_socketMode == SocketMode::Closed)
- throw SocketClosedException::format("Socket not open in %s", methodName);
+ throw SocketClosedException::format("Socket not open in {}", methodName);
}
void Socket::doShutdown() {
diff --git a/source/core/StarStaticVector.hpp b/source/core/StarStaticVector.hpp
index 693dc10..3a4a7cc 100644
--- a/source/core/StarStaticVector.hpp
+++ b/source/core/StarStaticVector.hpp
@@ -188,7 +188,7 @@ bool StaticVector<Element, MaxSize>::empty() const {
template <typename Element, size_t MaxSize>
void StaticVector<Element, MaxSize>::resize(size_t size, Element const& e) {
if (size > MaxSize)
- throw StaticVectorSizeException::format("StaticVector::resize(%s) out of range %s", m_size + size, MaxSize);
+ throw StaticVectorSizeException::format("StaticVector::resize({}) out of range {}", m_size + size, MaxSize);
for (size_t i = m_size; i > size; --i)
pop_back();
@@ -199,14 +199,14 @@ void StaticVector<Element, MaxSize>::resize(size_t size, Element const& e) {
template <typename Element, size_t MaxSize>
auto StaticVector<Element, MaxSize>::at(size_t i) -> reference {
if (i >= m_size)
- throw OutOfRangeException::format("out of range in StaticVector::at(%s)", i);
+ throw OutOfRangeException::format("out of range in StaticVector::at({})", i);
return ptr()[i];
}
template <typename Element, size_t MaxSize>
auto StaticVector<Element, MaxSize>::at(size_t i) const -> const_reference {
if (i >= m_size)
- throw OutOfRangeException::format("out of range in StaticVector::at(%s)", i);
+ throw OutOfRangeException::format("out of range in StaticVector::at({})", i);
return ptr()[i];
}
@@ -329,7 +329,7 @@ template <typename Element, size_t MaxSize>
template <typename... Args>
void StaticVector<Element, MaxSize>::emplace_back(Args&&... args) {
if (m_size + 1 > MaxSize)
- throw StaticVectorSizeException::format("StaticVector::emplace_back would extend StaticVector beyond size %s", MaxSize);
+ throw StaticVectorSizeException::format("StaticVector::emplace_back would extend StaticVector beyond size {}", MaxSize);
m_size += 1;
new (ptr() + m_size - 1) Element(forward<Args>(args)...);
diff --git a/source/core/StarString.cpp b/source/core/StarString.cpp
index aae3410..924c83b 100644
--- a/source/core/StarString.cpp
+++ b/source/core/StarString.cpp
@@ -187,7 +187,7 @@ bool CaseInsensitiveStringCompare::operator()(String const& lhs, String const& r
String::Char String::at(size_t i) const {
if (i > size())
- throw OutOfRangeException(strf("Out of range in String::at(%s)", i));
+ throw OutOfRangeException(strf("Out of range in String::at({})", i));
return operator[](i);
}
@@ -744,7 +744,7 @@ bool String::equalsIgnoreCase(String const& s) const {
String String::substr(size_t position, size_t n) const {
auto len = size();
if (position > len)
- throw OutOfRangeException(strf("out of range in String::substr(%s, %s)", position, n));
+ throw OutOfRangeException(strf("out of range in String::substr({}, {})", position, n));
if (position == 0 && n >= len)
return *this;
diff --git a/source/core/StarString.hpp b/source/core/StarString.hpp
index 7bca996..a401076 100644
--- a/source/core/StarString.hpp
+++ b/source/core/StarString.hpp
@@ -388,7 +388,7 @@ String String::lookupTags(Lookup&& lookup) const {
auto substrInto = [](std::string const& ref, size_t position, size_t n, std::string& result) {
auto len = ref.size();
if (position > len)
- throw OutOfRangeException(strf("out of range in substrInto: %s", position));
+ throw OutOfRangeException(strf("out of range in substrInto: {}", position));
auto it = ref.begin();
std::advance(it, position);
diff --git a/source/core/StarStringView.cpp b/source/core/StarStringView.cpp
index 7580bf6..36ad9b2 100644
--- a/source/core/StarStringView.cpp
+++ b/source/core/StarStringView.cpp
@@ -78,7 +78,7 @@ StringView::Char StringView::operator[](size_t index) const {
StringView::Char StringView::at(size_t i) const {
if (i > size())
- throw OutOfRangeException(strf("Out of range in StringView::at(%s)", i));
+ throw OutOfRangeException(strf("Out of range in StringView::at({})", i));
return operator[](i);
}
@@ -340,7 +340,7 @@ bool StringView::equalsIgnoreCase(StringView s) const {
StringView StringView::substr(size_t position, size_t n) const {
auto len = size();
if (position > len)
- throw OutOfRangeException(strf("out of range in StringView::substr(%s, %s)", position, n));
+ throw OutOfRangeException(strf("out of range in StringView::substr({}, {})", position, n));
if (position == 0 && n >= len)
return *this;
diff --git a/source/core/StarTcp.cpp b/source/core/StarTcp.cpp
index dc64b98..04a74f0 100644
--- a/source/core/StarTcp.cpp
+++ b/source/core/StarTcp.cpp
@@ -31,7 +31,7 @@ TcpSocketPtr TcpSocket::accept() {
if (invalidSocketDescriptor(socketDesc)) {
if (netErrorInterrupt())
return {};
- throw NetworkException(strf("Cannot accept connection: %s", netErrorString()));
+ throw NetworkException(strf("Cannot accept connection: {}", netErrorString()));
}
auto socketImpl = make_shared<SocketImpl>();
@@ -47,7 +47,7 @@ TcpSocketPtr TcpSocket::accept() {
sockPtr->m_localAddress = m_localAddress;
setAddressFromNative(sockPtr->m_remoteAddress, m_localAddress.address().mode(), &sockAddr);
- Logger::debug("accept from %s (%d)", sockPtr->m_remoteAddress, sockPtr->m_impl->socketDesc);
+ Logger::debug("accept from {} ({})", sockPtr->m_remoteAddress, sockPtr->m_impl->socketDesc);
return sockPtr;
}
@@ -83,7 +83,7 @@ size_t TcpSocket::receive(char* data, size_t size) {
} else if (netErrorInterrupt()) {
r = 0;
} else {
- throw NetworkException(strf("tcp recv error: %s", netErrorString()));
+ throw NetworkException(strf("tcp recv error: {}", netErrorString()));
}
}
@@ -113,7 +113,7 @@ size_t TcpSocket::send(char const* data, size_t size) {
} else if (netErrorInterrupt()) {
w = 0;
} else {
- throw NetworkException(strf("tcp send error: %s", netErrorString()));
+ throw NetworkException(strf("tcp send error: {}", netErrorString()));
}
}
@@ -145,7 +145,7 @@ void TcpSocket::connect(HostAddressWithPort const& addressWithPort) {
socklen_t sockAddrLen;
setNativeFromAddress(addressWithPort, &sockAddr, &sockAddrLen);
if (::connect(m_impl->socketDesc, (struct sockaddr*)&sockAddr, sockAddrLen) < 0)
- throw NetworkException(strf("cannot connect to %s: %s", addressWithPort, netErrorString()));
+ throw NetworkException(strf("cannot connect to {}: {}", addressWithPort, netErrorString()));
#if defined STAR_SYSTEM_MACOS || defined STAR_SYSTEM_FREEBSD
// Don't generate sigpipe
@@ -161,7 +161,7 @@ TcpServer::TcpServer(HostAddressWithPort const& address) : m_hostAddress(address
m_hostAddress = address;
m_listenSocket = TcpSocket::listen(address);
m_listenSocket->setNonBlocking(true);
- Logger::debug("TcpServer listening on: %s", address);
+ Logger::debug("TcpServer listening on: {}", address);
}
TcpServer::TcpServer(uint16_t port) : TcpServer(HostAddressWithPort("*", port)) {}
@@ -201,7 +201,7 @@ void TcpServer::setAcceptCallback(AcceptCallback callback, unsigned timeout) {
try {
conn = accept(timeout);
} catch (NetworkException const& e) {
- Logger::error("TcpServer caught exception accepting connection %s", outputException(e, false));
+ Logger::error("TcpServer caught exception accepting connection {}", outputException(e, false));
}
if (conn)
@@ -211,7 +211,7 @@ void TcpServer::setAcceptCallback(AcceptCallback callback, unsigned timeout) {
break;
}
} catch (std::exception const& e) {
- Logger::error("TcpServer will close, listener thread caught exception: %s", outputException(e, true));
+ Logger::error("TcpServer will close, listener thread caught exception: {}", outputException(e, true));
m_listenSocket->close();
}
});
diff --git a/source/core/StarThread_unix.cpp b/source/core/StarThread_unix.cpp
index ba635f9..22fd10d 100644
--- a/source/core/StarThread_unix.cpp
+++ b/source/core/StarThread_unix.cpp
@@ -31,21 +31,21 @@ struct ThreadImpl {
#ifdef STAR_SYSTEM_MACOS
// ensure the name is under the max allowed
char tname[MAX_THREAD_NAMELEN];
- snprintf(tname, sizeof(tname), "%s", ptr->name.utf8Ptr());
+ snprintf(tname, sizeof(tname), "{}", ptr->name.utf8Ptr());
pthread_setname_np(tname);
#endif
ptr->function();
} catch (std::exception const& e) {
if (ptr->name.empty())
- Logger::error("Exception caught in Thread: %s", outputException(e, true));
+ Logger::error("Exception caught in Thread: {}", outputException(e, true));
else
- Logger::error("Exception caught in Thread %s: %s", ptr->name, outputException(e, true));
+ Logger::error("Exception caught in Thread {}: {}", ptr->name, outputException(e, true));
} catch (...) {
if (ptr->name.empty())
Logger::error("Unknown exception caught in Thread");
else
- Logger::error("Unknown exception caught in Thread %s", ptr->name);
+ Logger::error("Unknown exception caught in Thread {}", ptr->name);
}
ptr->stopped = true;
return nullptr;
@@ -65,12 +65,12 @@ struct ThreadImpl {
if (ret != 0) {
stopped = true;
joined = true;
- throw StarException(strf("Failed to create thread, error %s", ret));
+ throw StarException(strf("Failed to create thread, error {}", ret));
}
// ensure the name is under the max allowed
char tname[MAX_THREAD_NAMELEN];
- snprintf(tname, sizeof(tname), "%s", name.utf8Ptr());
+ snprintf(tname, sizeof(tname), "{}", name.utf8Ptr());
#ifdef STAR_SYSTEM_FREEBSD
pthread_set_name_np(pthread, tname);
@@ -86,7 +86,7 @@ struct ThreadImpl {
return false;
int ret = pthread_join(pthread, NULL);
if (ret != 0)
- throw StarException(strf("Failed to join thread, error %s", ret));
+ throw StarException(strf("Failed to join thread, error {}", ret));
joined = true;
return true;
}
@@ -242,7 +242,7 @@ void Thread::yield() {
unsigned Thread::numberOfProcessors() {
long nprocs = sysconf(_SC_NPROCESSORS_ONLN);
if (nprocs < 1)
- throw StarException(strf("Could not determine number of CPUs online: %s\n", strerror(errno)));
+ throw StarException(strf("Could not determine number of CPUs online: {}\n", strerror(errno)));
return nprocs;
}
diff --git a/source/core/StarThread_windows.cpp b/source/core/StarThread_windows.cpp
index 86ebbf5..b8df19b 100644
--- a/source/core/StarThread_windows.cpp
+++ b/source/core/StarThread_windows.cpp
@@ -49,14 +49,14 @@ struct ThreadImpl {
ptr->function();
} catch (std::exception const& e) {
if (ptr->name.empty())
- Logger::error("Exception caught in Thread: %s", outputException(e, true));
+ Logger::error("Exception caught in Thread: {}", outputException(e, true));
else
- Logger::error("Exception caught in Thread %s: %s", ptr->name, outputException(e, true));
+ Logger::error("Exception caught in Thread {}: {}", ptr->name, outputException(e, true));
} catch (...) {
if (ptr->name.empty())
Logger::error("Unknown exception caught in Thread");
else
- Logger::error("Unknown exception caught in Thread %s", ptr->name);
+ Logger::error("Unknown exception caught in Thread {}", ptr->name);
}
ptr->stopped = true;
return 0;
diff --git a/source/core/StarTime.cpp b/source/core/StarTime.cpp
index 4d0b516..abb6aae 100644
--- a/source/core/StarTime.cpp
+++ b/source/core/StarTime.cpp
@@ -28,19 +28,19 @@ String Time::printDuration(double time) {
if (time >= 3600) {
int numHours = (int)time / 3600;
- hours = strf("%d hour%s", numHours, numHours == 1 ? "" : "s");
+ hours = strf("{} hour{}", numHours, numHours == 1 ? "" : "s");
}
if (time >= 60) {
int numMinutes = (int)(time / 60) % 60;
- minutes = strf("%s minute%s", numMinutes, numMinutes == 1 ? "" : "s");
+ minutes = strf("{} minute{}", numMinutes, numMinutes == 1 ? "" : "s");
}
if (time >= 1) {
int numSeconds = (int)time % 60;
- seconds = strf("%s second%s", numSeconds, numSeconds == 1 ? "" : "s");
+ seconds = strf("{} second{}", numSeconds, numSeconds == 1 ? "" : "s");
}
int numMilliseconds = round(time * 1000);
- milliseconds = strf("%s millisecond%s", numMilliseconds, numMilliseconds == 1 ? "" : "s");
+ milliseconds = strf("{} millisecond{}", numMilliseconds, numMilliseconds == 1 ? "" : "s");
return String::joinWith(", ", hours, minutes, seconds, milliseconds);
}
diff --git a/source/core/StarTime_unix.cpp b/source/core/StarTime_unix.cpp
index 50ed954..c5259c0 100644
--- a/source/core/StarTime_unix.cpp
+++ b/source/core/StarTime_unix.cpp
@@ -18,13 +18,13 @@ String Time::printDateAndTime(int64_t epochTicks, String format) {
localtime_r(&requestedTime, &ptm);
return format.replaceTags(StringMap<String>{
- {"year", strf("%04d", ptm.tm_year + 1900)},
- {"month", strf("%02d", ptm.tm_mon + 1)},
- {"day", strf("%02d", ptm.tm_mday)},
- {"hours", strf("%02d", ptm.tm_hour)},
- {"minutes", strf("%02d", ptm.tm_min)},
- {"seconds", strf("%02d", ptm.tm_sec)},
- {"millis", strf("%03d", (epochTicks % epochTickFrequency()) / (epochTickFrequency() / 1000))}
+ {"year", strf("{:04d}", ptm.tm_year + 1900)},
+ {"month", strf("{:02d}", ptm.tm_mon + 1)},
+ {"day", strf("{:02d}", ptm.tm_mday)},
+ {"hours", strf("{:02d}", ptm.tm_hour)},
+ {"minutes", strf("{:02d}", ptm.tm_min)},
+ {"seconds", strf("{:02d}", ptm.tm_sec)},
+ {"millis", strf("{:03d}", (epochTicks % epochTickFrequency()) / (epochTickFrequency() / 1000))}
});
}
diff --git a/source/core/StarTime_windows.cpp b/source/core/StarTime_windows.cpp
index 2b3e797..f1f10b4 100644
--- a/source/core/StarTime_windows.cpp
+++ b/source/core/StarTime_windows.cpp
@@ -14,13 +14,13 @@ String Time::printDateAndTime(int64_t epochTicks, String format) {
ptm = localtime(&requestedTime);
return format.replaceTags(StringMap<String>{
- {"year", strf("%04d", ptm->tm_year + 1900)},
- {"month", strf("%02d", ptm->tm_mon + 1)},
- {"day", strf("%02d", ptm->tm_mday)},
- {"hours", strf("%02d", ptm->tm_hour)},
- {"minutes", strf("%02d", ptm->tm_min)},
- {"seconds", strf("%02d", ptm->tm_sec)},
- {"millis", strf("%03d", (epochTicks % epochTickFrequency()) / (epochTickFrequency() / 1000))},
+ {"year", strf("{:04d}", ptm->tm_year + 1900)},
+ {"month", strf("{:02d}", ptm->tm_mon + 1)},
+ {"day", strf("{:02d}", ptm->tm_mday)},
+ {"hours", strf("{:02d}", ptm->tm_hour)},
+ {"minutes", strf("{:02d}", ptm->tm_min)},
+ {"seconds", strf("{:02d}", ptm->tm_sec)},
+ {"millis", strf("{:03d}", (epochTicks % epochTickFrequency()) / (epochTickFrequency() / 1000))},
});
}
diff --git a/source/core/StarUdp.cpp b/source/core/StarUdp.cpp
index 9ff7b48..c38da41 100644
--- a/source/core/StarUdp.cpp
+++ b/source/core/StarUdp.cpp
@@ -23,7 +23,7 @@ size_t UdpSocket::receive(HostAddressWithPort* address, char* data, size_t datas
else if (netErrorInterrupt())
len = 0;
else
- throw NetworkException(strf("udp recv error: %s", netErrorString()));
+ throw NetworkException(strf("udp recv error: {}", netErrorString()));
}
if (address)
@@ -47,7 +47,7 @@ size_t UdpSocket::send(HostAddressWithPort const& address, char const* data, siz
else if (netErrorInterrupt())
len = 0;
else
- throw NetworkException(strf("udp send error: %s", netErrorString()));
+ throw NetworkException(strf("udp send error: {}", netErrorString()));
}
return len;
@@ -57,7 +57,7 @@ UdpServer::UdpServer(HostAddressWithPort const& address)
: m_hostAddress(address), m_listenSocket(make_shared<UdpSocket>(m_hostAddress.address().mode())) {
m_listenSocket->setNonBlocking(true);
m_listenSocket->bind(m_hostAddress);
- Logger::debug("UdpServer listening on: %s", m_hostAddress);
+ Logger::debug("UdpServer listening on: {}", m_hostAddress);
}
UdpServer::~UdpServer() {
diff --git a/source/core/StarUnicode.cpp b/source/core/StarUnicode.cpp
index 008df96..01e660b 100644
--- a/source/core/StarUnicode.cpp
+++ b/source/core/StarUnicode.cpp
@@ -12,7 +12,7 @@ void throwMissingUtf8End() {
}
void throwInvalidUtf32CodePoint(Utf32Type val) {
- throw UnicodeException::format("Invalid UTF-32 code point %s encountered while trying to encode UTF-8", (int32_t)val);
+ throw UnicodeException::format("Invalid UTF-32 code point {} encountered while trying to encode UTF-8", (int32_t)val);
}
size_t utf8Length(const Utf8Type* utf8, size_t remain) {
diff --git a/source/core/StarUuid.cpp b/source/core/StarUuid.cpp
index 11121b6..6890e5e 100644
--- a/source/core/StarUuid.cpp
+++ b/source/core/StarUuid.cpp
@@ -9,7 +9,7 @@ Uuid::Uuid() : Uuid(Random::randBytes(UuidSize)) {}
Uuid::Uuid(ByteArray const& bytes) {
if (bytes.size() != UuidSize)
- throw UuidException(strf("Size mismatch in reading Uuid from ByteArray: %s vs %s", bytes.size(), UuidSize));
+ throw UuidException(strf("Size mismatch in reading Uuid from ByteArray: {} vs {}", bytes.size(), UuidSize));
bytes.copyTo(m_data.ptr(), UuidSize);
}
diff --git a/source/core/StarWorkerPool.cpp b/source/core/StarWorkerPool.cpp
index fa37a57..2a7003d 100644
--- a/source/core/StarWorkerPool.cpp
+++ b/source/core/StarWorkerPool.cpp
@@ -125,7 +125,7 @@ WorkerPoolHandle WorkerPool::addWork(function<void()> work) {
}
WorkerPool::WorkerThread::WorkerThread(WorkerPool* parent)
- : Thread(strf("WorkerThread for WorkerPool '%s'", parent->m_name)),
+ : Thread(strf("WorkerThread for WorkerPool '{}'", parent->m_name)),
parent(parent),
shouldStop(false),
waiting(false) {