Compare commits

...

4 Commits

Author SHA1 Message Date
b2f276a491 Restructure 2025-09-07 18:05:06 +05:30
c60810ba7b HF 2025-09-07 18:03:31 +05:30
fd54e8db39 Restructure 2025-09-07 17:53:55 +05:30
503bd51043 StreamReader 2025-09-07 17:43:28 +05:30
92 changed files with 519 additions and 335 deletions

View File

@ -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 <https://www.gnu.org/licenses/>.
#pragma once
namespace ia
{
class IStreamReader
{
public:
STATIC SharedPtr<IStreamReader> Create(IN PCCHAR filePath);
STATIC SharedPtr<IStreamReader> Create(IN Vector<UINT8> &&data);
public:
PURE_VIRTUAL(BOOL CompareBytes(IN PCUINT8 data, IN INT64 length) CONST);
PURE_VIRTUAL(Vector<UINT8> Read());
PURE_VIRTUAL(Vector<UINT8> 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<IStreamReader> Create(IN Vector<UINT8> &&data);
public:
BOOL CompareBytes(IN PCUINT8 data, IN INT64 length) CONST;
Vector<UINT8> Read();
Vector<UINT8> Read(IN INT64 size);
VOID Read(IN INT64 size, IN PUINT8 buffer);
Vector<UINT8> 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<UINT8> m_buffer;
private:
MemoryStreamReader(IN Vector<UINT8> &&data);
};
class FileStreamReader : public IStreamReader
{
public:
STATIC SharedPtr<IStreamReader> Create(IN PCCHAR filePath);
~FileStreamReader();
public:
BOOL CompareBytes(IN PCUINT8 data, IN INT64 length) CONST;
Vector<UINT8> Read();
Vector<UINT8> Read(IN INT64 size);
VOID Read(IN INT64 size, IN PUINT8 buffer);
Vector<UINT8> 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> IStreamReader::Create(IN PCCHAR filePath)
{
return FileStreamReader::Create(filePath);
}
SharedPtr<IStreamReader> IStreamReader::Create(IN Vector<UINT8> &&data)
{
return MemoryStreamReader::Create(std::move(data));
}
} // namespace ia

View File

@ -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 <https://www.gnu.org/licenses/>.
#pragma once
#include "interface/StreamReader.interface.inl"
namespace ia
{
SharedPtr<IStreamReader> MemoryStreamReader::Create(IN Vector<UINT8> &&data)
{
struct make_shared_enabler : public MemoryStreamReader
{
make_shared_enabler(IN Vector<UINT8> &&data) : MemoryStreamReader(std::move(data))
{
}
};
return std::make_shared<make_shared_enabler>(std::move(data));
}
MemoryStreamReader::MemoryStreamReader(IN Vector<UINT8> &&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<UINT8> MemoryStreamReader::Read()
{
Vector<UINT8> res;
res.resize(m_buffer.size() - m_cursor);
Read(res.size(), res.data());
return res;
}
Vector<UINT8> MemoryStreamReader::Read(IN INT64 size)
{
Vector<UINT8> 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<UINT8> 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<UINT16 *>(&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<UINT32 *>(&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<UINT64 *>(&m_buffer[m_cursor]);
m_cursor += 8;
return r;
}
} // namespace ia
namespace ia
{
SharedPtr<IStreamReader> FileStreamReader::Create(IN PCCHAR filePath)
{
struct make_shared_enabler : public FileStreamReader
{
make_shared_enabler(IN PCCHAR filePath) : FileStreamReader(filePath)
{
}
};
return std::make_shared<make_shared_enabler>(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<UINT8> 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<UINT8> FileStreamReader::Read()
{
DXF_RELEASE_ASSERT(m_filePtr);
Vector<UINT8> 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<UINT8> FileStreamReader::Read(IN INT64 size)
{
DXF_RELEASE_ASSERT(m_filePtr);
Vector<UINT8> 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<UINT8> 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

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/iterator.hpp>
#include <IACore/Iterator.hpp>
namespace ia
{

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/iterator.hpp>
#include <IACore/Iterator.hpp>
namespace ia
{

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/container.hpp>
#include <IACore/container.hpp>
namespace ia
{

View File

@ -16,8 +16,8 @@
#pragma once
#include <iacore/exception.hpp>
#include <iacore/vector.hpp>
#include <IACore/exception.hpp>
#include <IACore/vector.hpp>
namespace ia
{

View File

@ -16,8 +16,8 @@
#pragma once
#include <iacore/allocator.hpp>
#include <iacore/memory.hpp>
#include <IACore/Allocator.hpp>
#include <IACore/Memory.hpp>
#include "span.interface.inl"

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/iterator.hpp>
#include <IACore/Iterator.hpp>
namespace ia
{

View File

@ -16,9 +16,9 @@
#pragma once
#include <iacore/allocator.hpp>
#include <iacore/hashable.hpp>
#include <iacore/memory.hpp>
#include <IACore/Allocator.hpp>
#include <IACore/Hashable.hpp>
#include <IACore/Memory.hpp>
#include "iterator.interface.inl"

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/base.hpp>
#include <IACore/Base.hpp>
namespace ia
{

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/base.hpp>
#include <IACore/Base.hpp>
namespace ia
{

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/types.hpp>
#include <IACore/types.hpp>
namespace ia
{

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/types.hpp>
#include <IACore/types.hpp>
/*
* -----------------------------------

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/types.hpp>
#include <IACore/types.hpp>
/*
* -----------------------------------

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/allocator.hpp>
#include <IACore/Allocator.hpp>
namespace ia
{

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/allocator.hpp>
#include <IACore/Allocator.hpp>
//#include "iterator.interface.inl"
#include "entry.interface.inl"

View File

@ -16,9 +16,9 @@
#pragma once
#include <iacore/list.hpp>
#include <iacore/vector.hpp>
#include <iacore/hashable.hpp>
#include <IACore/List.hpp>
#include <IACore/Vector.hpp>
#include <IACore/Hashable.hpp>
namespace ia
{

View File

@ -17,7 +17,7 @@
#pragma once
#include <memory.h>
#include <iacore/base.hpp>
#include <IACore/Base.hpp>
namespace ia
{

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/base.hpp>
#include <IACore/Base.hpp>
namespace ia
{

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/base.hpp>
#include <IACore/Base.hpp>
#include <memory>
namespace ia

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/base.hpp>
#include <IACore/base.hpp>
namespace ia
{

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/vector.hpp>
#include <IACore/vector.hpp>
namespace ia
{

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/container.hpp>
#include <IACore/Container.hpp>
namespace ia
{

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/container.hpp>
#include <IACore/Container.hpp>
namespace ia
{

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/algorithm.hpp>
#include <IACore/Algorithm.hpp>
#include "interface/ordered.interface.inl"

View File

@ -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 <https://www.gnu.org/licenses/>.
#pragma once
#include "interface/xop.interface.inl"
namespace ia
{
// [IATODO: IMP]
}

View File

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

View File

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

View File

@ -16,6 +16,6 @@
#pragma once
#include "iacore/array/array.inl"
#include "IACore/array/array.inl"
namespace ia {}

View File

@ -17,13 +17,13 @@
#pragma once
#if __STDC_HOSTED__ and !IACORE_FREESTANDING
#include <iacore/types.hpp>
#include <IACore/Types.hpp>
#include <stdlib.h>
#include <math.h>
#include <cstring>
#define _lib_impl_ std
#else
#include "iacore/lib.hpp"
#include "IACore/lib.hpp"
#define _lib_impl_ ia
#endif

View File

@ -16,6 +16,6 @@
#pragma once
#include "iacore/bytestring/bytestring.inl"
#include "IACore/bytestring/bytestring.inl"
namespace ia {}

View File

@ -16,7 +16,7 @@
#pragma once
#include "iacore/definitions.hpp"
#include <IACore/Definitions.hpp>
#if __IA_DEBUG || IAC_SEC_LEVEL(1)
#define __IAC_OVERFLOW_CHECKS 1

View File

@ -0,0 +1,23 @@
// 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 <https://www.gnu.org/licenses/>.
#pragma once
#include "IACore/container/span.inl"
#include "IACore/container/fixed.inl"
#include "IACore/container/dynamic.inl"
namespace ia {}

View File

@ -16,7 +16,7 @@
#pragma once
#include <iacore/string.hpp>
#include <IACore/String.hpp>
namespace ia {
enum class ExceptionKind {

View File

@ -16,12 +16,9 @@
#pragma once
#include "iacore/types.hpp"
#include <cstdio>
#include <filesystem>
#include <iacore/exception.hpp>
#include <iacore/string.hpp>
#include <iacore/vector.hpp>
#include <IACore/Exception.hpp>
#include <IACore/String.hpp>
#include <IACore/Vector.hpp>
namespace ia
{
@ -35,12 +32,12 @@ namespace ia
OPEN_FLAG_BINARY = 4,
};
public:
public:
STATIC Vector<UINT8> 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<BOOL includeExtension> STATIC INLINE String ExtractFilenameFromPath(IN CONST String &path)
template<BOOL includeExtension> 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);
auto t = path.rfind(pathDelimiter);
if (t == path.end())
{
if constexpr (includeExtension)
return path.slice(path.begin(), path.cend());
if CONSTEXPR (includeExtension)
return path;
return path.slice(path.begin(), path.rfind('.', 0));
return path.slice(0, path.rfind('.'));
}
if constexpr (includeExtension)
return path.slice(t + 1, path.cend());
return path.slice(t + 1, path.end());
return path.slice(t + 1, path.rfind('.', 0));
return path.slice(t + 1, path.begin() + (path.rfind('.') - t) - 1);
}
String ExtractDirectoryFromPath(IN CONST String &path)
{
constexpr char pathDelimiter = '/';
auto t = path.rfind(pathDelimiter);
if (t == path.end())
return "./";
return path.slice(0, t + 1);
}
private:

View File

@ -16,6 +16,6 @@
#pragma once
#include "iacore/hashable/iihashable.inl"
#include "IACore/hashable/iihashable.inl"
namespace ia {}

View File

@ -23,7 +23,7 @@
#include <string>
#include <vector>
#include <iacore/types.hpp>
#include <IACore/Types.hpp>
#define valid_iatest_runner(type) iatest::_valid_iatest_runner<type>::value_type
#define template_iatest_runner template<typename _runner_type> requires valid_iatest_runner(_runner_type)

View File

@ -16,6 +16,6 @@
#pragma once
#include "iacore/iterator/iterator.inl"
#include "IACore/iterator/iterator.inl"
namespace ia {}

View File

@ -0,0 +1,23 @@
// 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 <https://www.gnu.org/licenses/>.
#pragma once
#include "IACore/lib/math.inl"
#include "IACore/lib/mem.inl"
#include "IACore/lib/str.inl"
namespace ia {}

View File

@ -16,6 +16,6 @@
#pragma once
#include "iacore/list/list.inl"
#include "IACore/list/list.inl"
namespace ia {}

View File

@ -16,7 +16,7 @@
#pragma once
#include "iacore/string.hpp"
#include <IACore/String.hpp>
namespace ia
{

View File

@ -16,7 +16,7 @@
#pragma once
#include "iacore/map/map.inl"
#include "IACore/map/map.inl"
namespace ia
{

View File

@ -0,0 +1,21 @@
// 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 <https://www.gnu.org/licenses/>.
#pragma once
#include "IACore/memory/ptr/interface/refptr.interface.inl"
namespace ia {}

View File

@ -16,6 +16,6 @@
#pragma once
#include "iacore/platform/platform.inl"
#include "IACore/platform/platform.inl"
namespace ia {}

View File

@ -16,6 +16,6 @@
#pragma once
#include "iacore/set/set.inl"
#include "IACore/set/set.inl"
namespace ia {}

View File

@ -16,7 +16,7 @@
#pragma once
#include "iacore/container/span.inl"
#include "IACore/container/span.inl"
namespace ia
{

View File

@ -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 <https://www.gnu.org/licenses/>.
#pragma once
#include <iacore/base.hpp>
#include "IACore/StreamReader/StreamReader.inl"
namespace ia
{
// [IATODO: IMP]
}
} // namespace ia

View File

@ -16,7 +16,7 @@
#pragma once
#include "iacore/stream/stringstream.inl"
#include "IACore/stream/stringstream.inl"
namespace ia
{

View File

@ -0,0 +1,21 @@
// 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 <https://www.gnu.org/licenses/>.
#pragma once
#include "IACore/stream/stringstream.inl"
namespace ia {}

View File

@ -16,7 +16,7 @@
#pragma once
#include "iacore/checks.hpp"
#include <IACore/Checks.hpp>
namespace ia
{

View File

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

View File

@ -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 <https://www.gnu.org/licenses/>.
#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<UINT64>(m_buffer[m_cursor++]) << 8) | t;
}
UINT32 ReadUInt32()
{
EnsureAvailable(4);
const auto t0 = m_buffer[m_cursor++];
const auto t1 = static_cast<UINT64>(m_buffer[m_cursor++]);
const auto t2 = static_cast<UINT64>(m_buffer[m_cursor++]);
return (static_cast<UINT64>(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<UINT64>(m_buffer[m_cursor++]);
const auto t2 = static_cast<UINT64>(m_buffer[m_cursor++]);
const auto t3 = static_cast<UINT64>(m_buffer[m_cursor++]);
const auto t4 = static_cast<UINT64>(m_buffer[m_cursor++]);
const auto t5 = static_cast<UINT64>(m_buffer[m_cursor++]);
const auto t6 = static_cast<UINT64>(m_buffer[m_cursor++]);
return (static_cast<UINT64>(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 {};
};
}

View File

@ -1,23 +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 <https://www.gnu.org/licenses/>.
#pragma once
#include "iacore/container/span.inl"
#include "iacore/container/fixed.inl"
#include "iacore/container/dynamic.inl"
namespace ia {}

View File

@ -1,23 +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 <https://www.gnu.org/licenses/>.
#pragma once
#include "iacore/lib/math.inl"
#include "iacore/lib/mem.inl"
#include "iacore/lib/str.inl"
namespace ia {}

View File

@ -1,21 +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 <https://www.gnu.org/licenses/>.
#pragma once
#include "iacore/memory/ptr/interface/refptr.interface.inl"
namespace ia {}

View File

@ -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 <https://www.gnu.org/licenses/>.
#pragma once
#include "iacore/stream/stringstream.inl"
#include "iacore/stream/filestream.inl"
namespace ia {}

View File

@ -1,21 +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 <https://www.gnu.org/licenses/>.
#pragma once
#include "iacore/xop/xop.inl"
namespace ia {}

View File

@ -1,8 +1,8 @@
#include <iacore/log.hpp>
#include <iacore/file.hpp>
#include <IACore/Logger.hpp>
#include <IACore/File.hpp>
#include <iacore/vector.hpp>
#include <iacore/map.hpp>
#include <IACore/Vector.hpp>
#include <IACore/Map.hpp>
using namespace ia;