From 30fe237210e3f2cb74f3989ff2e8b8a41b5a6db5 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sat, 11 Apr 2020 12:46:42 -1000 Subject: [PATCH] Update fmtlib --- atdna/test.cpp | 4 +-- extern/fmt | 2 +- include/athena/Global.hpp | 1 - include/athena/IStreamWriter.hpp | 12 ++++---- src/athena/DNAYaml.cpp | 52 ++++++++++++++++---------------- src/athena/Dir.cpp | 2 +- src/athena/FileReader.cpp | 14 ++++----- src/athena/FileReaderWin32.cpp | 14 ++++----- src/athena/FileWriterNix.cpp | 12 ++++---- src/athena/FileWriterWin32.cpp | 12 ++++---- src/athena/Global.cpp | 1 - src/athena/MemoryReader.cpp | 16 +++++----- src/athena/MemoryWriter.cpp | 38 +++++++++++------------ src/athena/Socket.cpp | 10 +++--- src/athena/Utility.cpp | 4 +-- src/athena/VectorWriter.cpp | 10 +++--- 16 files changed, 101 insertions(+), 103 deletions(-) diff --git a/atdna/test.cpp b/atdna/test.cpp index ede95de..7137acd 100644 --- a/atdna/test.cpp +++ b/atdna/test.cpp @@ -18,9 +18,9 @@ int main(int argc, const char** argv) { const bool pass = !w.hasError() && w.position() - pos == binSize && binSize == EXPECTED_BYTES; if (pass) { - fmt::print(fmt("[PASS] {} bytes written\n"), size_t(w.position() - pos)); + fmt::print(FMT_STRING("[PASS] {} bytes written\n"), size_t(w.position() - pos)); } else { - fmt::print(fmt("[FAIL] {} bytes written; {} bytes sized; {} bytes expected\n"), size_t(w.position() - pos), binSize, + fmt::print(FMT_STRING("[FAIL] {} bytes written; {} bytes sized; {} bytes expected\n"), size_t(w.position() - pos), binSize, EXPECTED_BYTES); } diff --git a/extern/fmt b/extern/fmt index 25ff2ef..9bdd159 160000 --- a/extern/fmt +++ b/extern/fmt @@ -1 +1 @@ -Subproject commit 25ff2efc0aeab3ce886fb6be11a1878f3497ec4c +Subproject commit 9bdd1596cef1b57b9556f8bef32dc4a32322ef3e diff --git a/include/athena/Global.hpp b/include/athena/Global.hpp index a746755..e7f34cf 100644 --- a/include/athena/Global.hpp +++ b/include/athena/Global.hpp @@ -5,7 +5,6 @@ #define FMT_STRING_ALIAS 1 #define FMT_ENFORCE_COMPILE_STRING 1 -#define FMT_USE_GRISU 0 #include #ifdef _MSC_VER diff --git a/include/athena/IStreamWriter.hpp b/include/athena/IStreamWriter.hpp index feeb390..2c12984 100644 --- a/include/athena/IStreamWriter.hpp +++ b/include/athena/IStreamWriter.hpp @@ -661,7 +661,7 @@ public: utf8proc_int32_t wc; utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc); if (len < 0) { - atWarning(fmt("invalid UTF-8 character while decoding")); + atWarning(FMT_STRING("invalid UTF-8 character while decoding")); return; } buf += len; @@ -675,7 +675,7 @@ public: if (*buf) { utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc); if (len < 0) { - atWarning(fmt("invalid UTF-8 character while decoding")); + atWarning(FMT_STRING("invalid UTF-8 character while decoding")); return; } buf += len; @@ -709,7 +709,7 @@ public: utf8proc_int32_t wc; utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc); if (len < 0) { - atWarning(fmt("invalid UTF-8 character while decoding")); + atWarning(FMT_STRING("invalid UTF-8 character while decoding")); return; } buf += len; @@ -723,7 +723,7 @@ public: if (*buf) { utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc); if (len < 0) { - atWarning(fmt("invalid UTF-8 character while decoding")); + atWarning(FMT_STRING("invalid UTF-8 character while decoding")); return; } buf += len; @@ -758,7 +758,7 @@ public: utf8proc_int32_t wc; utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc); if (len < 0) { - atWarning(fmt("invalid UTF-8 character while decoding")); + atWarning(FMT_STRING("invalid UTF-8 character while decoding")); return; } buf += len; @@ -772,7 +772,7 @@ public: if (*buf) { utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc); if (len < 0) { - atWarning(fmt("invalid UTF-8 character while decoding")); + atWarning(FMT_STRING("invalid UTF-8 character while decoding")); return; } buf += len; diff --git a/src/athena/DNAYaml.cpp b/src/athena/DNAYaml.cpp index b7db0be..fd3c4f3 100644 --- a/src/athena/DNAYaml.cpp +++ b/src/athena/DNAYaml.cpp @@ -34,7 +34,7 @@ atInt8 NodeToVal(const YAMLNode* node) { std::unique_ptr ValToNode(atInt8 val) { auto ret = std::make_unique(YAML_SCALAR_NODE); - ret->m_scalarString = fmt::format(fmt("{}"), int(val)); + ret->m_scalarString = fmt::format(FMT_STRING("{}"), int(val)); return ret; } @@ -45,7 +45,7 @@ atUint8 NodeToVal(const YAMLNode* node) { std::unique_ptr ValToNode(atUint8 val) { auto ret = std::make_unique(YAML_SCALAR_NODE); - ret->m_scalarString = fmt::format(fmt("0x{:02X}"), val); + ret->m_scalarString = fmt::format(FMT_STRING("0x{:02X}"), val); return ret; } @@ -56,7 +56,7 @@ atInt16 NodeToVal(const YAMLNode* node) { std::unique_ptr ValToNode(atInt16 val) { auto ret = std::make_unique(YAML_SCALAR_NODE); - ret->m_scalarString = fmt::format(fmt("{}"), int(val)); + ret->m_scalarString = fmt::format(FMT_STRING("{}"), int(val)); return ret; } @@ -67,7 +67,7 @@ atUint16 NodeToVal(const YAMLNode* node) { std::unique_ptr ValToNode(atUint16 val) { auto ret = std::make_unique(YAML_SCALAR_NODE); - ret->m_scalarString = fmt::format(fmt("0x{:04X}"), val); + ret->m_scalarString = fmt::format(FMT_STRING("0x{:04X}"), val); return ret; } @@ -78,7 +78,7 @@ atInt32 NodeToVal(const YAMLNode* node) { std::unique_ptr ValToNode(atInt32 val) { auto ret = std::make_unique(YAML_SCALAR_NODE); - ret->m_scalarString = fmt::format(fmt("{}"), int(val)); + ret->m_scalarString = fmt::format(FMT_STRING("{}"), int(val)); return ret; } @@ -89,7 +89,7 @@ atUint32 NodeToVal(const YAMLNode* node) { std::unique_ptr ValToNode(atUint32 val) { auto ret = std::make_unique(YAML_SCALAR_NODE); - ret->m_scalarString = fmt::format(fmt("0x{:08X}"), val); + ret->m_scalarString = fmt::format(FMT_STRING("0x{:08X}"), val); return ret; } @@ -100,7 +100,7 @@ atInt64 NodeToVal(const YAMLNode* node) { std::unique_ptr ValToNode(atInt64 val) { auto ret = std::make_unique(YAML_SCALAR_NODE); - ret->m_scalarString = fmt::format(fmt("{}"), val); + ret->m_scalarString = fmt::format(FMT_STRING("{}"), val); return ret; } @@ -111,7 +111,7 @@ atUint64 NodeToVal(const YAMLNode* node) { std::unique_ptr ValToNode(atUint64 val) { auto ret = std::make_unique(YAML_SCALAR_NODE); - ret->m_scalarString = fmt::format(fmt("0x{:016X}"), val); + ret->m_scalarString = fmt::format(FMT_STRING("0x{:016X}"), val); return ret; } @@ -122,7 +122,7 @@ float NodeToVal(const YAMLNode* node) { std::unique_ptr ValToNode(float val) { auto ret = std::make_unique(YAML_SCALAR_NODE); - ret->m_scalarString = fmt::format(fmt("{}"), val); + ret->m_scalarString = fmt::format(FMT_STRING("{}"), val); return ret; } @@ -133,7 +133,7 @@ double NodeToVal(const YAMLNode* node) { std::unique_ptr ValToNode(double val) { auto ret = std::make_unique(YAML_SCALAR_NODE); - ret->m_scalarString = fmt::format(fmt("{}"), val); + ret->m_scalarString = fmt::format(FMT_STRING("{}"), val); return ret; } @@ -171,7 +171,7 @@ std::unique_ptr ValToNode(const atVec2f& val) { simd_floats f(val.simd); for (size_t i = 0; i < 2; ++i) { auto comp = std::make_unique(YAML_SCALAR_NODE); - comp->m_scalarString = fmt::format(fmt("{}"), f[i]); + comp->m_scalarString = fmt::format(FMT_STRING("{}"), f[i]); ret->m_seqChildren.push_back(std::move(comp)); } return ret; @@ -188,7 +188,7 @@ std::unique_ptr ValToNode(const atVec3f& val) { simd_floats f(val.simd); for (size_t i = 0; i < 3; ++i) { auto comp = std::make_unique(YAML_SCALAR_NODE); - comp->m_scalarString = fmt::format(fmt("{}"), f[i]); + comp->m_scalarString = fmt::format(FMT_STRING("{}"), f[i]); ret->m_seqChildren.push_back(std::move(comp)); } return ret; @@ -205,7 +205,7 @@ std::unique_ptr ValToNode(const atVec4f& val) { simd_floats f(val.simd); for (size_t i = 0; i < 4; ++i) { auto comp = std::make_unique(YAML_SCALAR_NODE); - comp->m_scalarString = fmt::format(fmt("{}"), f[i]); + comp->m_scalarString = fmt::format(FMT_STRING("{}"), f[i]); ret->m_seqChildren.push_back(std::move(comp)); } return ret; @@ -222,7 +222,7 @@ std::unique_ptr ValToNode(const atVec2d& val) { simd_doubles f(val.simd); for (size_t i = 0; i < 2; ++i) { auto comp = std::make_unique(YAML_SCALAR_NODE); - comp->m_scalarString = fmt::format(fmt("{}"), f[i]); + comp->m_scalarString = fmt::format(FMT_STRING("{}"), f[i]); ret->m_seqChildren.push_back(std::move(comp)); } return ret; @@ -239,7 +239,7 @@ std::unique_ptr ValToNode(const atVec3d& val) { simd_doubles f(val.simd); for (size_t i = 0; i < 3; ++i) { auto comp = std::make_unique(YAML_SCALAR_NODE); - comp->m_scalarString = fmt::format(fmt("{}"), f[i]); + comp->m_scalarString = fmt::format(FMT_STRING("{}"), f[i]); ret->m_seqChildren.push_back(std::move(comp)); } return ret; @@ -256,7 +256,7 @@ std::unique_ptr ValToNode(const atVec4d& val) { simd_doubles f(val.simd); for (size_t i = 0; i < 4; ++i) { auto comp = std::make_unique(YAML_SCALAR_NODE); - comp->m_scalarString = fmt::format(fmt("{}"), f[i]); + comp->m_scalarString = fmt::format(FMT_STRING("{}"), f[i]); ret->m_seqChildren.push_back(std::move(comp)); } return ret; @@ -294,7 +294,7 @@ std::wstring NodeToVal(const YAMLNode* node) { utf8proc_int32_t wc; utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc); if (len < 0) { - atWarning(fmt("invalid UTF-8 character while decoding")); + atWarning(FMT_STRING("invalid UTF-8 character while decoding")); return retval; } buf += len; @@ -310,7 +310,7 @@ std::unique_ptr ValToNode(std::wstring_view val) { utf8proc_uint8_t mb[4]; utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb); if (c < 0) { - atWarning(fmt("invalid UTF-8 character while encoding")); + atWarning(FMT_STRING("invalid UTF-8 character while encoding")); return ret; } ret->m_scalarString.append(reinterpret_cast(mb), c); @@ -325,7 +325,7 @@ std::unique_ptr ValToNode(std::u16string_view val) { utf8proc_uint8_t mb[4]; utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb); if (c < 0) { - atWarning(fmt("invalid UTF-8 character while encoding")); + atWarning(FMT_STRING("invalid UTF-8 character while encoding")); return ret; } ret->m_scalarString.append(reinterpret_cast(mb), c); @@ -340,7 +340,7 @@ std::unique_ptr ValToNode(std::u32string_view val) { utf8proc_uint8_t mb[4]; utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb); if (c < 0) { - atWarning(fmt("invalid UTF-8 character while encoding")); + atWarning(FMT_STRING("invalid UTF-8 character while encoding")); return ret; } ret->m_scalarString.append(reinterpret_cast(mb), c); @@ -371,11 +371,11 @@ static std::string_view ErrorString(yaml_error_type_t errt) { } void HandleYAMLParserError(yaml_parser_t* parser) { - atError(fmt("YAML error: {}: {}"), ErrorString(parser->error), parser->problem ? parser->problem : ""); + atError(FMT_STRING("YAML error: {}: {}"), ErrorString(parser->error), parser->problem ? parser->problem : ""); } void HandleYAMLEmitterError(yaml_emitter_t* emitter) { - atError(fmt("YAML error: {}: {}"), ErrorString(emitter->error), emitter->problem ? emitter->problem : ""); + atError(FMT_STRING("YAML error: {}: {}"), ErrorString(emitter->error), emitter->problem ? emitter->problem : ""); } int YAMLStdStringReader(YAMLStdStringViewReaderState* reader, unsigned char* buffer, size_t size, size_t* size_read) { @@ -649,7 +649,7 @@ std::unique_ptr YAMLDocReader::ParseEvents(athena::io::IStreamReader* switch (event.type) { case YAML_SCALAR_EVENT: { if (nodeStack.empty()) { - atWarning(fmt("YAML parser stack empty; skipping scalar node")); + atWarning(FMT_STRING("YAML parser stack empty; skipping scalar node")); break; } auto newScalar = std::make_unique(YAML_SCALAR_NODE); @@ -784,7 +784,7 @@ YAMLDocReader::RecordRAII YAMLDocReader::enterSubRecord(std::string_view name) { m_seqTrackerStack.push_back(0); return RecordRAII{this}; } else if (name.empty()) { - atError(fmt("Expected YAML sequence")); + atError(FMT_STRING("Expected YAML sequence")); } for (const auto& item : curSub->m_mapChildren) { if (item.first == name) { @@ -819,7 +819,7 @@ YAMLDocReader::VectorRAII YAMLDocReader::enterSubVector(std::string_view name, s if (nextSub->m_type == YAML_SEQUENCE_NODE) { countOut = nextSub->m_seqChildren.size(); } else { - atError(fmt("'{}' is not a vector field"), name); + atError(FMT_STRING("'{}' is not a vector field"), name); countOut = 0; } m_subStack.push_back(nextSub); @@ -857,7 +857,7 @@ RETURNTYPE YAMLDocReader::readVal(std::string_view name) { } } if (!name.empty()) - atWarning(fmt("Unable to find field '{}'; returning 0"), name); + atWarning(FMT_STRING("Unable to find field '{}'; returning 0"), name); return RETURNTYPE(); } diff --git a/src/athena/Dir.cpp b/src/athena/Dir.cpp index 1f038a4..ca966b7 100644 --- a/src/athena/Dir.cpp +++ b/src/athena/Dir.cpp @@ -51,7 +51,7 @@ bool Dir::rm(std::string_view path) { return !(remove((m_path + "/" + path.data( bool Dir::touch() { std::srand(std::time(nullptr)); atUint64 tmp = utility::rand64(); - std::string tmpFile = fmt::format(fmt("{:016X}.tmp"), tmp); + std::string tmpFile = fmt::format(FMT_STRING("{:016X}.tmp"), tmp); bool ret = FileInfo(m_path + "/" + tmpFile).touch(); if (ret) return rm(tmpFile); diff --git a/src/athena/FileReader.cpp b/src/athena/FileReader.cpp index 2573deb..164dd8d 100644 --- a/src/athena/FileReader.cpp +++ b/src/athena/FileReader.cpp @@ -33,7 +33,7 @@ void FileReader::open() { if (!m_fileHandle) { std::string _filename = filename(); if (m_globalErr) - atError(fmt("File not found '{}'"), _filename); + atError(FMT_STRING("File not found '{}'"), _filename); setError(); return; } @@ -45,7 +45,7 @@ void FileReader::open() { void FileReader::close() { if (!m_fileHandle) { if (m_globalErr) - atError(fmt("Cannot close an unopened stream")); + atError(FMT_STRING("Cannot close an unopened stream")); setError(); return; } @@ -74,7 +74,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) { } if (m_offset > length()) { if (m_globalErr) - atError(fmt("Unable to seek in file")); + atError(FMT_STRING("Unable to seek in file")); setError(); return; } @@ -87,7 +87,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) { } } else if (fseeko64(m_fileHandle, pos, int(origin)) != 0) { if (m_globalErr) - atError(fmt("Unable to seek in file")); + atError(FMT_STRING("Unable to seek in file")); setError(); } } @@ -95,7 +95,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) { atUint64 FileReader::position() const { if (!isOpen()) { if (m_globalErr) - atError(fmt("File not open")); + atError(FMT_STRING("File not open")); return 0; } @@ -108,7 +108,7 @@ atUint64 FileReader::position() const { atUint64 FileReader::length() const { if (!isOpen()) { if (m_globalErr) - atError(fmt("File not open")); + atError(FMT_STRING("File not open")); return 0; } @@ -118,7 +118,7 @@ atUint64 FileReader::length() const { atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) { if (!isOpen()) { if (m_globalErr) - atError(fmt("File not open for reading")); + atError(FMT_STRING("File not open for reading")); setError(); return 0; } diff --git a/src/athena/FileReaderWin32.cpp b/src/athena/FileReaderWin32.cpp index fa94235..70f7a70 100644 --- a/src/athena/FileReaderWin32.cpp +++ b/src/athena/FileReaderWin32.cpp @@ -36,7 +36,7 @@ void FileReader::open() { m_fileHandle = 0; std::string _filename = filename(); if (m_globalErr) - atError(fmt("File not found '{}'"), _filename); + atError(FMT_STRING("File not found '{}'"), _filename); setError(); return; } @@ -48,7 +48,7 @@ void FileReader::open() { void FileReader::close() { if (!m_fileHandle) { if (m_globalErr) - atError(fmt("Cannot close an unopened stream")); + atError(FMT_STRING("Cannot close an unopened stream")); setError(); return; } @@ -79,7 +79,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) { if (m_offset > length()) { oldOff = m_offset; if (m_globalErr) - atError(fmt("Unable to seek in file")); + atError(FMT_STRING("Unable to seek in file")); setError(); return; } @@ -98,7 +98,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) { li.QuadPart = pos; if (!SetFilePointerEx(m_fileHandle, li, nullptr, DWORD(origin))) { if (m_globalErr) - atError(fmt("Unable to seek in file")); + atError(FMT_STRING("Unable to seek in file")); setError(); } } @@ -107,7 +107,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) { atUint64 FileReader::position() const { if (!isOpen()) { if (m_globalErr) - atError(fmt("File not open")); + atError(FMT_STRING("File not open")); return 0; } @@ -124,7 +124,7 @@ atUint64 FileReader::position() const { atUint64 FileReader::length() const { if (!isOpen()) { if (m_globalErr) - atError(fmt("File not open")); + atError(FMT_STRING("File not open")); return 0; } @@ -136,7 +136,7 @@ atUint64 FileReader::length() const { atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) { if (!isOpen()) { if (m_globalErr) - atError(fmt("File not open for reading")); + atError(FMT_STRING("File not open for reading")); setError(); return 0; } diff --git a/src/athena/FileWriterNix.cpp b/src/athena/FileWriterNix.cpp index d7f5d0d..824a6c5 100644 --- a/src/athena/FileWriterNix.cpp +++ b/src/athena/FileWriterNix.cpp @@ -49,7 +49,7 @@ void FileWriter::open(bool overwrite) { if (!m_fileHandle) { if (m_globalErr) - atError(fmt("Unable to open file '%s'"), filename().c_str()); + atError(FMT_STRING("Unable to open file '%s'"), filename().c_str()); setError(); return; } @@ -61,7 +61,7 @@ void FileWriter::open(bool overwrite) { void FileWriter::close() { if (!m_fileHandle) { if (m_globalErr) - atError(fmt("Cannot close an unopened stream")); + atError(FMT_STRING("Cannot close an unopened stream")); setError(); return; } @@ -81,14 +81,14 @@ void FileWriter::close() { void FileWriter::seek(atInt64 pos, SeekOrigin origin) { if (!isOpen()) { if (m_globalErr) - atError(fmt("Unable to seek in file, not open")); + atError(FMT_STRING("Unable to seek in file, not open")); setError(); return; } if (fseeko64(m_fileHandle, pos, int(origin)) != 0) { if (m_globalErr) - atError(fmt("Unable to seek in file")); + atError(FMT_STRING("Unable to seek in file")); setError(); } } @@ -100,14 +100,14 @@ atUint64 FileWriter::length() const { return utility::fileSize(m_filename); } void FileWriter::writeUBytes(const atUint8* data, atUint64 len) { if (!isOpen()) { if (m_globalErr) - atError(fmt("File not open for writing")); + atError(FMT_STRING("File not open for writing")); setError(); return; } if (fwrite(data, 1, len, m_fileHandle) != len) { if (m_globalErr) - atError(fmt("Unable to write to stream")); + atError(FMT_STRING("Unable to write to stream")); setError(); } } diff --git a/src/athena/FileWriterWin32.cpp b/src/athena/FileWriterWin32.cpp index 93fddd3..7e1c912 100644 --- a/src/athena/FileWriterWin32.cpp +++ b/src/athena/FileWriterWin32.cpp @@ -45,7 +45,7 @@ void FileWriter::open(bool overwrite) { if (m_fileHandle == INVALID_HANDLE_VALUE) { m_fileHandle = 0; if (m_globalErr) - atError(fmt("Unable to open file '{}'"), filename()); + atError(FMT_STRING("Unable to open file '{}'"), filename()); setError(); return; } @@ -57,7 +57,7 @@ void FileWriter::open(bool overwrite) { void FileWriter::close() { if (!m_fileHandle) { if (m_globalErr) - atError(fmt("Cannot close an unopened stream")); + atError(FMT_STRING("Cannot close an unopened stream")); setError(); return; } @@ -73,7 +73,7 @@ void FileWriter::close() { void FileWriter::seek(atInt64 pos, SeekOrigin origin) { if (!isOpen()) { if (m_globalErr) - atError(fmt("Unable to seek in file, not open")); + atError(FMT_STRING("Unable to seek in file, not open")); setError(); return; } @@ -82,7 +82,7 @@ void FileWriter::seek(atInt64 pos, SeekOrigin origin) { li.QuadPart = pos; if (!SetFilePointerEx(m_fileHandle, li, nullptr, DWORD(origin))) { if (m_globalErr) - atError(fmt("Unable to seek in file")); + atError(FMT_STRING("Unable to seek in file")); setError(); } } @@ -99,7 +99,7 @@ atUint64 FileWriter::length() const { return utility::fileSize(m_filename); } void FileWriter::writeUBytes(const atUint8* data, atUint64 len) { if (!isOpen()) { if (m_globalErr) { - atError(fmt("File not open for writing")); + atError(FMT_STRING("File not open for writing")); } setError(); return; @@ -112,7 +112,7 @@ void FileWriter::writeUBytes(const atUint8* data, atUint64 len) { if (WriteFile(m_fileHandle, data, toWrite, &written, nullptr) == FALSE) { if (m_globalErr) { - atError(fmt("Unable to write to file")); + atError(FMT_STRING("Unable to write to file")); } setError(); return; diff --git a/src/athena/Global.cpp b/src/athena/Global.cpp index ff8c97c..2624c5c 100644 --- a/src/athena/Global.cpp +++ b/src/athena/Global.cpp @@ -6,7 +6,6 @@ #define FMT_STRING_ALIAS 1 #define FMT_ENFORCE_COMPILE_STRING 1 -#define FMT_USE_GRISU 0 #include std::ostream& operator<<(std::ostream& os, const athena::SeekOrigin& origin) { diff --git a/src/athena/MemoryReader.cpp b/src/athena/MemoryReader.cpp index 8c5fd78..f92d54f 100644 --- a/src/athena/MemoryReader.cpp +++ b/src/athena/MemoryReader.cpp @@ -13,7 +13,7 @@ MemoryReader::MemoryReader(const void* data, atUint64 length, bool takeOwnership : m_data(data), m_length(length), m_position(0), m_owns(takeOwnership), m_globalErr(globalErr) { if (!data) { if (m_globalErr) - atError(fmt("data cannot be NULL")); + atError(FMT_STRING("data cannot be NULL")); setError(); return; } @@ -27,7 +27,7 @@ MemoryReader::~MemoryReader() { MemoryCopyReader::MemoryCopyReader(const void* data, atUint64 length) : MemoryReader(data, length, false) { if (!data) { if (m_globalErr) - atError(fmt("data cannot be NULL")); + atError(FMT_STRING("data cannot be NULL")); setError(); return; } @@ -42,7 +42,7 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin) { case SeekOrigin::Begin: if ((position < 0 || atInt64(position) > atInt64(m_length))) { if (m_globalErr) - atFatal(fmt("Position {:08X} outside stream bounds "), position); + atFatal(FMT_STRING("Position {:08X} outside stream bounds "), position); m_position = m_length; setError(); return; @@ -54,7 +54,7 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin) { case SeekOrigin::Current: if (((atInt64(m_position) + position) < 0 || (m_position + atUint64(position)) > m_length)) { if (m_globalErr) - atFatal(fmt("Position {:08X} outside stream bounds "), position); + atFatal(FMT_STRING("Position {:08X} outside stream bounds "), position); m_position = (position < 0 ? 0 : m_length); setError(); return; @@ -66,7 +66,7 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin) { case SeekOrigin::End: if ((((atInt64)m_length - position < 0) || (m_length - position) > m_length)) { if (m_globalErr) - atFatal(fmt("Position {:08X} outside stream bounds "), position); + atFatal(FMT_STRING("Position {:08X} outside stream bounds "), position); m_position = m_length; setError(); return; @@ -104,7 +104,7 @@ atUint8* MemoryReader::data() const { atUint64 MemoryReader::readUBytesToBuf(void* buf, atUint64 length) { if (m_position >= m_length) { if (m_globalErr) - atFatal(fmt("Position {:08X} outside stream bounds "), m_position); + atFatal(FMT_STRING("Position {:08X} outside stream bounds "), m_position); m_position = m_length; setError(); return 0; @@ -123,7 +123,7 @@ void MemoryCopyReader::loadData() { if (!in) { if (m_globalErr) - atError(fmt("Unable to open file '%s'"), m_filepath); + atError(FMT_STRING("Unable to open file '%s'"), m_filepath); setError(); return; } @@ -145,7 +145,7 @@ void MemoryCopyReader::loadData() { if (ret < 0) { if (m_globalErr) - atError(fmt("Error reading data from disk")); + atError(FMT_STRING("Error reading data from disk")); setError(); return; } else if (ret == 0) diff --git a/src/athena/MemoryWriter.cpp b/src/athena/MemoryWriter.cpp index 607a964..a0be0e2 100644 --- a/src/athena/MemoryWriter.cpp +++ b/src/athena/MemoryWriter.cpp @@ -12,7 +12,7 @@ namespace athena::io { MemoryWriter::MemoryWriter(atUint8* data, atUint64 length, bool takeOwnership) : m_data(data), m_length(length), m_bufferOwned(takeOwnership) { if (!data) { - atError(fmt("data cannot be NULL")); + atError(FMT_STRING("data cannot be NULL")); setError(); return; } @@ -32,7 +32,7 @@ MemoryCopyWriter::MemoryCopyWriter(atUint8* data, atUint64 length) { m_bufferOwned = false; if (length == 0) { - atError(fmt("length cannot be 0")); + atError(FMT_STRING("length cannot be 0")); setError(); return; } @@ -51,7 +51,7 @@ MemoryCopyWriter::MemoryCopyWriter(std::string_view filename) { m_bufferOwned = false; if (!m_data) { - atError(fmt("Could not allocate memory!")); + atError(FMT_STRING("Could not allocate memory!")); setError(); return; } @@ -61,13 +61,13 @@ void MemoryWriter::seek(atInt64 position, SeekOrigin origin) { switch (origin) { case SeekOrigin::Begin: if (position < 0) { - atError(fmt("Position outside stream bounds")); + atError(FMT_STRING("Position outside stream bounds")); setError(); return; } if ((atUint64)position > m_length) { - atError(fmt("data exceeds available buffer space")); + atError(FMT_STRING("data exceeds available buffer space")); setError(); return; } @@ -77,13 +77,13 @@ void MemoryWriter::seek(atInt64 position, SeekOrigin origin) { case SeekOrigin::Current: if ((((atInt64)m_position + position) < 0)) { - atError(fmt("Position outside stream bounds")); + atError(FMT_STRING("Position outside stream bounds")); setError(); return; } if (m_position + position > m_length) { - atError(fmt("data exceeds available buffer space")); + atError(FMT_STRING("data exceeds available buffer space")); setError(); return; } @@ -93,13 +93,13 @@ void MemoryWriter::seek(atInt64 position, SeekOrigin origin) { case SeekOrigin::End: if (((atInt64)m_length - position) < 0) { - atError(fmt("Position outside stream bounds")); + atError(FMT_STRING("Position outside stream bounds")); setError(); return; } if ((atUint64)position > m_length) { - atError(fmt("data exceeds available buffer space")); + atError(FMT_STRING("data exceeds available buffer space")); setError(); return; } @@ -113,7 +113,7 @@ void MemoryCopyWriter::seek(atInt64 position, SeekOrigin origin) { switch (origin) { case SeekOrigin::Begin: if (position < 0) { - atError(fmt("Position outside stream bounds")); + atError(FMT_STRING("Position outside stream bounds")); setError(); return; } @@ -126,7 +126,7 @@ void MemoryCopyWriter::seek(atInt64 position, SeekOrigin origin) { case SeekOrigin::Current: if ((((atInt64)m_position + position) < 0)) { - atError(fmt("Position outside stream bounds")); + atError(FMT_STRING("Position outside stream bounds")); setError(); return; } @@ -139,7 +139,7 @@ void MemoryCopyWriter::seek(atInt64 position, SeekOrigin origin) { case SeekOrigin::End: if (((atInt64)m_length - position) < 0) { - atError(fmt("Position outside stream bounds")); + atError(FMT_STRING("Position outside stream bounds")); setError(); return; } @@ -180,7 +180,7 @@ atUint8* MemoryWriter::data() const { void MemoryWriter::save(std::string_view filename) { if (filename.empty() && m_filepath.empty()) { - atError(fmt("No file specified, cannot save.")); + atError(FMT_STRING("No file specified, cannot save.")); setError(); return; } @@ -191,7 +191,7 @@ void MemoryWriter::save(std::string_view filename) { std::unique_ptr out{std::fopen(m_filepath.c_str(), "wb"), std::fclose}; if (!out) { - atError(fmt("Unable to open file '{}'"), m_filepath); + atError(FMT_STRING("Unable to open file '{}'"), m_filepath); setError(); return; } @@ -207,7 +207,7 @@ void MemoryWriter::save(std::string_view filename) { const atInt64 ret = std::fwrite(m_data + done, 1, blocksize, out.get()); if (ret < 0) { - atError(fmt("Error writing data to disk")); + atError(FMT_STRING("Error writing data to disk")); setError(); return; } @@ -222,13 +222,13 @@ void MemoryWriter::save(std::string_view filename) { void MemoryWriter::writeUBytes(const atUint8* data, atUint64 length) { if (!data) { - atError(fmt("data cannnot be NULL")); + atError(FMT_STRING("data cannnot be NULL")); setError(); return; } if (m_position + length > m_length) { - atError(fmt("data length exceeds available buffer space")); + atError(FMT_STRING("data length exceeds available buffer space")); setError(); return; } @@ -240,7 +240,7 @@ void MemoryWriter::writeUBytes(const atUint8* data, atUint64 length) { void MemoryCopyWriter::writeUBytes(const atUint8* data, atUint64 length) { if (!data) { - atError(fmt("data cannnot be NULL")); + atError(FMT_STRING("data cannnot be NULL")); setError(); return; } @@ -255,7 +255,7 @@ void MemoryCopyWriter::writeUBytes(const atUint8* data, atUint64 length) { void MemoryCopyWriter::resize(atUint64 newSize) { if (newSize < m_length) { - atError(fmt("New size cannot be less to the old size.")); + atError(FMT_STRING("New size cannot be less to the old size.")); return; } diff --git a/src/athena/Socket.cpp b/src/athena/Socket.cpp index 8057d2a..bf74e50 100644 --- a/src/athena/Socket.cpp +++ b/src/athena/Socket.cpp @@ -84,7 +84,7 @@ bool Socket::openSocket() { m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (m_socket == -1) { - atError(fmt("Can't allocate socket")); + atError(FMT_STRING("Can't allocate socket")); return false; } @@ -138,13 +138,13 @@ bool Socket::openAndListen(const IPAddress& address, uint32_t port) { sockaddr_in addr = createAddress(address.toInteger(), port); if (bind(m_socket, reinterpret_cast(&addr), sizeof(addr)) == -1) { /* Not likely to happen, but... */ - atError(fmt("Failed to bind listener socket to port {}"), port); + atError(FMT_STRING("Failed to bind listener socket to port {}"), port); return false; } if (::listen(m_socket, 0) == -1) { /* Oops, socket is deaf */ - atError(fmt("Failed to listen to port {}"), port); + atError(FMT_STRING("Failed to listen to port {}"), port); return false; } @@ -164,11 +164,11 @@ Socket::EResult Socket::accept(Socket& remoteSocketOut, sockaddr_in& fromAddress #ifndef _WIN32 EResult res = (errno == EAGAIN) ? EResult::Busy : EResult::Error; if (res == EResult::Error) - atError(fmt("Failed to accept incoming connection: {}"), strerror(errno)); + atError(FMT_STRING("Failed to accept incoming connection: {}"), strerror(errno)); #else EResult res = LastWSAError(); if (res == EResult::Error) - atError(fmt("Failed to accept incoming connection")); + atError(FMT_STRING("Failed to accept incoming connection")); #endif return res; } diff --git a/src/athena/Utility.cpp b/src/athena/Utility.cpp index 39f66dd..ef5b278 100644 --- a/src/athena/Utility.cpp +++ b/src/athena/Utility.cpp @@ -167,7 +167,7 @@ std::string wideToUtf8(std::wstring_view src) { utf8proc_uint8_t mb[4]; utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb); if (c < 0) { - atWarning(fmt("invalid UTF-8 character while encoding")); + atWarning(FMT_STRING("invalid UTF-8 character while encoding")); return retval; } retval.append(reinterpret_cast(mb), c); @@ -183,7 +183,7 @@ std::wstring utf8ToWide(std::string_view src) { utf8proc_int32_t wc; utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc); if (len < 0) { - atWarning(fmt("invalid UTF-8 character while decoding")); + atWarning(FMT_STRING("invalid UTF-8 character while decoding")); return retval; } buf += len; diff --git a/src/athena/VectorWriter.cpp b/src/athena/VectorWriter.cpp index a9db96c..f117416 100644 --- a/src/athena/VectorWriter.cpp +++ b/src/athena/VectorWriter.cpp @@ -10,7 +10,7 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) { switch (origin) { case SeekOrigin::Begin: if (position < 0) { - atError(fmt("Position outside stream bounds")); + atError(FMT_STRING("Position outside stream bounds")); setError(); return; } @@ -23,7 +23,7 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) { case SeekOrigin::Current: if ((((atInt64)m_position + position) < 0)) { - atError(fmt("Position outside stream bounds")); + atError(FMT_STRING("Position outside stream bounds")); setError(); return; } @@ -36,13 +36,13 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) { case SeekOrigin::End: if (((atInt64)m_data.size() - position) < 0) { - atError(fmt("Position outside stream bounds")); + atError(FMT_STRING("Position outside stream bounds")); setError(); return; } if ((atUint64)position > m_data.size()) { - atError(fmt("data exceeds vector size")); + atError(FMT_STRING("data exceeds vector size")); setError(); return; } @@ -54,7 +54,7 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) { void VectorWriter::writeUBytes(const atUint8* data, atUint64 length) { if (!data) { - atError(fmt("data cannnot be NULL")); + atError(FMT_STRING("data cannnot be NULL")); setError(); return; }