mirror of https://github.com/libAthena/athena.git
Update fmtlib
This commit is contained in:
parent
ebda6add23
commit
30fe237210
|
@ -18,9 +18,9 @@ int main(int argc, const char** argv) {
|
||||||
|
|
||||||
const bool pass = !w.hasError() && w.position() - pos == binSize && binSize == EXPECTED_BYTES;
|
const bool pass = !w.hasError() && w.position() - pos == binSize && binSize == EXPECTED_BYTES;
|
||||||
if (pass) {
|
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 {
|
} 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);
|
EXPECTED_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 25ff2efc0aeab3ce886fb6be11a1878f3497ec4c
|
Subproject commit 9bdd1596cef1b57b9556f8bef32dc4a32322ef3e
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
#define FMT_STRING_ALIAS 1
|
#define FMT_STRING_ALIAS 1
|
||||||
#define FMT_ENFORCE_COMPILE_STRING 1
|
#define FMT_ENFORCE_COMPILE_STRING 1
|
||||||
#define FMT_USE_GRISU 0
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
|
@ -661,7 +661,7 @@ public:
|
||||||
utf8proc_int32_t wc;
|
utf8proc_int32_t wc;
|
||||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
atWarning(fmt("invalid UTF-8 character while decoding"));
|
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf += len;
|
buf += len;
|
||||||
|
@ -675,7 +675,7 @@ public:
|
||||||
if (*buf) {
|
if (*buf) {
|
||||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
atWarning(fmt("invalid UTF-8 character while decoding"));
|
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf += len;
|
buf += len;
|
||||||
|
@ -709,7 +709,7 @@ public:
|
||||||
utf8proc_int32_t wc;
|
utf8proc_int32_t wc;
|
||||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
atWarning(fmt("invalid UTF-8 character while decoding"));
|
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf += len;
|
buf += len;
|
||||||
|
@ -723,7 +723,7 @@ public:
|
||||||
if (*buf) {
|
if (*buf) {
|
||||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
atWarning(fmt("invalid UTF-8 character while decoding"));
|
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf += len;
|
buf += len;
|
||||||
|
@ -758,7 +758,7 @@ public:
|
||||||
utf8proc_int32_t wc;
|
utf8proc_int32_t wc;
|
||||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
atWarning(fmt("invalid UTF-8 character while decoding"));
|
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf += len;
|
buf += len;
|
||||||
|
@ -772,7 +772,7 @@ public:
|
||||||
if (*buf) {
|
if (*buf) {
|
||||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
atWarning(fmt("invalid UTF-8 character while decoding"));
|
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
buf += len;
|
buf += len;
|
||||||
|
|
|
@ -34,7 +34,7 @@ atInt8 NodeToVal(const YAMLNode* node) {
|
||||||
|
|
||||||
std::unique_ptr<YAMLNode> ValToNode(atInt8 val) {
|
std::unique_ptr<YAMLNode> ValToNode(atInt8 val) {
|
||||||
auto ret = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ atUint8 NodeToVal(const YAMLNode* node) {
|
||||||
|
|
||||||
std::unique_ptr<YAMLNode> ValToNode(atUint8 val) {
|
std::unique_ptr<YAMLNode> ValToNode(atUint8 val) {
|
||||||
auto ret = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ atInt16 NodeToVal(const YAMLNode* node) {
|
||||||
|
|
||||||
std::unique_ptr<YAMLNode> ValToNode(atInt16 val) {
|
std::unique_ptr<YAMLNode> ValToNode(atInt16 val) {
|
||||||
auto ret = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ atUint16 NodeToVal(const YAMLNode* node) {
|
||||||
|
|
||||||
std::unique_ptr<YAMLNode> ValToNode(atUint16 val) {
|
std::unique_ptr<YAMLNode> ValToNode(atUint16 val) {
|
||||||
auto ret = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ atInt32 NodeToVal(const YAMLNode* node) {
|
||||||
|
|
||||||
std::unique_ptr<YAMLNode> ValToNode(atInt32 val) {
|
std::unique_ptr<YAMLNode> ValToNode(atInt32 val) {
|
||||||
auto ret = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ atUint32 NodeToVal(const YAMLNode* node) {
|
||||||
|
|
||||||
std::unique_ptr<YAMLNode> ValToNode(atUint32 val) {
|
std::unique_ptr<YAMLNode> ValToNode(atUint32 val) {
|
||||||
auto ret = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ atInt64 NodeToVal(const YAMLNode* node) {
|
||||||
|
|
||||||
std::unique_ptr<YAMLNode> ValToNode(atInt64 val) {
|
std::unique_ptr<YAMLNode> ValToNode(atInt64 val) {
|
||||||
auto ret = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ atUint64 NodeToVal(const YAMLNode* node) {
|
||||||
|
|
||||||
std::unique_ptr<YAMLNode> ValToNode(atUint64 val) {
|
std::unique_ptr<YAMLNode> ValToNode(atUint64 val) {
|
||||||
auto ret = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ float NodeToVal(const YAMLNode* node) {
|
||||||
|
|
||||||
std::unique_ptr<YAMLNode> ValToNode(float val) {
|
std::unique_ptr<YAMLNode> ValToNode(float val) {
|
||||||
auto ret = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ double NodeToVal(const YAMLNode* node) {
|
||||||
|
|
||||||
std::unique_ptr<YAMLNode> ValToNode(double val) {
|
std::unique_ptr<YAMLNode> ValToNode(double val) {
|
||||||
auto ret = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ std::unique_ptr<YAMLNode> ValToNode(const atVec2f& val) {
|
||||||
simd_floats f(val.simd);
|
simd_floats f(val.simd);
|
||||||
for (size_t i = 0; i < 2; ++i) {
|
for (size_t i = 0; i < 2; ++i) {
|
||||||
auto comp = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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));
|
ret->m_seqChildren.push_back(std::move(comp));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -188,7 +188,7 @@ std::unique_ptr<YAMLNode> ValToNode(const atVec3f& val) {
|
||||||
simd_floats f(val.simd);
|
simd_floats f(val.simd);
|
||||||
for (size_t i = 0; i < 3; ++i) {
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
auto comp = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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));
|
ret->m_seqChildren.push_back(std::move(comp));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -205,7 +205,7 @@ std::unique_ptr<YAMLNode> ValToNode(const atVec4f& val) {
|
||||||
simd_floats f(val.simd);
|
simd_floats f(val.simd);
|
||||||
for (size_t i = 0; i < 4; ++i) {
|
for (size_t i = 0; i < 4; ++i) {
|
||||||
auto comp = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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));
|
ret->m_seqChildren.push_back(std::move(comp));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -222,7 +222,7 @@ std::unique_ptr<YAMLNode> ValToNode(const atVec2d& val) {
|
||||||
simd_doubles f(val.simd);
|
simd_doubles f(val.simd);
|
||||||
for (size_t i = 0; i < 2; ++i) {
|
for (size_t i = 0; i < 2; ++i) {
|
||||||
auto comp = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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));
|
ret->m_seqChildren.push_back(std::move(comp));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -239,7 +239,7 @@ std::unique_ptr<YAMLNode> ValToNode(const atVec3d& val) {
|
||||||
simd_doubles f(val.simd);
|
simd_doubles f(val.simd);
|
||||||
for (size_t i = 0; i < 3; ++i) {
|
for (size_t i = 0; i < 3; ++i) {
|
||||||
auto comp = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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));
|
ret->m_seqChildren.push_back(std::move(comp));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -256,7 +256,7 @@ std::unique_ptr<YAMLNode> ValToNode(const atVec4d& val) {
|
||||||
simd_doubles f(val.simd);
|
simd_doubles f(val.simd);
|
||||||
for (size_t i = 0; i < 4; ++i) {
|
for (size_t i = 0; i < 4; ++i) {
|
||||||
auto comp = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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));
|
ret->m_seqChildren.push_back(std::move(comp));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -294,7 +294,7 @@ std::wstring NodeToVal(const YAMLNode* node) {
|
||||||
utf8proc_int32_t wc;
|
utf8proc_int32_t wc;
|
||||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
atWarning(fmt("invalid UTF-8 character while decoding"));
|
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
buf += len;
|
buf += len;
|
||||||
|
@ -310,7 +310,7 @@ std::unique_ptr<YAMLNode> ValToNode(std::wstring_view val) {
|
||||||
utf8proc_uint8_t mb[4];
|
utf8proc_uint8_t mb[4];
|
||||||
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
||||||
if (c < 0) {
|
if (c < 0) {
|
||||||
atWarning(fmt("invalid UTF-8 character while encoding"));
|
atWarning(FMT_STRING("invalid UTF-8 character while encoding"));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret->m_scalarString.append(reinterpret_cast<char*>(mb), c);
|
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_uint8_t mb[4];
|
||||||
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
||||||
if (c < 0) {
|
if (c < 0) {
|
||||||
atWarning(fmt("invalid UTF-8 character while encoding"));
|
atWarning(FMT_STRING("invalid UTF-8 character while encoding"));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret->m_scalarString.append(reinterpret_cast<char*>(mb), c);
|
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_uint8_t mb[4];
|
||||||
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
||||||
if (c < 0) {
|
if (c < 0) {
|
||||||
atWarning(fmt("invalid UTF-8 character while encoding"));
|
atWarning(FMT_STRING("invalid UTF-8 character while encoding"));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret->m_scalarString.append(reinterpret_cast<char*>(mb), c);
|
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) {
|
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) {
|
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) {
|
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) {
|
switch (event.type) {
|
||||||
case YAML_SCALAR_EVENT: {
|
case YAML_SCALAR_EVENT: {
|
||||||
if (nodeStack.empty()) {
|
if (nodeStack.empty()) {
|
||||||
atWarning(fmt("YAML parser stack empty; skipping scalar node"));
|
atWarning(FMT_STRING("YAML parser stack empty; skipping scalar node"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
auto newScalar = std::make_unique<YAMLNode>(YAML_SCALAR_NODE);
|
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);
|
m_seqTrackerStack.push_back(0);
|
||||||
return RecordRAII{this};
|
return RecordRAII{this};
|
||||||
} else if (name.empty()) {
|
} else if (name.empty()) {
|
||||||
atError(fmt("Expected YAML sequence"));
|
atError(FMT_STRING("Expected YAML sequence"));
|
||||||
}
|
}
|
||||||
for (const auto& item : curSub->m_mapChildren) {
|
for (const auto& item : curSub->m_mapChildren) {
|
||||||
if (item.first == name) {
|
if (item.first == name) {
|
||||||
|
@ -819,7 +819,7 @@ YAMLDocReader::VectorRAII YAMLDocReader::enterSubVector(std::string_view name, s
|
||||||
if (nextSub->m_type == YAML_SEQUENCE_NODE) {
|
if (nextSub->m_type == YAML_SEQUENCE_NODE) {
|
||||||
countOut = nextSub->m_seqChildren.size();
|
countOut = nextSub->m_seqChildren.size();
|
||||||
} else {
|
} else {
|
||||||
atError(fmt("'{}' is not a vector field"), name);
|
atError(FMT_STRING("'{}' is not a vector field"), name);
|
||||||
countOut = 0;
|
countOut = 0;
|
||||||
}
|
}
|
||||||
m_subStack.push_back(nextSub);
|
m_subStack.push_back(nextSub);
|
||||||
|
@ -857,7 +857,7 @@ RETURNTYPE YAMLDocReader::readVal(std::string_view name) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!name.empty())
|
if (!name.empty())
|
||||||
atWarning(fmt("Unable to find field '{}'; returning 0"), name);
|
atWarning(FMT_STRING("Unable to find field '{}'; returning 0"), name);
|
||||||
return RETURNTYPE();
|
return RETURNTYPE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ bool Dir::rm(std::string_view path) { return !(remove((m_path + "/" + path.data(
|
||||||
bool Dir::touch() {
|
bool Dir::touch() {
|
||||||
std::srand(std::time(nullptr));
|
std::srand(std::time(nullptr));
|
||||||
atUint64 tmp = utility::rand64();
|
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();
|
bool ret = FileInfo(m_path + "/" + tmpFile).touch();
|
||||||
if (ret)
|
if (ret)
|
||||||
return rm(tmpFile);
|
return rm(tmpFile);
|
||||||
|
|
|
@ -33,7 +33,7 @@ void FileReader::open() {
|
||||||
if (!m_fileHandle) {
|
if (!m_fileHandle) {
|
||||||
std::string _filename = filename();
|
std::string _filename = filename();
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("File not found '{}'"), _filename);
|
atError(FMT_STRING("File not found '{}'"), _filename);
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ void FileReader::open() {
|
||||||
void FileReader::close() {
|
void FileReader::close() {
|
||||||
if (!m_fileHandle) {
|
if (!m_fileHandle) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Cannot close an unopened stream"));
|
atError(FMT_STRING("Cannot close an unopened stream"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) {
|
||||||
}
|
}
|
||||||
if (m_offset > length()) {
|
if (m_offset > length()) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Unable to seek in file"));
|
atError(FMT_STRING("Unable to seek in file"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) {
|
||||||
}
|
}
|
||||||
} else if (fseeko64(m_fileHandle, pos, int(origin)) != 0) {
|
} else if (fseeko64(m_fileHandle, pos, int(origin)) != 0) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Unable to seek in file"));
|
atError(FMT_STRING("Unable to seek in file"));
|
||||||
setError();
|
setError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) {
|
||||||
atUint64 FileReader::position() const {
|
atUint64 FileReader::position() const {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("File not open"));
|
atError(FMT_STRING("File not open"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ atUint64 FileReader::position() const {
|
||||||
atUint64 FileReader::length() const {
|
atUint64 FileReader::length() const {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("File not open"));
|
atError(FMT_STRING("File not open"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ atUint64 FileReader::length() const {
|
||||||
atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) {
|
atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("File not open for reading"));
|
atError(FMT_STRING("File not open for reading"));
|
||||||
setError();
|
setError();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ void FileReader::open() {
|
||||||
m_fileHandle = 0;
|
m_fileHandle = 0;
|
||||||
std::string _filename = filename();
|
std::string _filename = filename();
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("File not found '{}'"), _filename);
|
atError(FMT_STRING("File not found '{}'"), _filename);
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ void FileReader::open() {
|
||||||
void FileReader::close() {
|
void FileReader::close() {
|
||||||
if (!m_fileHandle) {
|
if (!m_fileHandle) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Cannot close an unopened stream"));
|
atError(FMT_STRING("Cannot close an unopened stream"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) {
|
||||||
if (m_offset > length()) {
|
if (m_offset > length()) {
|
||||||
oldOff = m_offset;
|
oldOff = m_offset;
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Unable to seek in file"));
|
atError(FMT_STRING("Unable to seek in file"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) {
|
||||||
li.QuadPart = pos;
|
li.QuadPart = pos;
|
||||||
if (!SetFilePointerEx(m_fileHandle, li, nullptr, DWORD(origin))) {
|
if (!SetFilePointerEx(m_fileHandle, li, nullptr, DWORD(origin))) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Unable to seek in file"));
|
atError(FMT_STRING("Unable to seek in file"));
|
||||||
setError();
|
setError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ void FileReader::seek(atInt64 pos, SeekOrigin origin) {
|
||||||
atUint64 FileReader::position() const {
|
atUint64 FileReader::position() const {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("File not open"));
|
atError(FMT_STRING("File not open"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ atUint64 FileReader::position() const {
|
||||||
atUint64 FileReader::length() const {
|
atUint64 FileReader::length() const {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("File not open"));
|
atError(FMT_STRING("File not open"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ atUint64 FileReader::length() const {
|
||||||
atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) {
|
atUint64 FileReader::readUBytesToBuf(void* buf, atUint64 len) {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("File not open for reading"));
|
atError(FMT_STRING("File not open for reading"));
|
||||||
setError();
|
setError();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ void FileWriter::open(bool overwrite) {
|
||||||
|
|
||||||
if (!m_fileHandle) {
|
if (!m_fileHandle) {
|
||||||
if (m_globalErr)
|
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();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ void FileWriter::open(bool overwrite) {
|
||||||
void FileWriter::close() {
|
void FileWriter::close() {
|
||||||
if (!m_fileHandle) {
|
if (!m_fileHandle) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Cannot close an unopened stream"));
|
atError(FMT_STRING("Cannot close an unopened stream"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -81,14 +81,14 @@ void FileWriter::close() {
|
||||||
void FileWriter::seek(atInt64 pos, SeekOrigin origin) {
|
void FileWriter::seek(atInt64 pos, SeekOrigin origin) {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Unable to seek in file, not open"));
|
atError(FMT_STRING("Unable to seek in file, not open"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fseeko64(m_fileHandle, pos, int(origin)) != 0) {
|
if (fseeko64(m_fileHandle, pos, int(origin)) != 0) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Unable to seek in file"));
|
atError(FMT_STRING("Unable to seek in file"));
|
||||||
setError();
|
setError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,14 +100,14 @@ atUint64 FileWriter::length() const { return utility::fileSize(m_filename); }
|
||||||
void FileWriter::writeUBytes(const atUint8* data, atUint64 len) {
|
void FileWriter::writeUBytes(const atUint8* data, atUint64 len) {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("File not open for writing"));
|
atError(FMT_STRING("File not open for writing"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fwrite(data, 1, len, m_fileHandle) != len) {
|
if (fwrite(data, 1, len, m_fileHandle) != len) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Unable to write to stream"));
|
atError(FMT_STRING("Unable to write to stream"));
|
||||||
setError();
|
setError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ void FileWriter::open(bool overwrite) {
|
||||||
if (m_fileHandle == INVALID_HANDLE_VALUE) {
|
if (m_fileHandle == INVALID_HANDLE_VALUE) {
|
||||||
m_fileHandle = 0;
|
m_fileHandle = 0;
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Unable to open file '{}'"), filename());
|
atError(FMT_STRING("Unable to open file '{}'"), filename());
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ void FileWriter::open(bool overwrite) {
|
||||||
void FileWriter::close() {
|
void FileWriter::close() {
|
||||||
if (!m_fileHandle) {
|
if (!m_fileHandle) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Cannot close an unopened stream"));
|
atError(FMT_STRING("Cannot close an unopened stream"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ void FileWriter::close() {
|
||||||
void FileWriter::seek(atInt64 pos, SeekOrigin origin) {
|
void FileWriter::seek(atInt64 pos, SeekOrigin origin) {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Unable to seek in file, not open"));
|
atError(FMT_STRING("Unable to seek in file, not open"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ void FileWriter::seek(atInt64 pos, SeekOrigin origin) {
|
||||||
li.QuadPart = pos;
|
li.QuadPart = pos;
|
||||||
if (!SetFilePointerEx(m_fileHandle, li, nullptr, DWORD(origin))) {
|
if (!SetFilePointerEx(m_fileHandle, li, nullptr, DWORD(origin))) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Unable to seek in file"));
|
atError(FMT_STRING("Unable to seek in file"));
|
||||||
setError();
|
setError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ atUint64 FileWriter::length() const { return utility::fileSize(m_filename); }
|
||||||
void FileWriter::writeUBytes(const atUint8* data, atUint64 len) {
|
void FileWriter::writeUBytes(const atUint8* data, atUint64 len) {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
if (m_globalErr) {
|
if (m_globalErr) {
|
||||||
atError(fmt("File not open for writing"));
|
atError(FMT_STRING("File not open for writing"));
|
||||||
}
|
}
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
|
@ -112,7 +112,7 @@ void FileWriter::writeUBytes(const atUint8* data, atUint64 len) {
|
||||||
|
|
||||||
if (WriteFile(m_fileHandle, data, toWrite, &written, nullptr) == FALSE) {
|
if (WriteFile(m_fileHandle, data, toWrite, &written, nullptr) == FALSE) {
|
||||||
if (m_globalErr) {
|
if (m_globalErr) {
|
||||||
atError(fmt("Unable to write to file"));
|
atError(FMT_STRING("Unable to write to file"));
|
||||||
}
|
}
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#define FMT_STRING_ALIAS 1
|
#define FMT_STRING_ALIAS 1
|
||||||
#define FMT_ENFORCE_COMPILE_STRING 1
|
#define FMT_ENFORCE_COMPILE_STRING 1
|
||||||
#define FMT_USE_GRISU 0
|
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, const athena::SeekOrigin& origin) {
|
std::ostream& operator<<(std::ostream& os, const athena::SeekOrigin& origin) {
|
||||||
|
|
|
@ -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) {
|
: m_data(data), m_length(length), m_position(0), m_owns(takeOwnership), m_globalErr(globalErr) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("data cannot be NULL"));
|
atError(FMT_STRING("data cannot be NULL"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ MemoryReader::~MemoryReader() {
|
||||||
MemoryCopyReader::MemoryCopyReader(const void* data, atUint64 length) : MemoryReader(data, length, false) {
|
MemoryCopyReader::MemoryCopyReader(const void* data, atUint64 length) : MemoryReader(data, length, false) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("data cannot be NULL"));
|
atError(FMT_STRING("data cannot be NULL"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin) {
|
||||||
case SeekOrigin::Begin:
|
case SeekOrigin::Begin:
|
||||||
if ((position < 0 || atInt64(position) > atInt64(m_length))) {
|
if ((position < 0 || atInt64(position) > atInt64(m_length))) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atFatal(fmt("Position {:08X} outside stream bounds "), position);
|
atFatal(FMT_STRING("Position {:08X} outside stream bounds "), position);
|
||||||
m_position = m_length;
|
m_position = m_length;
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
|
@ -54,7 +54,7 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin) {
|
||||||
case SeekOrigin::Current:
|
case SeekOrigin::Current:
|
||||||
if (((atInt64(m_position) + position) < 0 || (m_position + atUint64(position)) > m_length)) {
|
if (((atInt64(m_position) + position) < 0 || (m_position + atUint64(position)) > m_length)) {
|
||||||
if (m_globalErr)
|
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);
|
m_position = (position < 0 ? 0 : m_length);
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
|
@ -66,7 +66,7 @@ void MemoryReader::seek(atInt64 position, SeekOrigin origin) {
|
||||||
case SeekOrigin::End:
|
case SeekOrigin::End:
|
||||||
if ((((atInt64)m_length - position < 0) || (m_length - position) > m_length)) {
|
if ((((atInt64)m_length - position < 0) || (m_length - position) > m_length)) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atFatal(fmt("Position {:08X} outside stream bounds "), position);
|
atFatal(FMT_STRING("Position {:08X} outside stream bounds "), position);
|
||||||
m_position = m_length;
|
m_position = m_length;
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
|
@ -104,7 +104,7 @@ atUint8* MemoryReader::data() const {
|
||||||
atUint64 MemoryReader::readUBytesToBuf(void* buf, atUint64 length) {
|
atUint64 MemoryReader::readUBytesToBuf(void* buf, atUint64 length) {
|
||||||
if (m_position >= m_length) {
|
if (m_position >= m_length) {
|
||||||
if (m_globalErr)
|
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;
|
m_position = m_length;
|
||||||
setError();
|
setError();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -123,7 +123,7 @@ void MemoryCopyReader::loadData() {
|
||||||
|
|
||||||
if (!in) {
|
if (!in) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Unable to open file '%s'"), m_filepath);
|
atError(FMT_STRING("Unable to open file '%s'"), m_filepath);
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ void MemoryCopyReader::loadData() {
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (m_globalErr)
|
if (m_globalErr)
|
||||||
atError(fmt("Error reading data from disk"));
|
atError(FMT_STRING("Error reading data from disk"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
} else if (ret == 0)
|
} else if (ret == 0)
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace athena::io {
|
||||||
MemoryWriter::MemoryWriter(atUint8* data, atUint64 length, bool takeOwnership)
|
MemoryWriter::MemoryWriter(atUint8* data, atUint64 length, bool takeOwnership)
|
||||||
: m_data(data), m_length(length), m_bufferOwned(takeOwnership) {
|
: m_data(data), m_length(length), m_bufferOwned(takeOwnership) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
atError(fmt("data cannot be NULL"));
|
atError(FMT_STRING("data cannot be NULL"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ MemoryCopyWriter::MemoryCopyWriter(atUint8* data, atUint64 length) {
|
||||||
m_bufferOwned = false;
|
m_bufferOwned = false;
|
||||||
|
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
atError(fmt("length cannot be 0"));
|
atError(FMT_STRING("length cannot be 0"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ MemoryCopyWriter::MemoryCopyWriter(std::string_view filename) {
|
||||||
m_bufferOwned = false;
|
m_bufferOwned = false;
|
||||||
|
|
||||||
if (!m_data) {
|
if (!m_data) {
|
||||||
atError(fmt("Could not allocate memory!"));
|
atError(FMT_STRING("Could not allocate memory!"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -61,13 +61,13 @@ void MemoryWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||||
switch (origin) {
|
switch (origin) {
|
||||||
case SeekOrigin::Begin:
|
case SeekOrigin::Begin:
|
||||||
if (position < 0) {
|
if (position < 0) {
|
||||||
atError(fmt("Position outside stream bounds"));
|
atError(FMT_STRING("Position outside stream bounds"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((atUint64)position > m_length) {
|
if ((atUint64)position > m_length) {
|
||||||
atError(fmt("data exceeds available buffer space"));
|
atError(FMT_STRING("data exceeds available buffer space"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -77,13 +77,13 @@ void MemoryWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||||
|
|
||||||
case SeekOrigin::Current:
|
case SeekOrigin::Current:
|
||||||
if ((((atInt64)m_position + position) < 0)) {
|
if ((((atInt64)m_position + position) < 0)) {
|
||||||
atError(fmt("Position outside stream bounds"));
|
atError(FMT_STRING("Position outside stream bounds"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_position + position > m_length) {
|
if (m_position + position > m_length) {
|
||||||
atError(fmt("data exceeds available buffer space"));
|
atError(FMT_STRING("data exceeds available buffer space"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -93,13 +93,13 @@ void MemoryWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||||
|
|
||||||
case SeekOrigin::End:
|
case SeekOrigin::End:
|
||||||
if (((atInt64)m_length - position) < 0) {
|
if (((atInt64)m_length - position) < 0) {
|
||||||
atError(fmt("Position outside stream bounds"));
|
atError(FMT_STRING("Position outside stream bounds"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((atUint64)position > m_length) {
|
if ((atUint64)position > m_length) {
|
||||||
atError(fmt("data exceeds available buffer space"));
|
atError(FMT_STRING("data exceeds available buffer space"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ void MemoryCopyWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||||
switch (origin) {
|
switch (origin) {
|
||||||
case SeekOrigin::Begin:
|
case SeekOrigin::Begin:
|
||||||
if (position < 0) {
|
if (position < 0) {
|
||||||
atError(fmt("Position outside stream bounds"));
|
atError(FMT_STRING("Position outside stream bounds"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ void MemoryCopyWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||||
|
|
||||||
case SeekOrigin::Current:
|
case SeekOrigin::Current:
|
||||||
if ((((atInt64)m_position + position) < 0)) {
|
if ((((atInt64)m_position + position) < 0)) {
|
||||||
atError(fmt("Position outside stream bounds"));
|
atError(FMT_STRING("Position outside stream bounds"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ void MemoryCopyWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||||
|
|
||||||
case SeekOrigin::End:
|
case SeekOrigin::End:
|
||||||
if (((atInt64)m_length - position) < 0) {
|
if (((atInt64)m_length - position) < 0) {
|
||||||
atError(fmt("Position outside stream bounds"));
|
atError(FMT_STRING("Position outside stream bounds"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ atUint8* MemoryWriter::data() const {
|
||||||
|
|
||||||
void MemoryWriter::save(std::string_view filename) {
|
void MemoryWriter::save(std::string_view filename) {
|
||||||
if (filename.empty() && m_filepath.empty()) {
|
if (filename.empty() && m_filepath.empty()) {
|
||||||
atError(fmt("No file specified, cannot save."));
|
atError(FMT_STRING("No file specified, cannot save."));
|
||||||
setError();
|
setError();
|
||||||
return;
|
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};
|
std::unique_ptr<FILE, decltype(&std::fclose)> out{std::fopen(m_filepath.c_str(), "wb"), std::fclose};
|
||||||
if (!out) {
|
if (!out) {
|
||||||
atError(fmt("Unable to open file '{}'"), m_filepath);
|
atError(FMT_STRING("Unable to open file '{}'"), m_filepath);
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ void MemoryWriter::save(std::string_view filename) {
|
||||||
const atInt64 ret = std::fwrite(m_data + done, 1, blocksize, out.get());
|
const atInt64 ret = std::fwrite(m_data + done, 1, blocksize, out.get());
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
atError(fmt("Error writing data to disk"));
|
atError(FMT_STRING("Error writing data to disk"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -222,13 +222,13 @@ void MemoryWriter::save(std::string_view filename) {
|
||||||
|
|
||||||
void MemoryWriter::writeUBytes(const atUint8* data, atUint64 length) {
|
void MemoryWriter::writeUBytes(const atUint8* data, atUint64 length) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
atError(fmt("data cannnot be NULL"));
|
atError(FMT_STRING("data cannnot be NULL"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_position + length > m_length) {
|
if (m_position + length > m_length) {
|
||||||
atError(fmt("data length exceeds available buffer space"));
|
atError(FMT_STRING("data length exceeds available buffer space"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ void MemoryWriter::writeUBytes(const atUint8* data, atUint64 length) {
|
||||||
|
|
||||||
void MemoryCopyWriter::writeUBytes(const atUint8* data, atUint64 length) {
|
void MemoryCopyWriter::writeUBytes(const atUint8* data, atUint64 length) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
atError(fmt("data cannnot be NULL"));
|
atError(FMT_STRING("data cannnot be NULL"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ void MemoryCopyWriter::writeUBytes(const atUint8* data, atUint64 length) {
|
||||||
|
|
||||||
void MemoryCopyWriter::resize(atUint64 newSize) {
|
void MemoryCopyWriter::resize(atUint64 newSize) {
|
||||||
if (newSize < m_length) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ bool Socket::openSocket() {
|
||||||
|
|
||||||
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
if (m_socket == -1) {
|
if (m_socket == -1) {
|
||||||
atError(fmt("Can't allocate socket"));
|
atError(FMT_STRING("Can't allocate socket"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,13 +138,13 @@ bool Socket::openAndListen(const IPAddress& address, uint32_t port) {
|
||||||
sockaddr_in addr = createAddress(address.toInteger(), port);
|
sockaddr_in addr = createAddress(address.toInteger(), port);
|
||||||
if (bind(m_socket, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == -1) {
|
if (bind(m_socket, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == -1) {
|
||||||
/* Not likely to happen, but... */
|
/* 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (::listen(m_socket, 0) == -1) {
|
if (::listen(m_socket, 0) == -1) {
|
||||||
/* Oops, socket is deaf */
|
/* Oops, socket is deaf */
|
||||||
atError(fmt("Failed to listen to port {}"), port);
|
atError(FMT_STRING("Failed to listen to port {}"), port);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,11 +164,11 @@ Socket::EResult Socket::accept(Socket& remoteSocketOut, sockaddr_in& fromAddress
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
EResult res = (errno == EAGAIN) ? EResult::Busy : EResult::Error;
|
EResult res = (errno == EAGAIN) ? EResult::Busy : EResult::Error;
|
||||||
if (res == 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
|
#else
|
||||||
EResult res = LastWSAError();
|
EResult res = LastWSAError();
|
||||||
if (res == EResult::Error)
|
if (res == EResult::Error)
|
||||||
atError(fmt("Failed to accept incoming connection"));
|
atError(FMT_STRING("Failed to accept incoming connection"));
|
||||||
#endif
|
#endif
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,7 +167,7 @@ std::string wideToUtf8(std::wstring_view src) {
|
||||||
utf8proc_uint8_t mb[4];
|
utf8proc_uint8_t mb[4];
|
||||||
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
utf8proc_ssize_t c = utf8proc_encode_char(utf8proc_int32_t(ch), mb);
|
||||||
if (c < 0) {
|
if (c < 0) {
|
||||||
atWarning(fmt("invalid UTF-8 character while encoding"));
|
atWarning(FMT_STRING("invalid UTF-8 character while encoding"));
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
retval.append(reinterpret_cast<char*>(mb), c);
|
retval.append(reinterpret_cast<char*>(mb), c);
|
||||||
|
@ -183,7 +183,7 @@ std::wstring utf8ToWide(std::string_view src) {
|
||||||
utf8proc_int32_t wc;
|
utf8proc_int32_t wc;
|
||||||
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
utf8proc_ssize_t len = utf8proc_iterate(buf, -1, &wc);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
atWarning(fmt("invalid UTF-8 character while decoding"));
|
atWarning(FMT_STRING("invalid UTF-8 character while decoding"));
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
buf += len;
|
buf += len;
|
||||||
|
|
|
@ -10,7 +10,7 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||||
switch (origin) {
|
switch (origin) {
|
||||||
case SeekOrigin::Begin:
|
case SeekOrigin::Begin:
|
||||||
if (position < 0) {
|
if (position < 0) {
|
||||||
atError(fmt("Position outside stream bounds"));
|
atError(FMT_STRING("Position outside stream bounds"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||||
|
|
||||||
case SeekOrigin::Current:
|
case SeekOrigin::Current:
|
||||||
if ((((atInt64)m_position + position) < 0)) {
|
if ((((atInt64)m_position + position) < 0)) {
|
||||||
atError(fmt("Position outside stream bounds"));
|
atError(FMT_STRING("Position outside stream bounds"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -36,13 +36,13 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||||
|
|
||||||
case SeekOrigin::End:
|
case SeekOrigin::End:
|
||||||
if (((atInt64)m_data.size() - position) < 0) {
|
if (((atInt64)m_data.size() - position) < 0) {
|
||||||
atError(fmt("Position outside stream bounds"));
|
atError(FMT_STRING("Position outside stream bounds"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((atUint64)position > m_data.size()) {
|
if ((atUint64)position > m_data.size()) {
|
||||||
atError(fmt("data exceeds vector size"));
|
atError(FMT_STRING("data exceeds vector size"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ void VectorWriter::seek(atInt64 position, SeekOrigin origin) {
|
||||||
|
|
||||||
void VectorWriter::writeUBytes(const atUint8* data, atUint64 length) {
|
void VectorWriter::writeUBytes(const atUint8* data, atUint64 length) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
atError(fmt("data cannnot be NULL"));
|
atError(FMT_STRING("data cannnot be NULL"));
|
||||||
setError();
|
setError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue