Update fmtlib

This commit is contained in:
Jack Andersen 2020-04-11 12:46:42 -10:00
parent ebda6add23
commit 30fe237210
16 changed files with 101 additions and 103 deletions

View File

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

2
extern/fmt vendored

@ -1 +1 @@
Subproject commit 25ff2efc0aeab3ce886fb6be11a1878f3497ec4c
Subproject commit 9bdd1596cef1b57b9556f8bef32dc4a32322ef3e

View File

@ -5,7 +5,6 @@
#define FMT_STRING_ALIAS 1
#define FMT_ENFORCE_COMPILE_STRING 1
#define FMT_USE_GRISU 0
#include <fmt/format.h>
#ifdef _MSC_VER

View File

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

View File

@ -34,7 +34,7 @@ atInt8 NodeToVal(const YAMLNode* node) {
std::unique_ptr<YAMLNode> ValToNode(atInt8 val) {
auto ret = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(atUint8 val) {
auto ret = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(atInt16 val) {
auto ret = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(atUint16 val) {
auto ret = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(atInt32 val) {
auto ret = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(atUint32 val) {
auto ret = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(atInt64 val) {
auto ret = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(atUint64 val) {
auto ret = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(float val) {
auto ret = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(double val) {
auto ret = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(const atVec2f& val) {
simd_floats f(val.simd);
for (size_t i = 0; i < 2; ++i) {
auto comp = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(const atVec3f& val) {
simd_floats f(val.simd);
for (size_t i = 0; i < 3; ++i) {
auto comp = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(const atVec4f& val) {
simd_floats f(val.simd);
for (size_t i = 0; i < 4; ++i) {
auto comp = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(const atVec2d& val) {
simd_doubles f(val.simd);
for (size_t i = 0; i < 2; ++i) {
auto comp = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(const atVec3d& val) {
simd_doubles f(val.simd);
for (size_t i = 0; i < 3; ++i) {
auto comp = std::make_unique<YAMLNode>(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<YAMLNode> ValToNode(const atVec4d& val) {
simd_doubles f(val.simd);
for (size_t i = 0; i < 4; ++i) {
auto comp = std::make_unique<YAMLNode>(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<YAMLNode> 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<char*>(mb), c);
@ -325,7 +325,7 @@ std::unique_ptr<YAMLNode> 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<char*>(mb), c);
@ -340,7 +340,7 @@ std::unique_ptr<YAMLNode> 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<char*>(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<YAMLNode> 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<YAMLNode>(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();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,6 @@
#define FMT_STRING_ALIAS 1
#define FMT_ENFORCE_COMPILE_STRING 1
#define FMT_USE_GRISU 0
#include <fmt/format.h>
std::ostream& operator<<(std::ostream& os, const athena::SeekOrigin& origin) {

View File

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

View File

@ -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<FILE, decltype(&std::fclose)> 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;
}

View File

@ -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<sockaddr*>(&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;
}

View File

@ -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<char*>(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;

View File

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