diff --git a/.cache/clangd/index/Main.cpp.8DF821074DA7C9F4.idx b/.cache/clangd/index/Main.cpp.8DF821074DA7C9F4.idx index d0860d6..b88810d 100644 Binary files a/.cache/clangd/index/Main.cpp.8DF821074DA7C9F4.idx and b/.cache/clangd/index/Main.cpp.8DF821074DA7C9F4.idx differ diff --git a/Src/IACore/imp/inl/iacore/StreamReader/Interface/StreamReader.interface.inl b/Src/IACore/imp/inl/iacore/StreamReader/Interface/StreamReader.interface.inl new file mode 100644 index 0000000..9e79dcd --- /dev/null +++ b/Src/IACore/imp/inl/iacore/StreamReader/Interface/StreamReader.interface.inl @@ -0,0 +1,136 @@ +// IACore-OSS; The Core Library for All IA Open Source Projects +// Copyright (C) 2024 IAS (ias@iasoft.dev) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#pragma once + +namespace ia +{ + class IStreamReader + { + public: + STATIC SharedPtr Create(IN PCCHAR filePath); + STATIC SharedPtr Create(IN Vector &&data); + + public: + PURE_VIRTUAL(BOOL CompareBytes(IN PCUINT8 data, IN INT64 length) CONST); + + PURE_VIRTUAL(Vector Read()); + PURE_VIRTUAL(Vector Read(IN INT64 size)); + PURE_VIRTUAL(VOID Read(IN INT64 size, IN PUINT8 buffer)); + + PURE_VIRTUAL(UINT8 Read8()); + PURE_VIRTUAL(UINT16 Read16()); + PURE_VIRTUAL(UINT32 Read32()); + PURE_VIRTUAL(UINT64 Read64()); + + PURE_VIRTUAL(VOID Skip(IN INT64 size)); + PURE_VIRTUAL(INT64 Cursor() CONST); + PURE_VIRTUAL(VOID Seek(IN INT64 newCursor)); + }; + + class MemoryStreamReader : public IStreamReader + { + public: + STATIC SharedPtr Create(IN Vector &&data); + + public: + BOOL CompareBytes(IN PCUINT8 data, IN INT64 length) CONST; + + Vector Read(); + Vector Read(IN INT64 size); + VOID Read(IN INT64 size, IN PUINT8 buffer); + Vector ReadAndInflate(IN INT64 size); + + UINT8 Read8(); + UINT16 Read16(); + UINT32 Read32(); + UINT64 Read64(); + + VOID Skip(IN INT64 size) + { + m_cursor += size; + } + + INT64 Cursor() CONST + { + return m_cursor; + } + + VOID Seek(IN INT64 newCursor) + { + m_cursor = newCursor; + } + + private: + INT64 m_cursor{}; + Vector m_buffer; + + private: + MemoryStreamReader(IN Vector &&data); + }; + + class FileStreamReader : public IStreamReader + { + public: + STATIC SharedPtr Create(IN PCCHAR filePath); + + ~FileStreamReader(); + + public: + BOOL CompareBytes(IN PCUINT8 data, IN INT64 length) CONST; + + Vector Read(); + Vector Read(IN INT64 size); + VOID Read(IN INT64 size, IN PUINT8 buffer); + Vector ReadAndInflate(IN INT64 size); + + UINT8 Read8(); + UINT16 Read16(); + UINT32 Read32(); + UINT64 Read64(); + + VOID Skip(IN INT64 size) + { + fseek(m_filePtr, ftell(m_filePtr) + size, SEEK_SET); + } + + INT64 Cursor() CONST + { + return ftell(m_filePtr); + } + + VOID Seek(IN INT64 newCursor) + { + fseek(m_filePtr, newCursor, SEEK_SET); + } + + private: + FILE *m_filePtr{}; + + private: + FileStreamReader(IN PCCHAR filePath); + }; + + SharedPtr IStreamReader::Create(IN PCCHAR filePath) + { + return FileStreamReader::Create(filePath); + } + + SharedPtr IStreamReader::Create(IN Vector &&data) + { + return MemoryStreamReader::Create(std::move(data)); + } +} // namespace ia \ No newline at end of file diff --git a/Src/IACore/imp/inl/iacore/StreamReader/StreamReader.inl b/Src/IACore/imp/inl/iacore/StreamReader/StreamReader.inl new file mode 100644 index 0000000..eb85b09 --- /dev/null +++ b/Src/IACore/imp/inl/iacore/StreamReader/StreamReader.inl @@ -0,0 +1,209 @@ +// IACore-OSS; The Core Library for All IA Open Source Projects +// Copyright (C) 2024 IAS (ias@iasoft.dev) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#pragma once + +#include "interface/StreamReader.interface.inl" + +namespace ia +{ + SharedPtr MemoryStreamReader::Create(IN Vector &&data) + { + struct make_shared_enabler : public MemoryStreamReader + { + make_shared_enabler(IN Vector &&data) : MemoryStreamReader(std::move(data)) + { + } + }; + + return std::make_shared(std::move(data)); + } + + MemoryStreamReader::MemoryStreamReader(IN Vector &&data) : m_buffer(std::move(data)) + { + m_cursor = 0; + } + + BOOL MemoryStreamReader::CompareBytes(IN PCUINT8 data, IN INT64 length) const + { + DXF_ASSERT((m_cursor + length) <= m_buffer.size()); + return !memcmp(&m_buffer[m_cursor], data, length); + } + + Vector MemoryStreamReader::Read() + { + Vector res; + res.resize(m_buffer.size() - m_cursor); + Read(res.size(), res.data()); + return res; + } + + Vector MemoryStreamReader::Read(IN INT64 size) + { + Vector res; + res.resize(size); + Read(size, res.data()); + return res; + } + + VOID MemoryStreamReader::Read(IN INT64 size, IN PUINT8 buffer) + { + DXF_ASSERT((m_cursor + size) <= m_buffer.size()); + memcpy_s(buffer, size, &m_buffer[m_cursor], size); + m_cursor += size; + } + + Vector MemoryStreamReader::ReadAndInflate(IN INT64 size) + { + const auto d = Read(size); + return Inflate(d.data(), d.size()); + } + + UINT8 MemoryStreamReader::Read8() + { + DXF_ASSERT((m_cursor + 1) <= m_buffer.size()); + return m_buffer[m_cursor++]; + } + + UINT16 MemoryStreamReader::Read16() + { + DXF_ASSERT((m_cursor + 2) <= m_buffer.size()); + const auto r = *reinterpret_cast(&m_buffer[m_cursor]); + m_cursor += 2; + return r; + } + + UINT32 MemoryStreamReader::Read32() + { + DXF_ASSERT((m_cursor + 4) <= m_buffer.size()); + const auto r = *reinterpret_cast(&m_buffer[m_cursor]); + m_cursor += 4; + return r; + } + + UINT64 MemoryStreamReader::Read64() + { + DXF_ASSERT((m_cursor + 8) <= m_buffer.size()); + const auto r = *reinterpret_cast(&m_buffer[m_cursor]); + m_cursor += 8; + return r; + } +} // namespace ia + +namespace ia +{ + SharedPtr FileStreamReader::Create(IN PCCHAR filePath) + { + struct make_shared_enabler : public FileStreamReader + { + make_shared_enabler(IN PCCHAR filePath) : FileStreamReader(filePath) + { + } + }; + + return std::make_shared(filePath); + } + + FileStreamReader::FileStreamReader(IN PCCHAR filePath) + { + fopen_s(&m_filePtr, filePath, "rb"); + if (!m_filePtr) + throw RuntimeError(BuildString("No such file or directory: ", filePath)); + } + + FileStreamReader ::~FileStreamReader() + { + if (m_filePtr) + fclose(m_filePtr); + } + + BOOL FileStreamReader::CompareBytes(IN PCUINT8 data, IN INT64 length) CONST + { + DXF_RELEASE_ASSERT(m_filePtr); + STATIC Vector TmpBuffer; + if (TmpBuffer.size() < length) + TmpBuffer.resize(length); + DXF_RELEASE_ASSERT(fread(TmpBuffer.data(), 1, length, m_filePtr) == length); + return !memcmp(TmpBuffer.data(), data, length); + } + + Vector FileStreamReader::Read() + { + DXF_RELEASE_ASSERT(m_filePtr); + Vector result; + const auto s = ftell(m_filePtr); + fseek(m_filePtr, 0, SEEK_END); + const auto e = ftell(m_filePtr); + fseek(m_filePtr, s, SEEK_SET); + result.resize(e - s); + DXF_RELEASE_ASSERT(fread(result.data(), 1, result.size(), m_filePtr) == result.size()); + return result; + } + + Vector FileStreamReader::Read(IN INT64 size) + { + DXF_RELEASE_ASSERT(m_filePtr); + Vector result; + result.resize(size); + DXF_RELEASE_ASSERT(fread(result.data(), 1, size, m_filePtr) == size); + return result; + } + + VOID FileStreamReader::Read(IN INT64 size, IN PUINT8 buffer) + { + DXF_RELEASE_ASSERT(m_filePtr); + DXF_RELEASE_ASSERT(fread(buffer, 1, size, m_filePtr) == size); + } + + Vector FileStreamReader::ReadAndInflate(IN INT64 size) + { + DXF_RELEASE_ASSERT(m_filePtr); + const auto d = Read(size); + return Inflate(d.data(), d.size()); + } + + UINT8 FileStreamReader::Read8() + { + DXF_RELEASE_ASSERT(m_filePtr); + UINT8 result; + DXF_RELEASE_ASSERT(fread(&result, 1, 1, m_filePtr) == 1); + return result; + } + + UINT16 FileStreamReader::Read16() + { + DXF_RELEASE_ASSERT(m_filePtr); + UINT16 result; + DXF_RELEASE_ASSERT(fread(&result, 2, 1, m_filePtr) == 1); + return result; + } + + UINT32 FileStreamReader::Read32() + { + DXF_RELEASE_ASSERT(m_filePtr); + UINT32 result; + DXF_RELEASE_ASSERT(fread(&result, 4, 1, m_filePtr) == 1); + return result; + } + + UINT64 FileStreamReader::Read64() + { + DXF_RELEASE_ASSERT(m_filePtr); + UINT64 result; + DXF_RELEASE_ASSERT(fread(&result, 8, 1, m_filePtr) == 1); + return result; + } +} // namespace ia \ No newline at end of file diff --git a/Src/IACore/imp/inl/iacore/algorithm/interface/binary-search.interface.inl b/Src/IACore/imp/inl/iacore/algorithm/interface/binary-search.interface.inl index 076d1c5..846d273 100644 --- a/Src/IACore/imp/inl/iacore/algorithm/interface/binary-search.interface.inl +++ b/Src/IACore/imp/inl/iacore/algorithm/interface/binary-search.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/algorithm/interface/quick-sort.interface.inl b/Src/IACore/imp/inl/iacore/algorithm/interface/quick-sort.interface.inl index 40505ef..cf96f5d 100644 --- a/Src/IACore/imp/inl/iacore/algorithm/interface/quick-sort.interface.inl +++ b/Src/IACore/imp/inl/iacore/algorithm/interface/quick-sort.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/array/interface/array.interface.inl b/Src/IACore/imp/inl/iacore/array/interface/array.interface.inl index d43cc10..b46baf7 100644 --- a/Src/IACore/imp/inl/iacore/array/interface/array.interface.inl +++ b/Src/IACore/imp/inl/iacore/array/interface/array.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/bytestring/interface/bytestring.interface.inl b/Src/IACore/imp/inl/iacore/bytestring/interface/bytestring.interface.inl index fb6be0c..309f6be 100644 --- a/Src/IACore/imp/inl/iacore/bytestring/interface/bytestring.interface.inl +++ b/Src/IACore/imp/inl/iacore/bytestring/interface/bytestring.interface.inl @@ -16,8 +16,8 @@ #pragma once -#include -#include +#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/container/interface/fixed.interface.inl b/Src/IACore/imp/inl/iacore/container/interface/fixed.interface.inl index f292f25..d57df31 100644 --- a/Src/IACore/imp/inl/iacore/container/interface/fixed.interface.inl +++ b/Src/IACore/imp/inl/iacore/container/interface/fixed.interface.inl @@ -16,8 +16,8 @@ #pragma once -#include -#include +#include +#include #include "span.interface.inl" diff --git a/Src/IACore/imp/inl/iacore/container/interface/iterator.interface.inl b/Src/IACore/imp/inl/iacore/container/interface/iterator.interface.inl index 1c95cbb..0a7c0a0 100644 --- a/Src/IACore/imp/inl/iacore/container/interface/iterator.interface.inl +++ b/Src/IACore/imp/inl/iacore/container/interface/iterator.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/container/interface/span.interface.inl b/Src/IACore/imp/inl/iacore/container/interface/span.interface.inl index 568ead8..03d5fa3 100644 --- a/Src/IACore/imp/inl/iacore/container/interface/span.interface.inl +++ b/Src/IACore/imp/inl/iacore/container/interface/span.interface.inl @@ -16,9 +16,9 @@ #pragma once -#include -#include -#include +#include +#include +#include #include "iterator.interface.inl" diff --git a/Src/IACore/imp/inl/iacore/hashable/interface/iihashable.interface.inl b/Src/IACore/imp/inl/iacore/hashable/interface/iihashable.interface.inl index fd58c7d..e61fdf0 100644 --- a/Src/IACore/imp/inl/iacore/hashable/interface/iihashable.interface.inl +++ b/Src/IACore/imp/inl/iacore/hashable/interface/iihashable.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/iterator/interface/iterator.interface.inl b/Src/IACore/imp/inl/iacore/iterator/interface/iterator.interface.inl index 91e7bf0..1a14786 100644 --- a/Src/IACore/imp/inl/iacore/iterator/interface/iterator.interface.inl +++ b/Src/IACore/imp/inl/iacore/iterator/interface/iterator.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/lib/interface/math.interface.inl b/Src/IACore/imp/inl/iacore/lib/interface/math.interface.inl index a856364..1b72a5d 100644 --- a/Src/IACore/imp/inl/iacore/lib/interface/math.interface.inl +++ b/Src/IACore/imp/inl/iacore/lib/interface/math.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/lib/interface/mem.interface.inl b/Src/IACore/imp/inl/iacore/lib/interface/mem.interface.inl index c4ab32f..7038bd3 100644 --- a/Src/IACore/imp/inl/iacore/lib/interface/mem.interface.inl +++ b/Src/IACore/imp/inl/iacore/lib/interface/mem.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include /* * ----------------------------------- diff --git a/Src/IACore/imp/inl/iacore/lib/interface/str.interface.inl b/Src/IACore/imp/inl/iacore/lib/interface/str.interface.inl index 5da08f5..9fb752f 100644 --- a/Src/IACore/imp/inl/iacore/lib/interface/str.interface.inl +++ b/Src/IACore/imp/inl/iacore/lib/interface/str.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include /* * ----------------------------------- diff --git a/Src/IACore/imp/inl/iacore/list/interface/entry.interface.inl b/Src/IACore/imp/inl/iacore/list/interface/entry.interface.inl index a54e3d4..4ffef63 100644 --- a/Src/IACore/imp/inl/iacore/list/interface/entry.interface.inl +++ b/Src/IACore/imp/inl/iacore/list/interface/entry.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/list/interface/list.interface.inl b/Src/IACore/imp/inl/iacore/list/interface/list.interface.inl index c3e8df8..c89a53e 100644 --- a/Src/IACore/imp/inl/iacore/list/interface/list.interface.inl +++ b/Src/IACore/imp/inl/iacore/list/interface/list.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include //#include "iterator.interface.inl" #include "entry.interface.inl" diff --git a/Src/IACore/imp/inl/iacore/map/interface/map.interface.inl b/Src/IACore/imp/inl/iacore/map/interface/map.interface.inl index 3a1ff12..71099fd 100644 --- a/Src/IACore/imp/inl/iacore/map/interface/map.interface.inl +++ b/Src/IACore/imp/inl/iacore/map/interface/map.interface.inl @@ -16,9 +16,9 @@ #pragma once -#include -#include -#include +#include +#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/memory/allocator/interface/iiallocator.interface.inl b/Src/IACore/imp/inl/iacore/memory/allocator/interface/iiallocator.interface.inl index d3f98d8..ea84fef 100644 --- a/Src/IACore/imp/inl/iacore/memory/allocator/interface/iiallocator.interface.inl +++ b/Src/IACore/imp/inl/iacore/memory/allocator/interface/iiallocator.interface.inl @@ -17,7 +17,7 @@ #pragma once #include -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/memory/allocator/interface/orchestrator.interface.inl b/Src/IACore/imp/inl/iacore/memory/allocator/interface/orchestrator.interface.inl index 04befa3..17719ec 100644 --- a/Src/IACore/imp/inl/iacore/memory/allocator/interface/orchestrator.interface.inl +++ b/Src/IACore/imp/inl/iacore/memory/allocator/interface/orchestrator.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/memory/ptr/interface/refptr.interface.inl b/Src/IACore/imp/inl/iacore/memory/ptr/interface/refptr.interface.inl index d3b0ec5..bb943d1 100644 --- a/Src/IACore/imp/inl/iacore/memory/ptr/interface/refptr.interface.inl +++ b/Src/IACore/imp/inl/iacore/memory/ptr/interface/refptr.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include #include namespace ia diff --git a/Src/IACore/imp/inl/iacore/platform/interface/platform.interface.inl b/Src/IACore/imp/inl/iacore/platform/interface/platform.interface.inl index 5375b92..f335d11 100644 --- a/Src/IACore/imp/inl/iacore/platform/interface/platform.interface.inl +++ b/Src/IACore/imp/inl/iacore/platform/interface/platform.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/set/interface/set.interface.inl b/Src/IACore/imp/inl/iacore/set/interface/set.interface.inl index e22ac96..5b04a86 100644 --- a/Src/IACore/imp/inl/iacore/set/interface/set.interface.inl +++ b/Src/IACore/imp/inl/iacore/set/interface/set.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/string/interface/string.interface.inl b/Src/IACore/imp/inl/iacore/string/interface/string.interface.inl index 45f4dff..8770040 100644 --- a/Src/IACore/imp/inl/iacore/string/interface/string.interface.inl +++ b/Src/IACore/imp/inl/iacore/string/interface/string.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/vector/interface/unordered.interface.inl b/Src/IACore/imp/inl/iacore/vector/interface/unordered.interface.inl index 20e40aa..f4dd986 100644 --- a/Src/IACore/imp/inl/iacore/vector/interface/unordered.interface.inl +++ b/Src/IACore/imp/inl/iacore/vector/interface/unordered.interface.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/vector/ordered.inl b/Src/IACore/imp/inl/iacore/vector/ordered.inl index ae5acfe..cb0bbcb 100644 --- a/Src/IACore/imp/inl/iacore/vector/ordered.inl +++ b/Src/IACore/imp/inl/iacore/vector/ordered.inl @@ -16,7 +16,7 @@ #pragma once -#include +#include #include "interface/ordered.interface.inl" diff --git a/Src/IACore/imp/inl/iacore/xop/xop.inl b/Src/IACore/imp/inl/iacore/xop/xop.inl deleted file mode 100644 index 8e2c565..0000000 --- a/Src/IACore/imp/inl/iacore/xop/xop.inl +++ /dev/null @@ -1,24 +0,0 @@ -// IACore-OSS; The Core Library for All IA Open Source Projects -// Copyright (C) 2024 IAS (ias@iasoft.dev) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#pragma once - -#include "interface/xop.interface.inl" - -namespace ia -{ - // [IATODO: IMP] -} \ No newline at end of file diff --git a/Src/IACore/inc/hpp/iacore/log.hpp b/Src/IACore/inc/hpp/iacore/Logger.hpp similarity index 98% rename from Src/IACore/inc/hpp/iacore/log.hpp rename to Src/IACore/inc/hpp/iacore/Logger.hpp index f943cc5..0eb0551 100644 --- a/Src/IACore/inc/hpp/iacore/log.hpp +++ b/Src/IACore/inc/hpp/iacore/Logger.hpp @@ -16,7 +16,7 @@ #pragma once -#include "iacore/string.hpp" +#include namespace ia { diff --git a/Src/IACore/imp/inl/iacore/xop/interface/xop.interface.inl b/Src/IACore/inc/hpp/iacore/StreamReader.hpp similarity index 83% rename from Src/IACore/imp/inl/iacore/xop/interface/xop.interface.inl rename to Src/IACore/inc/hpp/iacore/StreamReader.hpp index 9108d00..c45ab81 100644 --- a/Src/IACore/imp/inl/iacore/xop/interface/xop.interface.inl +++ b/Src/IACore/inc/hpp/iacore/StreamReader.hpp @@ -1,24 +1,23 @@ -// IACore-OSS; The Core Library for All IA Open Source Projects +// IACore-OSS; The Core Library for All IA Open Source Projects // Copyright (C) 2024 IAS (ias@iasoft.dev) -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . #pragma once -#include +#include "IACore/StreamReader/StreamReader.inl" namespace ia { - // [IATODO: IMP] -} \ No newline at end of file +} // namespace ia \ No newline at end of file diff --git a/Src/IACore/inc/hpp/iacore/xop.hpp b/Src/IACore/inc/hpp/iacore/StringStream.hpp similarity index 94% rename from Src/IACore/inc/hpp/iacore/xop.hpp rename to Src/IACore/inc/hpp/iacore/StringStream.hpp index fef7f2a..2a63fad 100644 --- a/Src/IACore/inc/hpp/iacore/xop.hpp +++ b/Src/IACore/inc/hpp/iacore/StringStream.hpp @@ -16,6 +16,6 @@ #pragma once -#include "iacore/xop/xop.inl" +#include "IACore/stream/stringstream.inl" namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/algorithm.hpp b/Src/IACore/inc/hpp/iacore/algorithm.hpp index 50e6c69..e6e87c1 100644 --- a/Src/IACore/inc/hpp/iacore/algorithm.hpp +++ b/Src/IACore/inc/hpp/iacore/algorithm.hpp @@ -16,7 +16,7 @@ #pragma once -#include "iacore/algorithm/binary-search.inl" -#include "iacore/algorithm/quick-sort.inl" +#include "IACore/algorithm/binary-search.inl" +#include "IACore/algorithm/quick-sort.inl" namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/allocator.hpp b/Src/IACore/inc/hpp/iacore/allocator.hpp index d4198de..87dccd1 100644 --- a/Src/IACore/inc/hpp/iacore/allocator.hpp +++ b/Src/IACore/inc/hpp/iacore/allocator.hpp @@ -16,7 +16,7 @@ #pragma once -#include "iacore/memory/allocator/general.inl" -#include "iacore/memory/allocator/orchestrator.inl" +#include "IACore/memory/allocator/general.inl" +#include "IACore/memory/allocator/orchestrator.inl" namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/array.hpp b/Src/IACore/inc/hpp/iacore/array.hpp index eefd9ce..64efd78 100644 --- a/Src/IACore/inc/hpp/iacore/array.hpp +++ b/Src/IACore/inc/hpp/iacore/array.hpp @@ -16,6 +16,6 @@ #pragma once -#include "iacore/array/array.inl" +#include "IACore/array/array.inl" namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/base.hpp b/Src/IACore/inc/hpp/iacore/base.hpp index f2620ac..f7eae3a 100644 --- a/Src/IACore/inc/hpp/iacore/base.hpp +++ b/Src/IACore/inc/hpp/iacore/base.hpp @@ -17,13 +17,13 @@ #pragma once #if __STDC_HOSTED__ and !IACORE_FREESTANDING -#include +#include #include #include #include #define _lib_impl_ std #else -#include "iacore/lib.hpp" +#include "IACore/lib.hpp" #define _lib_impl_ ia #endif diff --git a/Src/IACore/inc/hpp/iacore/bytestream.hpp b/Src/IACore/inc/hpp/iacore/bytestream.hpp deleted file mode 100644 index ab083eb..0000000 --- a/Src/IACore/inc/hpp/iacore/bytestream.hpp +++ /dev/null @@ -1,119 +0,0 @@ -// IACore-OSS; The Core Library for All IA Open Source Projects -// Copyright (C) 2024 IAS (ias@iasoft.dev) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#pragma once - -#include "iacore/file.hpp" - -namespace ia -{ - class ByteStream - { - public: - ByteStream(IN CONST String& filePath) - { - File f(filePath, File::OPEN_FLAG_READ | File::OPEN_FLAG_BINARY); - const auto buffer = new UINT8[f.Size()]; - f.Read(buffer, f.Size(), f.Size()); - m_buffer = buffer; - m_bufferSize = f.Size(); - m_cursor = 0; - m_isBufferOwner = true; - } - - ByteStream(IN PCUINT8 buffer, IN SIZE_T bufferSize) - { - m_buffer = buffer; - m_bufferSize = bufferSize; - m_cursor = 0; - m_isBufferOwner = false; - } - - ~ByteStream() - { - if(m_isBufferOwner && m_buffer) - delete[] m_buffer; - } - - public: - VOID Read(OUT PUINT8 buffer) - { - ia_memcpy(buffer, &m_buffer[m_cursor], Remaining()); - m_cursor = m_bufferSize; - } - - VOID Read(IN SIZE_T count, OUT PUINT8 buffer) - { - EnsureAvailable(count); - ia_memcpy(buffer, &m_buffer[m_cursor], count); - m_cursor += count; - } - - UINT8 ReadUInt8() - { - EnsureAvailable(1); - return m_buffer[m_cursor++]; - } - - UINT16 ReadUInt16() - { - EnsureAvailable(2); - const auto t = m_buffer[m_cursor++]; - return (static_cast(m_buffer[m_cursor++]) << 8) | t; - } - - UINT32 ReadUInt32() - { - EnsureAvailable(4); - const auto t0 = m_buffer[m_cursor++]; - const auto t1 = static_cast(m_buffer[m_cursor++]); - const auto t2 = static_cast(m_buffer[m_cursor++]); - return (static_cast(m_buffer[m_cursor++]) << 24) | (t2 << 16) | (t1 << 8) | t0; - } - - UINT64 ReadUInt64() - { - EnsureAvailable(8); - const auto t0 = m_buffer[m_cursor++]; - const auto t1 = static_cast(m_buffer[m_cursor++]); - const auto t2 = static_cast(m_buffer[m_cursor++]); - const auto t3 = static_cast(m_buffer[m_cursor++]); - const auto t4 = static_cast(m_buffer[m_cursor++]); - const auto t5 = static_cast(m_buffer[m_cursor++]); - const auto t6 = static_cast(m_buffer[m_cursor++]); - return (static_cast(m_buffer[m_cursor++]) << 56) | (t6 << 48) | (t5 << 40) | (t4 << 32) | (t3 << 24) | (t2 << 16) | (t1 << 8) | t0; - } - - public: - VOID Seek(IN SIZE_T position) { m_cursor = position; } - - SIZE_T Cursor() CONST { return m_cursor; } - SIZE_T Remaining() CONST { return m_bufferSize - m_cursor; } - - private: - ALWAYS_INLINE VOID EnsureAvailable(IN SIZE_T count) - { - if((m_cursor + count) > m_bufferSize) - THROW_UNEXPECTED_EOF(); - } - - private: - SIZE_T m_cursor {}; - PCUINT8 m_buffer {}; - SIZE_T m_bufferSize {}; - BOOL m_isBufferOwner {}; - }; -} diff --git a/Src/IACore/inc/hpp/iacore/bytestring.hpp b/Src/IACore/inc/hpp/iacore/bytestring.hpp index 66ab552..20dbf1d 100644 --- a/Src/IACore/inc/hpp/iacore/bytestring.hpp +++ b/Src/IACore/inc/hpp/iacore/bytestring.hpp @@ -16,6 +16,6 @@ #pragma once -#include "iacore/bytestring/bytestring.inl" +#include "IACore/bytestring/bytestring.inl" namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/checks.hpp b/Src/IACore/inc/hpp/iacore/checks.hpp index f7a0678..d55cd09 100644 --- a/Src/IACore/inc/hpp/iacore/checks.hpp +++ b/Src/IACore/inc/hpp/iacore/checks.hpp @@ -16,7 +16,7 @@ #pragma once -#include "iacore/definitions.hpp" +#include #if __IA_DEBUG || IAC_SEC_LEVEL(1) #define __IAC_OVERFLOW_CHECKS 1 diff --git a/Src/IACore/inc/hpp/iacore/container.hpp b/Src/IACore/inc/hpp/iacore/container.hpp index 4714de2..c2d9f7d 100644 --- a/Src/IACore/inc/hpp/iacore/container.hpp +++ b/Src/IACore/inc/hpp/iacore/container.hpp @@ -16,8 +16,8 @@ #pragma once -#include "iacore/container/span.inl" -#include "iacore/container/fixed.inl" -#include "iacore/container/dynamic.inl" +#include "IACore/container/span.inl" +#include "IACore/container/fixed.inl" +#include "IACore/container/dynamic.inl" namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/exception.hpp b/Src/IACore/inc/hpp/iacore/exception.hpp index 1912d79..39fad19 100644 --- a/Src/IACore/inc/hpp/iacore/exception.hpp +++ b/Src/IACore/inc/hpp/iacore/exception.hpp @@ -16,7 +16,7 @@ #pragma once -#include +#include namespace ia { enum class ExceptionKind { diff --git a/Src/IACore/inc/hpp/iacore/file.hpp b/Src/IACore/inc/hpp/iacore/file.hpp index 3dd30a7..be542c6 100644 --- a/Src/IACore/inc/hpp/iacore/file.hpp +++ b/Src/IACore/inc/hpp/iacore/file.hpp @@ -16,12 +16,9 @@ #pragma once -#include "iacore/types.hpp" -#include -#include -#include -#include -#include +#include +#include +#include namespace ia { @@ -35,12 +32,12 @@ namespace ia OPEN_FLAG_BINARY = 4, }; - public: + public: STATIC Vector ReadToVector(IN CONST String &path) { File f(path, OPEN_FLAG_READ | OPEN_FLAG_BINARY); return f.ReadToVector(); - } + } STATIC String ReadToString(IN CONST String &path) { @@ -109,25 +106,33 @@ namespace ia } public: - template STATIC INLINE String ExtractFilenameFromPath(IN CONST String &path) + template STATIC String ExtractFilenameFromPath(IN CONST String &path) { -#if IA_DEFINED_TRUE(IA_PLATFORM_WINDOWS) - constexpr char pathDelimiter = '\\'; -#else constexpr char pathDelimiter = '/'; -#endif - auto t = path.rfind(pathDelimiter, 0); - if (t == path.end()) - { - if constexpr (includeExtension) - return path.slice(path.begin(), path.cend()); - return path.slice(path.begin(), path.rfind('.', 0)); + auto t = path.rfind(pathDelimiter); + if (t == String::npos) + { + if CONSTEXPR (includeExtension) + return path; + + return path.substr(0, path.rfind('.')); } if constexpr (includeExtension) - return path.slice(t + 1, path.cend()); + return path.substr(t + 1); - return path.slice(t + 1, path.rfind('.', 0)); + return path.substr(t + 1, path.rfind('.') - t - 1); + } + + String ExtractDirectoryFromPath(IN CONST String &path) + { + constexpr char pathDelimiter = '/'; + + auto t = path.rfind(pathDelimiter); + if (t == String::npos) + return "./"; + + return path.substr(0, t + 1); } private: diff --git a/Src/IACore/inc/hpp/iacore/hashable.hpp b/Src/IACore/inc/hpp/iacore/hashable.hpp index efcd6c7..256c3c5 100644 --- a/Src/IACore/inc/hpp/iacore/hashable.hpp +++ b/Src/IACore/inc/hpp/iacore/hashable.hpp @@ -16,6 +16,6 @@ #pragma once -#include "iacore/hashable/iihashable.inl" +#include "IACore/hashable/iihashable.inl" namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/iatest.hpp b/Src/IACore/inc/hpp/iacore/iatest.hpp index 7f55c58..124dc16 100644 --- a/Src/IACore/inc/hpp/iacore/iatest.hpp +++ b/Src/IACore/inc/hpp/iacore/iatest.hpp @@ -23,7 +23,7 @@ #include #include -#include +#include #define valid_iatest_runner(type) iatest::_valid_iatest_runner::value_type #define template_iatest_runner template requires valid_iatest_runner(_runner_type) diff --git a/Src/IACore/inc/hpp/iacore/iterator.hpp b/Src/IACore/inc/hpp/iacore/iterator.hpp index c73da7b..a351129 100644 --- a/Src/IACore/inc/hpp/iacore/iterator.hpp +++ b/Src/IACore/inc/hpp/iacore/iterator.hpp @@ -16,6 +16,6 @@ #pragma once -#include "iacore/iterator/iterator.inl" +#include "IACore/iterator/iterator.inl" namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/lib.hpp b/Src/IACore/inc/hpp/iacore/lib.hpp index eb522ed..ee1c19e 100644 --- a/Src/IACore/inc/hpp/iacore/lib.hpp +++ b/Src/IACore/inc/hpp/iacore/lib.hpp @@ -16,8 +16,8 @@ #pragma once -#include "iacore/lib/math.inl" -#include "iacore/lib/mem.inl" -#include "iacore/lib/str.inl" +#include "IACore/lib/math.inl" +#include "IACore/lib/mem.inl" +#include "IACore/lib/str.inl" namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/list.hpp b/Src/IACore/inc/hpp/iacore/list.hpp index 58850cb..88a61a3 100644 --- a/Src/IACore/inc/hpp/iacore/list.hpp +++ b/Src/IACore/inc/hpp/iacore/list.hpp @@ -16,6 +16,6 @@ #pragma once -#include "iacore/list/list.inl" +#include "IACore/list/list.inl" namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/map.hpp b/Src/IACore/inc/hpp/iacore/map.hpp index 78bf9ba..f0e839c 100644 --- a/Src/IACore/inc/hpp/iacore/map.hpp +++ b/Src/IACore/inc/hpp/iacore/map.hpp @@ -16,7 +16,7 @@ #pragma once -#include "iacore/map/map.inl" +#include "IACore/map/map.inl" namespace ia { diff --git a/Src/IACore/inc/hpp/iacore/memory.hpp b/Src/IACore/inc/hpp/iacore/memory.hpp index 6d191bb..80ea675 100644 --- a/Src/IACore/inc/hpp/iacore/memory.hpp +++ b/Src/IACore/inc/hpp/iacore/memory.hpp @@ -16,6 +16,6 @@ #pragma once -#include "iacore/memory/ptr/interface/refptr.interface.inl" +#include "IACore/memory/ptr/interface/refptr.interface.inl" namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/platform.hpp b/Src/IACore/inc/hpp/iacore/platform.hpp index 6a995b6..06836e9 100644 --- a/Src/IACore/inc/hpp/iacore/platform.hpp +++ b/Src/IACore/inc/hpp/iacore/platform.hpp @@ -16,6 +16,6 @@ #pragma once -#include "iacore/platform/platform.inl" +#include "IACore/platform/platform.inl" namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/set.hpp b/Src/IACore/inc/hpp/iacore/set.hpp index 8a6a4e2..b572f0d 100644 --- a/Src/IACore/inc/hpp/iacore/set.hpp +++ b/Src/IACore/inc/hpp/iacore/set.hpp @@ -16,6 +16,6 @@ #pragma once -#include "iacore/set/set.inl" +#include "IACore/set/set.inl" namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/span.hpp b/Src/IACore/inc/hpp/iacore/span.hpp index aec4053..0266407 100644 --- a/Src/IACore/inc/hpp/iacore/span.hpp +++ b/Src/IACore/inc/hpp/iacore/span.hpp @@ -16,7 +16,7 @@ #pragma once -#include "iacore/container/span.inl" +#include "IACore/container/span.inl" namespace ia { diff --git a/Src/IACore/inc/hpp/iacore/stream.hpp b/Src/IACore/inc/hpp/iacore/stream.hpp deleted file mode 100644 index 7aee1ff..0000000 --- a/Src/IACore/inc/hpp/iacore/stream.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// IACore-OSS; The Core Library for All IA Open Source Projects -// Copyright (C) 2024 IAS (ias@iasoft.dev) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#pragma once - -#include "iacore/stream/stringstream.inl" -#include "iacore/stream/filestream.inl" - -namespace ia {} diff --git a/Src/IACore/inc/hpp/iacore/string.hpp b/Src/IACore/inc/hpp/iacore/string.hpp index 4898154..ab618f3 100644 --- a/Src/IACore/inc/hpp/iacore/string.hpp +++ b/Src/IACore/inc/hpp/iacore/string.hpp @@ -16,7 +16,7 @@ #pragma once -#include "iacore/stream/stringstream.inl" +#include "IACore/stream/stringstream.inl" namespace ia { diff --git a/Src/IACore/inc/hpp/iacore/types.hpp b/Src/IACore/inc/hpp/iacore/types.hpp index 205e4e3..9e26e22 100644 --- a/Src/IACore/inc/hpp/iacore/types.hpp +++ b/Src/IACore/inc/hpp/iacore/types.hpp @@ -16,7 +16,7 @@ #pragma once -#include "iacore/checks.hpp" +#include namespace ia { diff --git a/Src/IACore/inc/hpp/iacore/vector.hpp b/Src/IACore/inc/hpp/iacore/vector.hpp index 73d2910..b1290a6 100644 --- a/Src/IACore/inc/hpp/iacore/vector.hpp +++ b/Src/IACore/inc/hpp/iacore/vector.hpp @@ -16,8 +16,8 @@ #pragma once -#include "iacore/vector/ordered.inl" -#include "iacore/vector/unordered.inl" +#include "IACore/vector/ordered.inl" +#include "IACore/vector/unordered.inl" namespace ia { diff --git a/Src/IACoreTest/imp/cpp/Main.cpp b/Src/IACoreTest/imp/cpp/Main.cpp index 17a103d..a32ec55 100644 --- a/Src/IACoreTest/imp/cpp/Main.cpp +++ b/Src/IACoreTest/imp/cpp/Main.cpp @@ -1,8 +1,8 @@ -#include -#include +#include +#include -#include -#include +#include +#include using namespace ia;