From af59ea2d4815d8ca94ba8188eccbc17843bd221c Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Thu, 15 Aug 2019 08:52:45 -0700 Subject: [PATCH] Revert "General: Minor general cleanup" --- include/LZ77/LZType10.hpp | 4 +- include/LZ77/LZType11.hpp | 4 +- include/athena/DNAOp.hpp | 175 ++++++++++++++++--------------- include/athena/DNAYaml.hpp | 23 ++-- include/athena/Dir.hpp | 2 +- include/athena/FileInfo.hpp | 20 ++-- include/athena/FileReader.hpp | 16 +-- include/athena/FileWriter.hpp | 26 ++--- include/athena/Global.hpp | 11 +- include/athena/IStreamReader.hpp | 149 +++++++++++++------------- include/athena/IStreamWriter.hpp | 38 ++++--- include/athena/MemoryReader.hpp | 10 +- include/athena/MemoryWriter.hpp | 20 ++-- include/athena/Utility.hpp | 4 +- include/athena/VectorWriter.hpp | 10 +- include/athena/YAMLCommon.hpp | 4 +- include/athena/YAMLDocReader.hpp | 19 ++-- include/athena/YAMLDocWriter.hpp | 21 ++-- src/LZ77/LZType11.cpp | 2 +- src/athena/Compression.cpp | 4 +- src/athena/Dir.cpp | 2 +- src/athena/FileInfo.cpp | 16 +-- src/athena/Socket.cpp | 4 +- src/athena/Utility.cpp | 2 +- 24 files changed, 302 insertions(+), 284 deletions(-) diff --git a/include/LZ77/LZType10.hpp b/include/LZ77/LZType10.hpp index a3517bc..c613625 100644 --- a/include/LZ77/LZType10.hpp +++ b/include/LZ77/LZType10.hpp @@ -6,6 +6,6 @@ class LZType10 : public LZBase { public: explicit LZType10(atInt32 minimumOffset = 1, atInt32 SlidingWindow = 4096, atInt32 MinimumMatch = 3, atInt32 BlockSize = 8); - atUint32 compress(const atUint8* src, atUint8** dstBuf, atUint32 srcLength) override; - atUint32 decompress(const atUint8* src, atUint8** dst, atUint32 srcLen) override; + atUint32 compress(const atUint8* src, atUint8** dstBuf, atUint32 srcLength); + atUint32 decompress(const atUint8* src, atUint8** dst, atUint32 srcLen); }; diff --git a/include/LZ77/LZType11.hpp b/include/LZ77/LZType11.hpp index 7402319..e5e1c99 100644 --- a/include/LZ77/LZType11.hpp +++ b/include/LZ77/LZType11.hpp @@ -6,6 +6,6 @@ class LZType11 : public LZBase { public: explicit LZType11(atInt32 MinimumOffset = 1, atInt32 SlidingWindow = 4096, atInt32 MinimumMatch = 3, atInt32 BlockSize = 8); - atUint32 compress(const atUint8* src, atUint8** dst, atUint32 srcLength) override; - atUint32 decompress(const atUint8* src, atUint8** dst, atUint32 srcLength) override; + atUint32 compress(const atUint8* src, atUint8** dst, atUint32 srcLength); + atUint32 decompress(const atUint8* src, atUint8** dst, atUint32 srcLength); }; diff --git a/include/athena/DNAOp.hpp b/include/athena/DNAOp.hpp index 271dd63..a63e550 100644 --- a/include/athena/DNAOp.hpp +++ b/include/athena/DNAOp.hpp @@ -56,16 +56,16 @@ constexpr PropId operator"" _propid(const char* s, size_t len) { return {s}; } enum class PropType { None, CRC32, CRC64 }; template -using __IsPODType = std::disjunction< +using __IsPODType = typename std::disjunction< std::is_arithmetic>, std::is_convertible&, atVec2f&>, std::is_convertible&, atVec3f&>, std::is_convertible&, atVec4f&>, std::is_convertible&, atVec2d&>, std::is_convertible&, atVec3d&>, std::is_convertible&, atVec4d&>>; template -constexpr bool __IsPODType_v = __IsPODType::value; +inline constexpr bool __IsPODType_v = __IsPODType::value; template -using __CastPODType = std::conditional_t< +using __CastPODType = typename std::conditional_t< std::is_convertible_v&, atVec2f&>, atVec2f, std::conditional_t< std::is_convertible_v&, atVec3f&>, atVec3f, @@ -78,32 +78,32 @@ using __CastPODType = std::conditional_t< std::remove_cv_t>>>>>>; template -uint16_t __Read16(IStreamReader& r) { +inline uint16_t __Read16(IStreamReader& r) { return DNAE == Endian::Big ? r.readUint16Big() : r.readUint16Little(); } template -void __Write16(IStreamWriter& w, uint16_t v) { +inline void __Write16(IStreamWriter& w, uint16_t v) { DNAE == Endian::Big ? w.writeUint16Big(v) : w.writeUint16Little(v); } template -uint32_t __Read32(IStreamReader& r) { +inline uint32_t __Read32(IStreamReader& r) { return DNAE == Endian::Big ? r.readUint32Big() : r.readUint32Little(); } template -void __Write32(IStreamWriter& w, uint32_t v) { +inline void __Write32(IStreamWriter& w, uint32_t v) { DNAE == Endian::Big ? w.writeUint32Big(v) : w.writeUint32Little(v); } template -uint64_t __Read64(IStreamReader& r) { +inline uint64_t __Read64(IStreamReader& r) { return DNAE == Endian::Big ? r.readUint64Big() : r.readUint64Little(); } template -void __Write64(IStreamWriter& w, uint64_t v) { +inline void __Write64(IStreamWriter& w, uint64_t v) { DNAE == Endian::Big ? w.writeUint64Big(v) : w.writeUint64Little(v); } @@ -112,7 +112,7 @@ struct BinarySize { using PropT = std::conditional_t; using StreamT = size_t; template - static std::enable_if_t> Do(const PropId& id, T& var, StreamT& s) { + static typename std::enable_if_t> Do(const PropId& id, T& var, StreamT& s) { if (PropOp != PropType::None) { /* Accessed via Enumerate, header */ s += 6; @@ -121,7 +121,7 @@ struct BinarySize { BinarySize::Do(id, *reinterpret_cast(&var), s); } template - static std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& s) { + static typename std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& s) { if (PropOp != PropType::None) { /* Accessed via Enumerate, header */ s += 6; @@ -130,17 +130,19 @@ struct BinarySize { BinarySize::Do(id, static_cast(const_cast&>(var)), s); } template - static std::enable_if_t<__IsDNARecord_v && PropOp != PropType::None> Do(const PropId& id, T& var, StreamT& s) { + static typename std::enable_if_t<__IsDNARecord_v && PropOp != PropType::None> Do(const PropId& id, T& var, + StreamT& s) { /* Accessed via Enumerate, header */ s += 6; var.template Enumerate>(s); } template - static std::enable_if_t<__IsDNARecord_v && PropOp == PropType::None> Do(const PropId& id, T& var, StreamT& s) { + static typename std::enable_if_t<__IsDNARecord_v && PropOp == PropType::None> Do(const PropId& id, T& var, + StreamT& s) { var.template Enumerate>(s); } template - static std::enable_if_t> Do(const PropId& id, T& var, StreamT& s) { + static typename std::enable_if_t> Do(const PropId& id, T& var, StreamT& s) { for (auto& v : var) BinarySize::Do, DNAE>(id, v, s); } @@ -149,14 +151,14 @@ struct BinarySize { BinarySize::Do(id, var, s); } template - static std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, - StreamT& s) { + static typename std::enable_if_t> Do(const PropId& id, std::vector& vector, + const S& count, StreamT& s) { for (T& v : vector) BinarySize::Do(id, v, s); } template - static std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, - StreamT& s) { + static typename std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, + StreamT& s) { /* libc++ specializes vector as a bitstream */ s += vector.size(); } @@ -165,7 +167,7 @@ struct BinarySize { s += count; } template - static std::enable_if_t> Do(const PropId& id, T& str, StreamT& s) { + static typename std::enable_if_t> Do(const PropId& id, T& str, StreamT& s) { s += str.size() + 1; } static void Do(const PropId& id, std::string& str, atInt32 count, StreamT& s) { @@ -175,7 +177,7 @@ struct BinarySize { s += count; } template - static std::enable_if_t> Do(const PropId& id, T& str, StreamT& s) { + static typename std::enable_if_t> Do(const PropId& id, T& str, StreamT& s) { s += str.size() * 2 + 2; } template @@ -261,7 +263,7 @@ struct PropCount { s += 1; } template - static std::enable_if_t> Do(const PropId& id, T& str, StreamT& s) { + static typename std::enable_if_t> Do(const PropId& id, T& str, StreamT& s) { /* Only reports one level of properties */ s += 1; } @@ -270,7 +272,7 @@ struct PropCount { s += 1; } template - static std::enable_if_t> Do(const PropId& id, T& str, StreamT& s) { + static typename std::enable_if_t> Do(const PropId& id, T& str, StreamT& s) { /* Only reports one level of properties */ s += 1; } @@ -288,21 +290,23 @@ struct Read { using PropT = std::conditional_t; using StreamT = IStreamReader; template - static std::enable_if_t> Do(const PropId& id, T& var, StreamT& r) { + static typename std::enable_if_t> Do(const PropId& id, T& var, StreamT& r) { using PODType = std::underlying_type_t; Read::Do(id, *reinterpret_cast(&var), r); } template - static std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& r) { + static typename std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& r) { using CastT = __CastPODType; Read::Do(id, static_cast(var), r); } template - static std::enable_if_t<__IsDNARecord() && PropOp == PropType::None> Do(const PropId& id, T& var, StreamT& r) { + static typename std::enable_if_t<__IsDNARecord() && PropOp == PropType::None> Do(const PropId& id, T& var, + StreamT& r) { var.template Enumerate>(r); } template - static std::enable_if_t<__IsDNARecord() && PropOp != PropType::None> Do(const PropId& id, T& var, StreamT& r) { + static typename std::enable_if_t<__IsDNARecord() && PropOp != PropType::None> Do(const PropId& id, T& var, + StreamT& r) { /* Accessed via Lookup, no header */ atUint16 propCount = __Read16(r); for (atUint32 i = 0; i < propCount; ++i) { @@ -320,7 +324,7 @@ struct Read { } } template - static std::enable_if_t> Do(const PropId& id, T& var, StreamT& s) { + static typename std::enable_if_t> Do(const PropId& id, T& var, StreamT& s) { for (auto& v : var) Read::Do, DNAE>(id, v, s); } @@ -329,8 +333,8 @@ struct Read { Read::Do(id, var, s); } template - static std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, - StreamT& r) { + static typename std::enable_if_t> Do(const PropId& id, std::vector& vector, + const S& count, StreamT& r) { vector.clear(); vector.reserve(count); for (size_t i = 0; i < static_cast(count); ++i) { @@ -339,8 +343,8 @@ struct Read { } } template - static std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, - StreamT& r) { + static typename std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, + StreamT& r) { /* libc++ specializes vector as a bitstream */ vector.clear(); vector.reserve(count); @@ -352,12 +356,12 @@ struct Read { r.readUBytesToBuf(buf.get(), count); } template - static std::enable_if_t> Do(const PropId& id, T& str, StreamT& r) { + static typename std::enable_if_t> Do(const PropId& id, T& str, StreamT& r) { str = r.readString(); } static void Do(const PropId& id, std::string& str, atInt32 count, StreamT& r) { str = r.readString(count); } template - static std::enable_if_t> Do(const PropId& id, T& str, StreamT& r) { + static typename std::enable_if_t> Do(const PropId& id, T& str, StreamT& r) { Read::Do(id, str, r); } template @@ -425,7 +429,7 @@ struct Write { using PropT = std::conditional_t; using StreamT = IStreamWriter; template - static std::enable_if_t> Do(const PropId& id, T& var, StreamT& w) { + static typename std::enable_if_t> Do(const PropId& id, T& var, StreamT& w) { if (PropOp != PropType::None) { /* Accessed via Enumerate, header */ if (PropOp == PropType::CRC64) @@ -440,7 +444,7 @@ struct Write { Write::Do(id, *reinterpret_cast(&var), w); } template - static std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& w) { + static typename std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& w) { using CastT = __CastPODType; if (PropOp != PropType::None) { /* Accessed via Enumerate, header */ @@ -456,7 +460,8 @@ struct Write { Write::Do(id, static_cast(const_cast&>(var)), w); } template - static std::enable_if_t<__IsDNARecord() && PropOp != PropType::None> Do(const PropId& id, T& var, StreamT& w) { + static typename std::enable_if_t<__IsDNARecord() && PropOp != PropType::None> Do(const PropId& id, T& var, + StreamT& w) { /* Accessed via Enumerate, header */ if (PropOp == PropType::CRC64) __Write64(w, id.crc64); @@ -472,11 +477,12 @@ struct Write { var.template Enumerate>(w); } template - static std::enable_if_t<__IsDNARecord() && PropOp == PropType::None> Do(const PropId& id, T& var, StreamT& w) { + static typename std::enable_if_t<__IsDNARecord() && PropOp == PropType::None> Do(const PropId& id, T& var, + StreamT& w) { var.template Enumerate>(w); } template - static std::enable_if_t> Do(const PropId& id, T& var, StreamT& s) { + static typename std::enable_if_t> Do(const PropId& id, T& var, StreamT& s) { for (auto& v : var) Write::Do, DNAE>(id, v, s); } @@ -485,14 +491,14 @@ struct Write { Write::Do(id, var, s); } template - static std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, - StreamT& w) { + static typename std::enable_if_t> Do(const PropId& id, std::vector& vector, + const S& count, StreamT& w) { for (T& v : vector) Write::Do(id, v, w); } template - static std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, - StreamT& w) { + static typename std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, + StreamT& w) { /* libc++ specializes vector as a bitstream */ for (const T& v : vector) w.writeBool(v); @@ -502,12 +508,13 @@ struct Write { w.writeUBytes(buf.get(), count); } template - static std::enable_if_t> Do(const PropId& id, std::string& str, StreamT& w) { + static typename std::enable_if_t> Do(const PropId& id, std::string& str, StreamT& w) { w.writeString(str); } static void Do(const PropId& id, std::string& str, atInt32 count, StreamT& w) { w.writeString(str, count); } template - static std::enable_if_t> Do(const PropId& id, std::wstring& str, StreamT& w) { + static typename std::enable_if_t> Do(const PropId& id, std::wstring& str, + StreamT& w) { Write::Do(id, str, w); } template @@ -573,22 +580,22 @@ struct ReadYaml { using PropT = std::conditional_t; using StreamT = YAMLDocReader; template - static std::enable_if_t> Do(const PropId& id, T& var, StreamT& r) { + static typename std::enable_if_t> Do(const PropId& id, T& var, StreamT& r) { using PODType = std::underlying_type_t; ReadYaml::Do(id, *reinterpret_cast(&var), r); } template - static std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& r) { + static typename std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& r) { using CastT = __CastPODType; ReadYaml::Do(id, static_cast(var), r); } template - static std::enable_if_t<__IsDNARecord_v> Do(const PropId& id, T& var, StreamT& r) { + static typename std::enable_if_t<__IsDNARecord_v> Do(const PropId& id, T& var, StreamT& r) { if (auto rec = r.enterSubRecord(id.name)) var.template Enumerate>(r); } template - static std::enable_if_t> Do(const PropId& id, T& var, StreamT& r) { + static typename std::enable_if_t> Do(const PropId& id, T& var, StreamT& r) { size_t _count; if (auto __v = r.enterSubVector(id.name, _count)) for (size_t i = 0; i < _count && i < std::extent_v; ++i) @@ -599,8 +606,8 @@ struct ReadYaml { /* Squelch size field access */ } template - static std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, - StreamT& r) { + static typename std::enable_if_t> Do(const PropId& id, std::vector& vector, + const S& count, StreamT& r) { size_t _count; vector.clear(); if (auto __v = r.enterSubVector(id.name, _count)) { @@ -614,8 +621,8 @@ struct ReadYaml { const_cast(count) = vector.size(); } template - static std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, - StreamT& r) { + static typename std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, + StreamT& r) { /* libc++ specializes vector as a bitstream */ size_t _count; vector.clear(); @@ -631,12 +638,12 @@ struct ReadYaml { buf = r.readUBytes(id.name); } template - static std::enable_if_t> Do(const PropId& id, T& str, StreamT& r) { + static typename std::enable_if_t> Do(const PropId& id, T& str, StreamT& r) { str = r.readString(id.name); } static void Do(const PropId& id, std::string& str, atInt32 count, StreamT& r) { str = r.readString(id.name); } template - static std::enable_if_t> Do(const PropId& id, T& str, StreamT& r) { + static typename std::enable_if_t> Do(const PropId& id, T& str, StreamT& r) { str = r.readWString(id.name); } template @@ -690,22 +697,22 @@ struct WriteYaml { using PropT = std::conditional_t; using StreamT = YAMLDocWriter; template - static std::enable_if_t> Do(const PropId& id, T& var, StreamT& w) { + static typename std::enable_if_t> Do(const PropId& id, T& var, StreamT& w) { using PODType = std::underlying_type_t; WriteYaml::Do(id, *reinterpret_cast(&var), w); } template - static std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& w) { + static typename std::enable_if_t<__IsPODType_v> Do(const PropId& id, T& var, StreamT& w) { using CastT = __CastPODType; WriteYaml::Do(id, static_cast(const_cast&>(var)), w); } template - static std::enable_if_t<__IsDNARecord_v> Do(const PropId& id, T& var, StreamT& w) { + static typename std::enable_if_t<__IsDNARecord_v> Do(const PropId& id, T& var, StreamT& w) { if (auto rec = w.enterSubRecord(id.name)) var.template Enumerate>(w); } template - static std::enable_if_t> Do(const PropId& id, T& var, StreamT& w) { + static typename std::enable_if_t> Do(const PropId& id, T& var, StreamT& w) { if (auto __v = w.enterSubVector(id.name)) for (auto& v : var) WriteYaml::Do, DNAE>({}, v, w); @@ -715,15 +722,15 @@ struct WriteYaml { /* Squelch size field access */ } template - static std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, - StreamT& w) { + static typename std::enable_if_t> Do(const PropId& id, std::vector& vector, + const S& count, StreamT& w) { if (auto __v = w.enterSubVector(id.name)) for (T& v : vector) WriteYaml::Do(id, v, w); } template - static std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, - StreamT& w) { + static typename std::enable_if_t> Do(const PropId& id, std::vector& vector, const S& count, + StreamT& w) { /* libc++ specializes vector as a bitstream */ if (auto __v = w.enterSubVector(id.name)) for (const T& v : vector) @@ -733,12 +740,12 @@ struct WriteYaml { w.writeUBytes(id.name, buf, count); } template - static std::enable_if_t> Do(const PropId& id, T& str, StreamT& w) { + static typename std::enable_if_t> Do(const PropId& id, T& str, StreamT& w) { w.writeString(id.name, str); } static void Do(const PropId& id, std::string& str, atInt32 count, StreamT& w) { w.writeString(id.name, str); } template - static std::enable_if_t> Do(const PropId& id, T& str, StreamT& w) { + static typename std::enable_if_t> Do(const PropId& id, T& str, StreamT& w) { w.writeWString(id.name, str); } template @@ -788,77 +795,77 @@ __WRITE_YAML_S(atVec4f, Endian::Little) { w.writeVec4f(id.name, var); } __WRITE_YAML_S(atVec4d, Endian::Little) { w.writeVec4d(id.name, var); } template -void __Do(const PropId& id, T& var, typename Op::StreamT& s) { +inline void __Do(const PropId& id, T& var, typename Op::StreamT& s) { Op::template Do(id, var, s); } template -void __DoSize(const PropId& id, T& var, typename Op::StreamT& s) { +inline void __DoSize(const PropId& id, T& var, typename Op::StreamT& s) { Op::template DoSize(id, var, s); } template -void __Do(const PropId& id, std::vector& vector, const S& count, typename Op::StreamT& s) { +inline void __Do(const PropId& id, std::vector& vector, const S& count, typename Op::StreamT& s) { Op::template Do(id, vector, count, s); } template -void __Do(const PropId& id, std::unique_ptr& buf, size_t count, typename Op::StreamT& s) { +inline void __Do(const PropId& id, std::unique_ptr& buf, size_t count, typename Op::StreamT& s) { Op::Do(id, buf, count, s); } template -void __Do(const PropId& id, std::string& str, atInt32 count, typename Op::StreamT& s) { +inline void __Do(const PropId& id, std::string& str, atInt32 count, typename Op::StreamT& s) { Op::Do(id, str, count, s); } template -void __Do(const PropId& id, std::wstring& str, atInt32 count, typename Op::StreamT& s) { +inline void __Do(const PropId& id, std::wstring& str, atInt32 count, typename Op::StreamT& s) { Op::template Do(id, str, count, s); } template -void __DoSeek(atInt64 delta, athena::SeekOrigin whence, typename Op::StreamT& s) { +inline void __DoSeek(atInt64 delta, athena::SeekOrigin whence, typename Op::StreamT& s) { Op::DoSeek(delta, whence, s); } template -void __DoAlign(atInt64 amount, typename Op::StreamT& s) { +inline void __DoAlign(atInt64 amount, typename Op::StreamT& s) { Op::DoAlign(amount, s); } template -void __Read(T& obj, athena::io::IStreamReader& r) { +inline void __Read(T& obj, athena::io::IStreamReader& r) { __Do, T, T::DNAEndian>({}, obj, r); } template -void __Write(const T& obj, athena::io::IStreamWriter& w) { +inline void __Write(const T& obj, athena::io::IStreamWriter& w) { __Do, T, T::DNAEndian>({}, const_cast(obj), w); } template -void __BinarySize(const T& obj, size_t& s) { +inline void __BinarySize(const T& obj, size_t& s) { __Do, T, T::DNAEndian>({}, const_cast(obj), s); } template -void __PropCount(const T& obj, size_t& s) { +inline void __PropCount(const T& obj, size_t& s) { const_cast(obj).template Enumerate>(s); } template -void __ReadYaml(T& obj, athena::io::YAMLDocReader& r) { +inline void __ReadYaml(T& obj, athena::io::YAMLDocReader& r) { obj.template Enumerate>(r); } template -void __WriteYaml(const T& obj, athena::io::YAMLDocWriter& w) { +inline void __WriteYaml(const T& obj, athena::io::YAMLDocWriter& w) { const_cast(obj).template Enumerate>(w); } template -void __ReadProp(T& obj, athena::io::IStreamReader& r) { +inline void __ReadProp(T& obj, athena::io::IStreamReader& r) { /* Read root 0xffffffff hash (hashed empty string) */ T::DNAEndian == Endian::Big ? r.readUint32Big() : r.readUint32Little(); atInt64 size = T::DNAEndian == Endian::Big ? r.readUint16Big() : r.readUint16Little(); @@ -870,17 +877,17 @@ void __ReadProp(T& obj, athena::io::IStreamReader& r) { } template -void __WriteProp(const T& obj, athena::io::IStreamWriter& w) { +inline void __WriteProp(const T& obj, athena::io::IStreamWriter& w) { __Do, T, T::DNAEndian>({}, const_cast(obj), w); } template -void __BinarySizeProp(const T& obj, size_t& s) { +inline void __BinarySizeProp(const T& obj, size_t& s) { __Do, T, T::DNAEndian>({}, const_cast(obj), s); } template -void __ReadProp64(T& obj, athena::io::IStreamReader& r) { +inline void __ReadProp64(T& obj, athena::io::IStreamReader& r) { /* Read root 0x0 hash (hashed empty string) */ T::DNAEndian == Endian::Big ? r.readUint64Big() : r.readUint64Little(); atInt64 size = T::DNAEndian == Endian::Big ? r.readUint16Big() : r.readUint16Little(); @@ -892,12 +899,12 @@ void __ReadProp64(T& obj, athena::io::IStreamReader& r) { } template -void __WriteProp64(const T& obj, athena::io::IStreamWriter& w) { +inline void __WriteProp64(const T& obj, athena::io::IStreamWriter& w) { __Do, T, T::DNAEndian>({}, const_cast(obj), w); } template -void __BinarySizeProp64(const T& obj, size_t& s) { +inline void __BinarySizeProp64(const T& obj, size_t& s) { __Do, T, T::DNAEndian>({}, const_cast(obj), s); } diff --git a/include/athena/DNAYaml.hpp b/include/athena/DNAYaml.hpp index 0ca0ad4..01d8dc7 100644 --- a/include/athena/DNAYaml.hpp +++ b/include/athena/DNAYaml.hpp @@ -9,17 +9,17 @@ namespace athena::io { template -const char* __GetDNAName(const T& dna, std::enable_if_t>* = nullptr) { +inline const char* __GetDNAName(const T& dna, typename std::enable_if_t>* = 0) { return dna.DNATypeV(); } template -const char* __GetDNAName(const T& dna, std::enable_if_t>* = nullptr) { +inline const char* __GetDNAName(const T& dna, typename std::enable_if_t>* = 0) { return dna.DNAType(); } template -std::string ToYAMLString(const T& dna) { +inline std::string ToYAMLString(const T& dna) { YAMLDocWriter docWriter(__GetDNAName(dna)); std::string res; @@ -35,7 +35,7 @@ std::string ToYAMLString(const T& dna) { } template -bool FromYAMLString(T& dna, std::string_view str) { +inline bool FromYAMLString(T& dna, std::string_view str) { YAMLStdStringViewReaderState reader(str); YAMLDocReader docReader; yaml_parser_set_input(docReader.getParser(), (yaml_read_handler_t*)YAMLStdStringReader, &reader); @@ -46,7 +46,7 @@ bool FromYAMLString(T& dna, std::string_view str) { } template -bool ValidateFromYAMLString(std::string_view str) { +inline bool ValidateFromYAMLString(std::string_view str) { YAMLStdStringViewReaderState reader(str); YAMLDocReader docReader; yaml_parser_set_input(docReader.getParser(), (yaml_read_handler_t*)YAMLStdStringReader, &reader); @@ -55,7 +55,7 @@ bool ValidateFromYAMLString(std::string_view str) { } template -bool ToYAMLStream(const T& dna, athena::io::IStreamWriter& fout) { +inline bool ToYAMLStream(const T& dna, athena::io::IStreamWriter& fout) { YAMLDocWriter docWriter(__GetDNAName(dna)); yaml_emitter_set_unicode(docWriter.getEmitter(), true); @@ -66,7 +66,8 @@ bool ToYAMLStream(const T& dna, athena::io::IStreamWriter& fout) { } template -bool ToYAMLStream(const T& dna, athena::io::IStreamWriter& fout, void (T::*fn)(YAMLDocWriter& out) const) { +inline bool ToYAMLStream(const T& dna, athena::io::IStreamWriter& fout, + void (T::*fn)(YAMLDocWriter& out) const) { YAMLDocWriter docWriter(__GetDNAName(dna)); yaml_emitter_set_unicode(docWriter.getEmitter(), true); @@ -77,7 +78,7 @@ bool ToYAMLStream(const T& dna, athena::io::IStreamWriter& fout, void (T::*fn)(Y } template -bool FromYAMLStream(T& dna, athena::io::IStreamReader& fin) { +inline bool FromYAMLStream(T& dna, athena::io::IStreamReader& fin) { YAMLDocReader docReader; if (!docReader.parse(&fin)) return false; @@ -86,7 +87,7 @@ bool FromYAMLStream(T& dna, athena::io::IStreamReader& fin) { } template -bool FromYAMLStream(T& dna, athena::io::IStreamReader& fin, void (T::*fn)(YAMLDocReader& in)) { +inline bool FromYAMLStream(T& dna, athena::io::IStreamReader& fin, void (T::*fn)(YAMLDocReader& in)) { YAMLDocReader docReader; if (!docReader.parse(&fin)) return false; @@ -95,7 +96,7 @@ bool FromYAMLStream(T& dna, athena::io::IStreamReader& fin, void (T::*fn)(YAMLDo } template -bool MergeToYAMLFile(const T& dna, const NameT& filename) { +inline bool MergeToYAMLFile(const T& dna, const NameT& filename) { athena::io::FileReader r(filename); YAMLDocWriter docWriter(__GetDNAName(dna), r.isOpen() ? &r : nullptr); r.close(); @@ -108,7 +109,7 @@ bool MergeToYAMLFile(const T& dna, const NameT& filename) { } template -bool ValidateFromYAMLStream(athena::io::IStreamReader& fin) { +inline bool ValidateFromYAMLStream(athena::io::IStreamReader& fin) { YAMLDocReader reader; atUint64 pos = fin.position(); yaml_parser_set_input(reader.getParser(), (yaml_read_handler_t*)YAMLAthenaReader, &fin); diff --git a/include/athena/Dir.hpp b/include/athena/Dir.hpp index 413800c..e18d080 100644 --- a/include/athena/Dir.hpp +++ b/include/athena/Dir.hpp @@ -14,7 +14,7 @@ public: explicit Dir(std::string_view path); std::string absolutePath() const; - static std::string absolutePath(std::string_view path) { return Dir(path).absolutePath(); } + static inline std::string absolutePath(std::string_view path) { return Dir(path).absolutePath(); } bool isDir() const; static bool isDir(std::string_view dir) { return Dir(dir).isDir(); } diff --git a/include/athena/FileInfo.hpp b/include/athena/FileInfo.hpp index 58cc753..1b8e01b 100644 --- a/include/athena/FileInfo.hpp +++ b/include/athena/FileInfo.hpp @@ -10,33 +10,33 @@ public: explicit FileInfo(std::string_view path = {}); std::string absolutePath() const; - static std::string absolutePath(std::string_view lnk) { return FileInfo(lnk).absolutePath(); } + static inline std::string absolutePath(std::string_view lnk) { return FileInfo(lnk).absolutePath(); } std::string absoluteFilePath() const; - static std::string absoluteFilePath(std::string_view path) { return FileInfo(path).absoluteFilePath(); } + static inline std::string absoluteFilePath(std::string_view path) { return FileInfo(path).absoluteFilePath(); } std::string filename() const; - static std::string filename(std::string_view path) { return FileInfo(path).filename(); } + static inline std::string filename(std::string_view path) { return FileInfo(path).filename(); } std::string path() const { return m_path; } - static std::string path(std::string_view path) { return FileInfo(path).path(); } + static inline std::string path(std::string_view path) { return FileInfo(path).path(); } std::string extension() const; - static std::string extension(std::string_view path) { return FileInfo(path).extension(); } + static inline std::string extension(std::string_view path) { return FileInfo(path).extension(); } atUint64 size() const; - static atUint64 size(std::string_view path) { return FileInfo(path).size(); } + static inline atUint64 size(std::string_view path) { return FileInfo(path).size(); } bool exists() const; - static bool exists(std::string_view path) { return FileInfo(path).exists(); } + static inline bool exists(std::string_view path) { return FileInfo(path).exists(); } bool isLink() const; - static bool isLink(std::string_view lnk) { return FileInfo(lnk).isLink(); } + static inline bool isLink(std::string_view lnk) { return FileInfo(lnk).isLink(); } bool isFile() const; - static bool isFile(std::string_view path) { return FileInfo(path).isFile(); } + static inline bool isFile(std::string_view path) { return FileInfo(path).isFile(); } bool touch() const; - static bool touch(std::string_view path) { return FileInfo(path).touch(); } + static inline bool touch(std::string_view path) { return FileInfo(path).touch(); } private: std::string m_path; diff --git a/include/athena/FileReader.hpp b/include/athena/FileReader.hpp index 123b3ab..16e1f7f 100644 --- a/include/athena/FileReader.hpp +++ b/include/athena/FileReader.hpp @@ -18,9 +18,9 @@ class FileReader : public IStreamReader { public: FileReader(std::string_view filename, atInt32 cacheSize = (32 * 1024), bool globalErr = true); FileReader(std::wstring_view filename, atInt32 cacheSize = (32 * 1024), bool globalErr = true); - ~FileReader() override; + virtual ~FileReader(); - std::string filename() const { + inline std::string filename() const { #if _WIN32 return utility::wideToUtf8(m_filename); #else @@ -28,7 +28,7 @@ public: #endif } - std::wstring wfilename() const { + inline std::wstring wfilename() const { #if _WIN32 return m_filename; #else @@ -38,12 +38,12 @@ public: void open(); void close(); - bool isOpen() const { return m_fileHandle != 0; } + inline bool isOpen() const { return m_fileHandle != 0; } bool save(); - void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override; - atUint64 position() const override; - atUint64 length() const override; - atUint64 readUBytesToBuf(void* buf, atUint64 len) override; + void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current); + atUint64 position() const; + atUint64 length() const; + atUint64 readUBytesToBuf(void* buf, atUint64 len); void setCacheSize(const atInt32 blockSize); diff --git a/include/athena/FileWriter.hpp b/include/athena/FileWriter.hpp index a095d9b..3d8cf38 100644 --- a/include/athena/FileWriter.hpp +++ b/include/athena/FileWriter.hpp @@ -15,16 +15,16 @@ class FileWriter : public IStreamWriter { public: FileWriter(std::string_view filename, bool overwrite = true, bool globalErr = true); FileWriter(std::wstring_view filename, bool overwrite = true, bool globalErr = true); - ~FileWriter() override; + virtual ~FileWriter(); - std::string filename() const { + inline std::string filename() const { #if _WIN32 return utility::wideToUtf8(m_filename); #else return m_filename; #endif } - std::wstring wfilename() const { + inline std::wstring wfilename() const { #if _WIN32 return m_filename; #else @@ -34,11 +34,11 @@ public: void open(bool overwrite = true); void close(); - bool isOpen() const { return m_fileHandle != 0; } - void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override; - atUint64 position() const override; - atUint64 length() const override; - void writeUBytes(const atUint8* data, atUint64 len) override; + inline bool isOpen() const { return m_fileHandle != 0; } + void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current); + atUint64 position() const; + atUint64 length() const; + void writeUBytes(const atUint8* data, atUint64 len); #if _WIN32 using HandleType = HANDLE; @@ -99,12 +99,12 @@ public: m_position = 0; } - atUint64 position() const override { return m_position; } - atUint64 length() const override { return m_deferredBuffer.size(); } - void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override; - void writeUBytes(const atUint8* data, atUint64 len) override; + inline atUint64 position() const { return m_position; } + inline atUint64 length() const { return m_deferredBuffer.size(); } + void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current); + void writeUBytes(const atUint8* data, atUint64 len); - ~TransactionalFileWriter() override { flush(); } + ~TransactionalFileWriter() { flush(); } }; } // namespace athena::io diff --git a/include/athena/Global.hpp b/include/athena/Global.hpp index f15df4b..02b5309 100644 --- a/include/athena/Global.hpp +++ b/include/athena/Global.hpp @@ -134,15 +134,16 @@ template struct DNAV; template -using __IsDNARecord = std::disjunction, T>, std::is_base_of, T>>; +using __IsDNARecord = + typename std::disjunction, T>, std::is_base_of, T>>; template -constexpr bool __IsDNARecord_v = __IsDNARecord::value; +inline constexpr bool __IsDNARecord_v = __IsDNARecord::value; template using __IsDNAVRecord = - std::disjunction, T>, std::is_base_of, T>>; + typename std::disjunction, T>, std::is_base_of, T>>; template -constexpr bool __IsDNAVRecord_v = __IsDNAVRecord::value; +inline constexpr bool __IsDNAVRecord_v = __IsDNAVRecord::value; } // namespace io } // namespace athena @@ -162,7 +163,7 @@ std::ostream& operator<<(std::ostream& os, const athena::Endian& endian); template constexpr auto __FIRST_ARG__(First first, Rest...) { return first; } template -auto __make_args_checked__(const S& format_str, Args&&... args) { +inline auto __make_args_checked__(const S& format_str, Args&&... args) { return fmt::internal::make_args_checked(format_str, std::forward(args)...); } diff --git a/include/athena/IStreamReader.hpp b/include/athena/IStreamReader.hpp index 66ef6e4..752576e 100644 --- a/include/athena/IStreamReader.hpp +++ b/include/athena/IStreamReader.hpp @@ -15,14 +15,14 @@ namespace athena::io { */ class IStreamReader : public IStream { public: - ~IStreamReader() override = default; + virtual ~IStreamReader() = default; /** @brief Sets the buffers position relative to the specified position.
* It seeks relative to the current position by default. * @param position where in the buffer to seek * @param origin The Origin to seek relative to */ - void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override = 0; + virtual void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) = 0; /** @brief Sets the buffer's position relative to the next 64-byte aligned position.
*/ @@ -44,19 +44,19 @@ public: * * @return True if at end; False otherwise. */ - bool atEnd() const override { return position() >= length(); } + bool atEnd() const { return position() >= length(); } /** @brief Returns the current position in the stream. * * @return The current position in the stream. */ - atUint64 position() const override = 0; + virtual atUint64 position() const = 0; /** @brief Returns the length of the file. * * @return True length of the file. */ - atUint64 length() const override = 0; + virtual atUint64 length() const = 0; /** @brief Reads a byte at the current position and advances the current position * @@ -68,15 +68,15 @@ public: return val; } template - atInt8 readVal(std::enable_if_t>* = nullptr) { + atInt8 readVal(typename std::enable_if::value>::type* = 0) { return readByte(); } template - atInt8 readValLittle(std::enable_if_t>* = nullptr) { + atInt8 readValLittle(typename std::enable_if::value>::type* = 0) { return readByte(); } template - atInt8 readValBig(std::enable_if_t>* = nullptr) { + atInt8 readValBig(typename std::enable_if::value>::type* = 0) { return readByte(); } @@ -86,15 +86,15 @@ public: */ atUint8 readUByte() { return readByte(); } template - atUint8 readVal(std::enable_if_t>* = nullptr) { + atUint8 readVal(typename std::enable_if::value>::type* = 0) { return readUByte(); } template - atUint8 readValLittle(std::enable_if_t>* = nullptr) { + atUint8 readValLittle(typename std::enable_if::value>::type* = 0) { return readUByte(); } template - atUint8 readValBig(std::enable_if_t>* = nullptr) { + atUint8 readValBig(typename std::enable_if::value>::type* = 0) { return readUByte(); } @@ -144,7 +144,7 @@ public: return m_endian == Big ? utility::BigInt16(val) : utility::LittleInt16(val); } template - atInt16 readVal(std::enable_if_t>* = nullptr) { + atInt16 readVal(typename std::enable_if::value>::type* = 0) { return readInt16(); } @@ -159,7 +159,7 @@ public: return utility::LittleInt16(val); } template - atInt16 readValLittle(std::enable_if_t>* = nullptr) { + atInt16 readValLittle(typename std::enable_if::value>::type* = 0) { return readInt16Little(); } @@ -174,7 +174,7 @@ public: return utility::BigInt16(val); } template - atInt16 readValBig(std::enable_if_t>* = nullptr) { + atInt16 readValBig(typename std::enable_if::value>::type* = 0) { return readInt16Big(); } @@ -185,7 +185,7 @@ public: */ atUint16 readUint16() { return readInt16(); } template - atUint16 readVal(std::enable_if_t>* = 0) { + atUint16 readVal(typename std::enable_if::value>::type* = 0) { return readUint16(); } @@ -200,7 +200,7 @@ public: return utility::LittleUint16(val); } template - atUint16 readValLittle(std::enable_if_t>* = nullptr) { + atUint16 readValLittle(typename std::enable_if::value>::type* = 0) { return readUint16Little(); } @@ -215,7 +215,7 @@ public: return utility::BigUint16(val); } template - atUint16 readValBig(std::enable_if_t>* = nullptr) { + atUint16 readValBig(typename std::enable_if::value>::type* = 0) { return readUint16Big(); } @@ -230,7 +230,7 @@ public: return m_endian == Big ? utility::BigInt32(val) : utility::LittleInt32(val); } template - atInt32 readVal(std::enable_if_t>* = nullptr) { + atInt32 readVal(typename std::enable_if::value>::type* = 0) { return readInt32(); } @@ -245,7 +245,7 @@ public: return utility::LittleInt32(val); } template - atInt32 readValLittle(std::enable_if_t>* = nullptr) { + atInt32 readValLittle(typename std::enable_if::value>::type* = 0) { return readInt32Little(); } @@ -260,7 +260,7 @@ public: return utility::BigInt32(val); } template - atInt32 readValBig(std::enable_if_t>* = nullptr) { + atInt32 readValBig(typename std::enable_if::value>::type* = 0) { return readInt32Big(); } @@ -271,7 +271,7 @@ public: */ atUint32 readUint32() { return readInt32(); } template - atUint32 readVal(std::enable_if_t>* = nullptr) { + atUint32 readVal(typename std::enable_if::value>::type* = 0) { return readUint32(); } @@ -286,7 +286,7 @@ public: return utility::LittleUint32(val); } template - atInt32 readValLittle(std::enable_if_t>* = nullptr) { + atInt32 readValLittle(typename std::enable_if::value>::type* = 0) { return readUint32Little(); } @@ -301,7 +301,7 @@ public: return utility::BigUint32(val); } template - atUint32 readValBig(std::enable_if_t>* = nullptr) { + atUint32 readValBig(typename std::enable_if::value>::type* = 0) { return readUint32Big(); } @@ -316,7 +316,7 @@ public: return m_endian == Big ? utility::BigInt64(val) : utility::LittleInt64(val); } template - atInt64 readVal(std::enable_if_t>* = nullptr) { + atInt64 readVal(typename std::enable_if::value>::type* = 0) { return readInt64(); } @@ -331,7 +331,7 @@ public: return utility::LittleInt64(val); } template - atInt64 readValLittle(std::enable_if_t>* = nullptr) { + atInt64 readValLittle(typename std::enable_if::value>::type* = 0) { return readInt64Little(); } @@ -346,7 +346,7 @@ public: return utility::BigInt64(val); } template - atInt64 readValBig(std::enable_if_t>* = nullptr) { + atInt64 readValBig(typename std::enable_if::value>::type* = 0) { return readInt64Big(); } @@ -357,7 +357,7 @@ public: */ atUint64 readUint64() { return readInt64(); } template - atUint64 readVal(std::enable_if_t>* = nullptr) { + atUint64 readVal(typename std::enable_if::value>::type* = 0) { return readUint64(); } @@ -372,7 +372,7 @@ public: return utility::LittleUint64(val); } template - atUint64 readValLittle(std::enable_if_t>* = nullptr) { + atUint64 readValLittle(typename std::enable_if::value>::type* = 0) { return readUint64Little(); } @@ -387,7 +387,7 @@ public: return utility::BigUint64(val); } template - atUint64 readValBig(std::enable_if_t>* = nullptr) { + atUint64 readValBig(typename std::enable_if::value>::type* = 0) { return readUint64Big(); } @@ -402,7 +402,7 @@ public: return m_endian == Big ? utility::BigFloat(val) : utility::LittleFloat(val); } template - float readVal(std::enable_if_t>* = nullptr) { + float readVal(typename std::enable_if::value>::type* = 0) { return readFloat(); } @@ -417,7 +417,7 @@ public: return utility::LittleFloat(val); } template - float readValLittle(std::enable_if_t>* = nullptr) { + float readValLittle(typename std::enable_if::value>::type* = 0) { return readFloatLittle(); } @@ -432,7 +432,7 @@ public: return utility::BigFloat(val); } template - float readValBig(std::enable_if_t>* = nullptr) { + float readValBig(typename std::enable_if::value>::type* = 0) { return readFloatBig(); } @@ -447,7 +447,7 @@ public: return m_endian == Big ? utility::BigDouble(val) : utility::LittleDouble(val); } template - double readVal(std::enable_if_t>* = nullptr) { + double readVal(typename std::enable_if::value>::type* = 0) { return readDouble(); } @@ -462,7 +462,7 @@ public: return utility::LittleDouble(val); } template - double readValLittle(std::enable_if_t>* = nullptr) { + double readValLittle(typename std::enable_if::value>::type* = 0) { return readDoubleLittle(); } @@ -477,7 +477,7 @@ public: return utility::BigDouble(val); } template - double readValBig(std::enable_if_t>* = nullptr) { + double readValBig(typename std::enable_if::value>::type* = 0) { return readDoubleBig(); } @@ -491,15 +491,15 @@ public: return val != 0; } template - bool readVal(std::enable_if_t>* = nullptr) { + bool readVal(typename std::enable_if::value>::type* = 0) { return readBool(); } template - bool readValLittle(std::enable_if_t>* = nullptr) { + bool readValLittle(typename std::enable_if::value>::type* = 0) { return readBool(); } template - bool readValBig(std::enable_if_t>* = nullptr) { + bool readValBig(typename std::enable_if::value>::type* = 0) { return readBool(); } @@ -525,7 +525,7 @@ public: return s; } template - atVec2f readVal(std::enable_if_t>* = nullptr) { + atVec2f readVal(typename std::enable_if::value>::type* = 0) { return readVec2f(); } @@ -546,7 +546,7 @@ public: return s; } template - atVec2f readValLittle(std::enable_if_t>* = nullptr) { + atVec2f readValLittle(typename std::enable_if::value>::type* = 0) { return readVec2fLittle(); } @@ -567,7 +567,7 @@ public: return s; } template - atVec2f readValBig(std::enable_if_t>* = nullptr) { + atVec2f readValBig(typename std::enable_if::value>::type* = 0) { return readVec2fBig(); } @@ -594,7 +594,7 @@ public: return s; } template - atVec3f readVal(std::enable_if_t>* = nullptr) { + atVec3f readVal(typename std::enable_if::value>::type* = 0) { return readVec3f(); } @@ -615,7 +615,7 @@ public: return s; } template - atVec3f readValLittle(std::enable_if_t>* = nullptr) { + atVec3f readValLittle(typename std::enable_if::value>::type* = 0) { return readVec3fLittle(); } @@ -636,7 +636,7 @@ public: return s; } template - atVec3f readValBig(std::enable_if_t>* = nullptr) { + atVec3f readValBig(typename std::enable_if::value>::type* = 0) { return readVec3fBig(); } @@ -664,7 +664,7 @@ public: return s; } template - atVec4f readVal(std::enable_if_t>* = nullptr) { + atVec4f readVal(typename std::enable_if::value>::type* = 0) { return readVec4f(); } @@ -685,7 +685,7 @@ public: return s; } template - atVec4f readValLittle(std::enable_if_t>* = nullptr) { + atVec4f readValLittle(typename std::enable_if::value>::type* = 0) { return readVec4fLittle(); } @@ -706,7 +706,7 @@ public: return s; } template - atVec4f readValBig(std::enable_if_t>* = nullptr) { + atVec4f readValBig(typename std::enable_if::value>::type* = 0) { return readVec4fBig(); } @@ -732,7 +732,7 @@ public: return s; } template - atVec2d readVal(std::enable_if_t>* = nullptr) { + atVec2d readVal(typename std::enable_if::value>::type* = 0) { return readVec2d(); } @@ -753,7 +753,7 @@ public: return s; } template - atVec2d readValLittle(std::enable_if_t>* = nullptr) { + atVec2d readValLittle(typename std::enable_if::value>::type* = 0) { return readVec2dLittle(); } @@ -774,7 +774,7 @@ public: return s; } template - atVec2d readValBig(std::enable_if_t>* = nullptr) { + atVec2d readValBig(typename std::enable_if::value>::type* = 0) { return readVec2dBig(); } @@ -801,7 +801,7 @@ public: return s; } template - atVec3d readVal(std::enable_if_t>* = nullptr) { + atVec3d readVal(typename std::enable_if::value>::type* = 0) { return readVec3d(); } @@ -822,7 +822,7 @@ public: return s; } template - atVec3d readValLittle(std::enable_if_t>* = nullptr) { + atVec3d readValLittle(typename std::enable_if::value>::type* = 0) { return readVec3dLittle(); } @@ -843,7 +843,7 @@ public: return s; } template - atVec3d readValBig(std::enable_if_t>* = nullptr) { + atVec3d readValBig(typename std::enable_if::value>::type* = 0) { return readVec3dBig(); } @@ -871,7 +871,7 @@ public: return s; } template - atVec4d readVal(std::enable_if_t>* = nullptr) { + atVec4d readVal(typename std::enable_if::value>::type* = 0) { return readVec4d(); } @@ -892,7 +892,7 @@ public: return s; } template - atVec4d readValLittle(std::enable_if_t>* = nullptr) { + atVec4d readValLittle(typename std::enable_if::value>::type* = 0) { return readVec4dLittle(); } @@ -913,7 +913,7 @@ public: return s; } template - atVec4d readValBig(std::enable_if_t>* = nullptr) { + atVec4d readValBig(typename std::enable_if::value>::type* = 0) { return readVec4dBig(); } @@ -944,7 +944,7 @@ public: return ret; } template - std::string readVal(std::enable_if_t>* = nullptr) { + std::string readVal(typename std::enable_if::value>::type* = 0) { return readString(); } @@ -976,7 +976,7 @@ public: return ret; } template - std::wstring readVal(std::enable_if_t>* = nullptr) { + std::wstring readVal(typename std::enable_if::value>::type* = 0) { return readWString(); } @@ -1009,7 +1009,7 @@ public: return ret; } template - std::wstring readValLittle(std::enable_if_t>* = nullptr) { + std::wstring readValLittle(typename std::enable_if::value>::type* = 0) { return readWStringLittle(); } @@ -1041,7 +1041,7 @@ public: return ret; } template - std::wstring readValBig(std::enable_if_t>* = nullptr) { + std::wstring readValBig(typename std::enable_if::value>::type* = 0) { return readWStringBig(); } @@ -1073,7 +1073,7 @@ public: return ret; } template - std::u16string readValBig(std::enable_if_t>* = nullptr) { + std::u16string readValBig(typename std::enable_if::value>::type* = 0) { return readU16StringBig(); } @@ -1105,7 +1105,7 @@ public: return ret; } template - std::u32string readValBig(std::enable_if_t>* = nullptr) { + std::u32string readValBig(typename std::enable_if::value>::type* = 0) { return readU32StringBig(); } @@ -1119,8 +1119,8 @@ public: template void enumerate(std::vector& vector, size_t count, - std::enable_if || std::is_same_v || - std::is_same_v || std::is_same_v>* = nullptr) { + typename std::enable_if::value || std::is_same::value || + std::is_same::value || std::is_same::value>::type* = 0) { vector.clear(); vector.reserve(count); for (size_t i = 0; i < count; ++i) @@ -1135,9 +1135,10 @@ public: * Endianness is little */ template - void enumerateLittle(std::vector& vector, size_t count, - std::enable_if_t || std::is_same_v || - std::is_same_v || std::is_same_v>* = nullptr) { + void enumerateLittle( + std::vector& vector, size_t count, + typename std::enable_if::value || std::is_same::value || + std::is_same::value || std::is_same::value>::type* = 0) { vector.clear(); vector.reserve(count); for (size_t i = 0; i < count; ++i) @@ -1152,9 +1153,10 @@ public: * Endianness is big */ template - void enumerateBig(std::vector& vector, size_t count, - std::enable_if_t || std::is_same_v || - std::is_same_v || std::is_same_v>* = nullptr) { + void + enumerateBig(std::vector& vector, size_t count, + typename std::enable_if::value || std::is_same::value || + std::is_same::value || std::is_same::value>::type* = 0) { vector.clear(); vector.reserve(count); for (size_t i = 0; i < count; ++i) @@ -1167,9 +1169,10 @@ public: * @param count The number of elements to read into vector */ template - void enumerate(std::vector& vector, size_t count, - std::enable_if_t && !std::is_same_v && - !std::is_same_v && !std::is_same_v>* = nullptr) { + void + enumerate(std::vector& vector, size_t count, + typename std::enable_if::value && !std::is_same::value && + !std::is_same::value && !std::is_same::value>::type* = 0) { vector.clear(); vector.reserve(count); for (size_t i = 0; i < count; ++i) { diff --git a/include/athena/IStreamWriter.hpp b/include/athena/IStreamWriter.hpp index 5dcfe20..edfd34e 100644 --- a/include/athena/IStreamWriter.hpp +++ b/include/athena/IStreamWriter.hpp @@ -9,14 +9,14 @@ namespace athena::io { class IStreamWriter : public IStream { public: - ~IStreamWriter() override = default; + virtual ~IStreamWriter() = default; /** @brief Sets the buffers position relative to the specified position.
* It seeks relative to the current position by default. * @param position where in the buffer to seek * @param origin The location to seek relative to */ - void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override = 0; + virtual void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) = 0; /** @brief Sets the buffers position relative to the next 32-byte aligned position.
*/ @@ -36,19 +36,19 @@ public: * * @return True if at end; False otherwise. */ - bool atEnd() const override { return position() >= length(); } + bool atEnd() const { return position() >= length(); } /** @brief Returns the current position in the stream. * * @return The current position in the stream. */ - atUint64 position() const override = 0; + virtual atUint64 position() const = 0; /** @brief Returns whether or not the stream is at the end. * * @return True if at end; False otherwise. */ - atUint64 length() const override = 0; + virtual atUint64 length() const = 0; /** @brief Writes a byte at the current position and advances the position by one byte. * @param val The value to write @@ -989,9 +989,10 @@ public: * Endianness is set with setEndian */ template - void enumerate(const std::vector& vector, - std::enable_if_t || std::is_same_v || std::is_same_v || - std::is_same_v>* = nullptr) { + void + enumerate(const std::vector& vector, + typename std::enable_if::value || std::is_same::value || + std::is_same::value || std::is_same::value>::type* = 0) { for (const T& item : vector) writeVal(item); } @@ -1002,9 +1003,10 @@ public: * Endianness is little */ template - void enumerateLittle(const std::vector& vector, - std::enable_if_t || std::is_same_v || - std::is_same_v || std::is_same_v>* = nullptr) { + void enumerateLittle( + const std::vector& vector, + typename std::enable_if::value || std::is_same::value || + std::is_same::value || std::is_same::value>::type* = 0) { for (const T& item : vector) writeValLittle(item); } @@ -1015,9 +1017,10 @@ public: * Endianness is big */ template - void enumerateBig(const std::vector& vector, - std::enable_if_t || std::is_same_v || - std::is_same_v || std::is_same_v>* = nullptr) { + void + enumerateBig(const std::vector& vector, + typename std::enable_if::value || std::is_same::value || + std::is_same::value || std::is_same::value>::type* = 0) { for (const T& item : vector) writeValBig(item); } @@ -1026,9 +1029,10 @@ public: * @param vector The std::vector read from when writing data */ template - void enumerate(const std::vector& vector, - std::enable_if_t && !std::is_same_v && - !std::is_same_v && !std::is_same_v>* = nullptr) { + void + enumerate(const std::vector& vector, + typename std::enable_if::value && !std::is_same::value && + !std::is_same::value && !std::is_same::value>::type* = 0) { for (const T& item : vector) item.write(*this); } diff --git a/include/athena/MemoryReader.hpp b/include/athena/MemoryReader.hpp index 6d7064a..1a82c27 100644 --- a/include/athena/MemoryReader.hpp +++ b/include/athena/MemoryReader.hpp @@ -19,7 +19,7 @@ protected: MemoryReader() = default; public: - ~MemoryReader() override; + virtual ~MemoryReader(); /*! \brief This constructor references an existing buffer to read from. * @@ -34,19 +34,19 @@ public: * \param position where in the buffer to seek * \param origin The Origin to seek \sa SeekOrigin */ - void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override; + void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current); /*! \brief Returns the current position in the stream. * * \return Int64 The current position in the stream. */ - atUint64 position() const override { return m_position; } + inline atUint64 position() const { return m_position; } /*! \brief Returns whether or not the stream is at the end. * * \return bool True if at end; False otherwise. */ - atUint64 length() const override { return m_length; } + inline atUint64 length() const { return m_length; } /*! \brief Sets the buffer to the given one, deleting the current one.
* BEWARE: As this deletes the current buffer it WILL cause a loss of data @@ -74,7 +74,7 @@ public: * \param len Length to read * \return Number of bytes read */ - atUint64 readUBytesToBuf(void* buf, atUint64 len) override; + atUint64 readUBytesToBuf(void* buf, atUint64 len); protected: const void* m_data = nullptr; diff --git a/include/athena/MemoryWriter.hpp b/include/athena/MemoryWriter.hpp index b18a9bc..28c4d23 100644 --- a/include/athena/MemoryWriter.hpp +++ b/include/athena/MemoryWriter.hpp @@ -17,7 +17,7 @@ namespace athena::io { */ class MemoryWriter : public IStreamWriter { public: - ~MemoryWriter() override; + virtual ~MemoryWriter(); /*! @brief This constructor references an existing buffer to write to in-place. * @@ -31,21 +31,21 @@ public: * @param position where in the buffer to seek * @param origin The Origin to seek @sa SeekOrigin */ - void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override; + void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current); /*! @brief Returns the current position in the stream. * * @return Int64 The current position in the stream. */ - atUint64 position() const override { return m_position; } + inline atUint64 position() const { return m_position; } /*! @brief Returns the length of the stream. * * @return Int64 The length of the stream. */ - atUint64 length() const override { return m_length; } + inline atUint64 length() const { return m_length; } - bool isOpen() const { return true; } + inline bool isOpen() const { return true; } /** @brief Sets the buffer to the given one, deleting the current one if it owns it.
* @param data The new buffer. @@ -65,12 +65,12 @@ public: * * @param filepath The path to write to. */ - void setFilepath(const std::string& filepath) { m_filepath = filepath; } + inline void setFilepath(const std::string& filepath) { m_filepath = filepath; } /*! @brief * Returns the target file */ - std::string filepath() const { return m_filepath; } + inline std::string filepath() const { return m_filepath; } /*! @brief Saves the file to the specified file. * @@ -85,7 +85,7 @@ public: * @param data The buffer to write * @param length The amount to write */ - void writeUBytes(const atUint8* data, atUint64 len) override; + void writeUBytes(const atUint8* data, atUint64 len); protected: MemoryWriter() {} @@ -116,7 +116,7 @@ public: * @param position where in the buffer to seek * @param origin The Origin to seek @sa SeekOrigin */ - void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override; + void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current); /*! @brief Sets the buffer to the given one, deleting the current one.
* BEWARE: As this deletes the current buffer it WILL cause a loss of data @@ -135,7 +135,7 @@ public: * @param data The buffer to write * @param length The amount to write */ - void writeUBytes(const atUint8* data, atUint64 len) override; + void writeUBytes(const atUint8* data, atUint64 len); protected: std::unique_ptr m_dataCopy; diff --git a/include/athena/Utility.hpp b/include/athena/Utility.hpp index 1602564..e2c7c08 100644 --- a/include/athena/Utility.hpp +++ b/include/athena/Utility.hpp @@ -181,9 +181,9 @@ atUint64 rand64(); std::string join(const std::vector& elems, std::string_view delims); void tolower(std::string& str); void toupper(std::string& str); -bool parseBool(std::string_view boolean, bool* valid = nullptr); +bool parseBool(std::string_view boolean, bool* valid = NULL); -int countChar(std::string_view str, char chr, int* lastOccur = nullptr); +int countChar(std::string_view str, const char chr, int* lastOccur = NULL); // trim from start std::string& ltrim(std::string& s); diff --git a/include/athena/VectorWriter.hpp b/include/athena/VectorWriter.hpp index 7257812..f17e160 100644 --- a/include/athena/VectorWriter.hpp +++ b/include/athena/VectorWriter.hpp @@ -22,21 +22,21 @@ public: * @param position where in the buffer to seek * @param origin The Origin to seek @sa SeekOrigin */ - void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current) override; + void seek(atInt64 pos, SeekOrigin origin = SeekOrigin::Current); /*! @brief Returns the current position in the stream. * * @return Int64 The current position in the stream. */ - atUint64 position() const override { return m_position; } + inline atUint64 position() const { return m_position; } /*! @brief Returns the length of the stream. * * @return Int64 The length of the stream. */ - atUint64 length() const override { return m_data.size(); } + inline atUint64 length() const { return m_data.size(); } - bool isOpen() const { return true; } + inline bool isOpen() const { return true; } /*! @brief Obtains reference to underlying std::vector store */ const std::vector& data() const { return m_data; } @@ -48,7 +48,7 @@ public: * @param data The buffer to write * @param length The amount to write */ - void writeUBytes(const atUint8* data, atUint64 len) override; + void writeUBytes(const atUint8* data, atUint64 len); protected: std::vector m_data; diff --git a/include/athena/YAMLCommon.hpp b/include/athena/YAMLCommon.hpp index 01e56bd..7617b14 100644 --- a/include/athena/YAMLCommon.hpp +++ b/include/athena/YAMLCommon.hpp @@ -27,14 +27,14 @@ struct YAMLNode { YAMLNode(yaml_node_type_t type) : m_type(type) {} - const YAMLNode* findMapChild(std::string_view key) const { + inline const YAMLNode* findMapChild(std::string_view key) const { for (const auto& item : m_mapChildren) if (!item.first.compare(key)) return item.second.get(); return nullptr; } - void assignMapChild(std::string_view key, std::unique_ptr&& node) { + inline void assignMapChild(std::string_view key, std::unique_ptr&& node) { for (auto& item : m_mapChildren) if (!item.first.compare(key)) { item.second = std::move(node); diff --git a/include/athena/YAMLDocReader.hpp b/include/athena/YAMLDocReader.hpp index 45f160c..8fa4c00 100644 --- a/include/athena/YAMLDocReader.hpp +++ b/include/athena/YAMLDocReader.hpp @@ -19,15 +19,15 @@ public: void reset(); - yaml_parser_t* getParser() { return &m_parser; } + inline yaml_parser_t* getParser() { return &m_parser; } bool parse(athena::io::IStreamReader* reader); bool ClassTypeOperation(std::function func); bool ValidateClassType(const char* expectedType); - const YAMLNode* getRootNode() const { return m_rootNode.get(); } - const YAMLNode* getCurNode() const { return m_subStack.empty() ? nullptr : m_subStack.back(); } + inline const YAMLNode* getRootNode() const { return m_rootNode.get(); } + inline const YAMLNode* getCurNode() const { return m_subStack.empty() ? nullptr : m_subStack.back(); } std::unique_ptr releaseRootNode() { return std::move(m_rootNode); } class RecordRAII { @@ -54,7 +54,7 @@ public: RecordRAII enterSubRecord(const char* name); template - void enumerate(const char* name, T& record, std::enable_if_t<__IsDNARecord_v>* = nullptr) { + void enumerate(const char* name, T& record, typename std::enable_if_t<__IsDNARecord_v>* = 0) { if (auto rec = enterSubRecord(name)) record.read(*this); } @@ -77,9 +77,10 @@ public: VectorRAII enterSubVector(const char* name, size_t& countOut); template - size_t enumerate(const char* name, std::vector& vector, - std::enable_if_t && !std::is_same_v && - !std::is_same_v && !std::is_same_v>* = nullptr) { + size_t + enumerate(const char* name, std::vector& vector, + typename std::enable_if_t::value && !std::is_same::value && + !std::is_same::value && !std::is_same::value>* = 0) { size_t countOut; if (auto v = enterSubVector(name, countOut)) { vector.clear(); @@ -95,8 +96,8 @@ public: template size_t enumerate(const char* name, std::vector& vector, - std::enable_if_t || std::is_same_v || - std::is_same_v || std::is_same_v>* = nullptr) { + typename std::enable_if_t::value || std::is_same::value || + std::is_same::value || std::is_same::value>* = 0) { size_t countOut; if (auto v = enterSubVector(name, countOut)) { vector.clear(); diff --git a/include/athena/YAMLDocWriter.hpp b/include/athena/YAMLDocWriter.hpp index c590674..ae9cbc4 100644 --- a/include/athena/YAMLDocWriter.hpp +++ b/include/athena/YAMLDocWriter.hpp @@ -20,7 +20,7 @@ public: bool finish(athena::io::IStreamWriter* fout); - YAMLNode* getCurNode() const { return m_subStack.empty() ? nullptr : m_subStack.back(); } + inline YAMLNode* getCurNode() const { return m_subStack.empty() ? nullptr : m_subStack.back(); } class RecordRAII { friend class YAMLDocWriter; @@ -40,7 +40,7 @@ public: RecordRAII enterSubRecord(const char* name); template - void enumerate(const char* name, T& record, std::enable_if_t<__IsDNARecord_v>* = nullptr) { + void enumerate(const char* name, T& record, typename std::enable_if_t<__IsDNARecord_v>* = 0) { if (auto rec = enterSubRecord(name)) record.write(*this); } @@ -63,11 +63,11 @@ public: VectorRAII enterSubVector(const char* name); template - void - enumerate(const char* name, const std::vector& vector, - std::enable_if_t && !std::is_same_v && !std::is_same_v && - !std::is_same_v && !std::is_same_v && - !std::is_same_v && !std::is_same_v>* = nullptr) { + void enumerate(const char* name, const std::vector& vector, + typename std::enable_if_t::value && !std::is_same::value && + !std::is_same::value && !std::is_same::value && + !std::is_same::value && !std::is_same::value && + !std::is_same::value>* = 0) { if (auto v = enterSubVector(name)) for (const T& item : vector) if (auto rec = enterSubRecord(nullptr)) @@ -76,9 +76,10 @@ public: template void enumerate(const char* name, const std::vector& vector, - std::enable_if_t || std::is_same_v || std::is_same_v || - std::is_same_v || std::is_same_v || - std::is_same_v || std::is_same_v>* = nullptr) { + typename std::enable_if_t::value || std::is_same::value || + std::is_same::value || std::is_same::value || + std::is_same::value || std::is_same::value || + std::is_same::value>* = 0) { if (auto v = enterSubVector(name)) for (T item : vector) writeVal(nullptr, item); diff --git a/src/LZ77/LZType11.cpp b/src/LZ77/LZType11.cpp index de26bd8..41cee43 100644 --- a/src/LZ77/LZType11.cpp +++ b/src/LZ77/LZType11.cpp @@ -106,7 +106,7 @@ atUint32 LZType11::compress(const atUint8* src, atUint8** dst, atUint32 srcLengt } delete[] compressedBytes; - compressedBytes = nullptr; + compressedBytes = NULL; // Add zeros until the file is a multiple of 4 while ((outbuff.position() % 4) != 0) diff --git a/src/athena/Compression.cpp b/src/athena/Compression.cpp index ff23040..4f72837 100644 --- a/src/athena/Compression.cpp +++ b/src/athena/Compression.cpp @@ -10,7 +10,7 @@ namespace athena::io::Compression { atInt32 decompressZlib(const atUint8* src, atUint32 srcLen, atUint8* dst, atUint32 dstLen) { - z_stream strm = {}; + z_stream strm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; strm.total_in = strm.avail_in = srcLen; strm.total_out = strm.avail_out = dstLen; strm.next_in = (Bytef*)src; @@ -45,7 +45,7 @@ atInt32 decompressZlib(const atUint8* src, atUint32 srcLen, atUint8* dst, atUint } atInt32 compressZlib(const atUint8* src, atUint32 srcLen, atUint8* dst, atUint32 dstLen) { - z_stream strm = {}; + z_stream strm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; strm.total_in = strm.avail_in = srcLen; strm.total_out = strm.avail_out = dstLen; strm.next_in = (Bytef*)src; diff --git a/src/athena/Dir.cpp b/src/athena/Dir.cpp index c9d6d98..6f6a02c 100644 --- a/src/athena/Dir.cpp +++ b/src/athena/Dir.cpp @@ -45,7 +45,7 @@ bool Dir::cd(std::string_view path) { bool Dir::rm(std::string_view path) { return !(remove((m_path + "/" + path.data()).c_str()) < 0); } bool Dir::touch() { - std::srand(std::time(nullptr)); + srand(time(NULL)); atUint64 tmp = utility::rand64(); std::string tmpFile = fmt::format(fmt("{:016X}.tmp"), tmp); bool ret = FileInfo(m_path + "/" + tmpFile).touch(); diff --git a/src/athena/FileInfo.cpp b/src/athena/FileInfo.cpp index d78913c..fb47e01 100644 --- a/src/athena/FileInfo.cpp +++ b/src/athena/FileInfo.cpp @@ -104,7 +104,7 @@ bool FileInfo::touch() const { (void)athena::io::FileWriter(m_path); return true; } - if (utimes(m_path.c_str(), nullptr) < 0) { + if (utimes(m_path.c_str(), NULL) < 0) { return false; } #elif defined(_WIN32) @@ -114,7 +114,7 @@ bool FileInfo::touch() const { wchar_t date[80], time[80]; #if !WINDOWS_STORE - fh = CreateFileA(m_path.c_str(), GENERIC_READ | FILE_WRITE_ATTRIBUTES, 0, nullptr, CREATE_NEW, 0, nullptr); + fh = CreateFileA(m_path.c_str(), GENERIC_READ | FILE_WRITE_ATTRIBUTES, 0, NULL, CREATE_NEW, 0, NULL); if (fh == INVALID_HANDLE_VALUE) return false; @@ -122,14 +122,14 @@ bool FileInfo::touch() const { /* * Use GetFileTime() to get the file modification time. */ - if (GetFileTime(fh, nullptr, nullptr, &modtime) == 0) { + if (GetFileTime(fh, NULL, NULL, &modtime) == 0) { CloseHandle(fh); return false; } FileTimeToSystemTime(&modtime, &st); - if (GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, nullptr, date, sizeof date / sizeof date[0]) == 0 || - GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, nullptr, time, sizeof time / sizeof time[0]) == 0) { + if (GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, date, sizeof date / sizeof date[0]) == 0 || + GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, time, sizeof time / sizeof time[0]) == 0) { CloseHandle(fh); return false; } @@ -139,13 +139,13 @@ bool FileInfo::touch() const { * to the current time. */ GetSystemTime(&st); - if (GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, nullptr, date, sizeof date / sizeof date[0]) == 0 || - GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, nullptr, time, sizeof time / sizeof time[0]) == 0) { + if (GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, date, sizeof date / sizeof date[0]) == 0 || + GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, time, sizeof time / sizeof time[0]) == 0) { CloseHandle(fh); return false; } SystemTimeToFileTime(&st, &modtime); - if (SetFileTime(fh, nullptr, nullptr, &modtime) == 0) { + if (SetFileTime(fh, NULL, NULL, &modtime) == 0) { CloseHandle(fh); return false; } diff --git a/src/athena/Socket.cpp b/src/athena/Socket.cpp index 129972a..8f2f7c4 100644 --- a/src/athena/Socket.cpp +++ b/src/athena/Socket.cpp @@ -45,8 +45,8 @@ void IPAddress::resolve(const std::string& address) { addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; - addrinfo* result = nullptr; - if (getaddrinfo(address.c_str(), nullptr, &hints, &result) == 0) { + addrinfo* result = NULL; + if (getaddrinfo(address.c_str(), NULL, &hints, &result) == 0) { if (result) { addr = reinterpret_cast(result->ai_addr)->sin_addr; freeaddrinfo(result); diff --git a/src/athena/Utility.cpp b/src/athena/Utility.cpp index c0665fc..da36334 100644 --- a/src/athena/Utility.cpp +++ b/src/athena/Utility.cpp @@ -100,7 +100,7 @@ int countChar(std::string_view str, const char chr, int* lastOccur) { for (char c : str) { if (c == chr) { - if (lastOccur != nullptr) + if (lastOccur != NULL) *lastOccur = index; ret++;