diff --git a/src/tools/Serial.cpp b/src/tools/Serial.cpp deleted file mode 100644 index 14142b8..0000000 --- a/src/tools/Serial.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - OmniaFramework - A collection of useful functionality - Copyright (C) 2026 OmniaX-Dev - - This file is part of OmniaFramework. - - OmniaFramework 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. - - OmniaFramework 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 OmniaFramework. If not, see . -*/ diff --git a/src/tools/Serial.hpp b/src/tools/Serial.hpp deleted file mode 100644 index bfc1e91..0000000 --- a/src/tools/Serial.hpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - OmniaFramework - A collection of useful functionality - Copyright (C) 2026 OmniaX-Dev - - This file is part of OmniaFramework. - - OmniaFramework 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. - - OmniaFramework 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 OmniaFramework. If not, see . -*/ - -#pragma once - -#include -#include - -namespace ostd -{ - class Serial - { - public: enum class Endianness : u8 { LittleEndian = 0, BigEndian }; - public: using StreamEdit = std::span; - public: using StreamView = std::span; - public: class Stream - { - public: - inline Stream(u64 size, Endianness endianness = Endianness::LittleEndian, bool preInitialize = false, i8 initialValue = 0) { - if (size < 1) return; - if constexpr (sizeof(size_t) < sizeof(uint64_t)) - { - if (size > std::numeric_limits::max()) - throw "Serial::Stream size can't excede UINT32_MAX on a 32bit system."; - } - m_data = new i8[size]; - m_size = size; - m_endianness = endianness; - if (preInitialize) - { - for (u64 i = 0; i < size; i++) - m_data[i] = initialValue; - } - } - inline ~Stream(void) { - if (isValid()) - { - delete[] m_data; - m_data = nullptr; - } - } - inline bool isValid(void) const { return m_size > 0 && m_data != nullptr; } - inline StreamEdit data() { - if (isValid()) - return { m_data, cast(m_size) }; - return {}; - } - inline StreamView data() const { - if (isValid()) - return { m_data, cast(m_size) }; - return {}; - } - - private: - i8* m_data { nullptr }; - u64 m_size { 0 }; - Endianness m_endianness { Endianness::LittleEndian }; - }; - - public: - inline static void attachStream(Stream& stream) { s_openStream = stream.data(); } - inline static void detachStrean(void) { s_openStream = {}; } - inline static bool isStreamAttached(void) { return !s_openStream.empty(); } - - public: struct read - { - std::pair int8(u64 addr); - inline i8 int8d(u64 addr, bool* outError = nullptr) { auto val = int8(addr); if (outError) *outError = val.second; return val.first; } - std::pair uint8(u64 addr); - inline u8 uint8d(u64 addr, bool* outError = nullptr) { auto val = uint8(addr); if (outError) *outError = val.second; return val.first; } - - std::pair int16(u64 addr); - inline i16 int16d(u64 addr, bool* outError = nullptr) { auto val = int16(addr); if (outError) *outError = val.second; return val.first; } - std::pair uint16(u64 addr); - inline u16 uint16d(u64 addr, bool* outError = nullptr) { auto val = uint16(addr); if (outError) *outError = val.second; return val.first; } - - std::pair int32(u64 addr); - inline i32 int32d(u64 addr, bool* outError = nullptr) { auto val = int32(addr); if (outError) *outError = val.second; return val.first; } - std::pair uint32(u64 addr); - inline u32 uint32d(u64 addr, bool* outError = nullptr) { auto val = uint32(addr); if (outError) *outError = val.second; return val.first; } - - std::pair int64(u64 addr); - inline i64 int64d(u64 addr, bool* outError = nullptr) { auto val = int64(addr); if (outError) *outError = val.second; return val.first; } - std::pair uint64(u64 addr); - inline u64 uint64d(u64 addr, bool* outError = nullptr) { auto val = uint64(addr); if (outError) *outError = val.second; return val.first; } - - private: - read(void) = default; - }; - - private: - Serial(void) = default; - - private: - inline static StreamEdit s_openStream { }; - }; -}