diff --git a/other/build.nr b/other/build.nr
index 671b223..90403d9 100644
--- a/other/build.nr
+++ b/other/build.nr
@@ -1 +1 @@
-2091
+2095
diff --git a/src/ostd/io/Memory.cpp b/src/ostd/io/Memory.cpp
index 4cc7b39..8a7b1bc 100644
--- a/src/ostd/io/Memory.cpp
+++ b/src/ostd/io/Memory.cpp
@@ -1,21 +1,21 @@
/*
- OmniaFramework - A collection of useful functionality
- Copyright (C) 2026 OmniaX-Dev
+ OmniaFramework - A collection of useful functionality
+ Copyright (C) 2026 OmniaX-Dev
- This file is part of OmniaFramework.
+ 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 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.
+ 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 .
+ You should have received a copy of the GNU General Public License
+ along with OmniaFramework. If not, see .
*/
#include "Memory.hpp"
@@ -23,7 +23,7 @@
namespace ostd
{
- void Memory::printByteStream(const ByteStream& data, StreamIndex start, u8 line_len, u16 n_rows, OutputHandlerBase& out, i32 addrHighlight, u32 highlightRange, const String& title)
+ void Memory::printByteStream(std::span data, StreamIndex start, u8 line_len, u16 n_rows, OutputHandlerBase& out, i32 addrHighlight, u32 highlightRange, const String& title)
{
StreamIndex end = start + (n_rows * line_len);
if (end > data.size()) end = data.size();
@@ -89,13 +89,13 @@ namespace ostd
out.nl().fg(ConsoleColors::BrightBlue).p(String::duplicateChar('=', linew)).nl().reset();
}
- bool Memory::saveByteStreamToFile(const ByteStream& stream, const String& filePath)
+ bool Memory::saveByteStreamToFile(std::span stream, const String& filePath)
{
std::ofstream writeFile;
writeFile.open(filePath.cpp_str(), std::ios::out | std::ios::binary);
- writeFile.write((char*)(&stream[0]), stream.size());
+ writeFile.write((char*)(stream.data()), stream.size());
writeFile.close();
- return true;
+ return writeFile.good();
}
bool Memory::loadByteStreamFromFile(const String& filePath, ByteStream& outStream)
@@ -117,7 +117,7 @@ namespace ostd
return bstream;
}
- String Memory::byteStreamToString(const ByteStream& data)
+ String Memory::byteStreamToString(std::span data)
{
String out_string = "";
for (i64 i = 0; i < data.size(); i++)
diff --git a/src/ostd/io/Memory.hpp b/src/ostd/io/Memory.hpp
index e799ad4..6293bd2 100644
--- a/src/ostd/io/Memory.hpp
+++ b/src/ostd/io/Memory.hpp
@@ -1,21 +1,21 @@
/*
- OmniaFramework - A collection of useful functionality
- Copyright (C) 2026 OmniaX-Dev
+ OmniaFramework - A collection of useful functionality
+ Copyright (C) 2026 OmniaX-Dev
- This file is part of OmniaFramework.
+ 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 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.
+ 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 .
+ You should have received a copy of the GNU General Public License
+ along with OmniaFramework. If not, see .
*/
#pragma once
@@ -32,11 +32,11 @@ namespace ostd
class Memory
{
public:
- static void printByteStream(const ByteStream& data, StreamIndex start, u8 line_len, u16 n_rows, OutputHandlerBase& out, i32 addrHighlight = -1, u32 highlightRange = 1, const String& title = "");
- static bool saveByteStreamToFile(const ByteStream& stream, const String& filePath);
+ static void printByteStream(std::span data, StreamIndex start, u8 line_len, u16 n_rows, OutputHandlerBase& out, i32 addrHighlight = -1, u32 highlightRange = 1, const String& title = "");
+ static bool saveByteStreamToFile(std::span stream, const String& filePath);
static bool loadByteStreamFromFile(const String& filePath, ByteStream& outStream);
static ByteStream stringToByteStream(const String& data);
- static String byteStreamToString(const ByteStream& data);
+ static String byteStreamToString(std::span data);
//Array helpers
template
diff --git a/src/ostd/io/Serial.cpp b/src/ostd/io/Serial.cpp
index 6ab46f1..57f337d 100755
--- a/src/ostd/io/Serial.cpp
+++ b/src/ostd/io/Serial.cpp
@@ -1,4 +1,5 @@
#include "Serial.hpp"
+#include "Memory.hpp"
namespace ostd
{
@@ -41,6 +42,14 @@ namespace ostd
+ Serial::Serial(StreamView copyData, serial::Endianness endianness) : read(*this), write(*this)
+ {
+ if (construct(copyData.size(), endianness, false) && isValid())
+ {
+ std::ranges::copy(copyData, m_data.data().begin());
+ }
+ }
+
bool Serial::construct(u64 size, serial::Endianness endianness, bool preInitialize, i8 initialValue)
{
if (m_data.isValid()) return false;
@@ -63,6 +72,12 @@ namespace ostd
return (addr + size - 1) < m_data.size();
}
+ bool Serial::writeToFile(const String& filePath) const
+ {
+ if (!isValid()) return false;
+ return Memory::saveByteStreamToFile(m_data.data(), filePath);
+ }
+
diff --git a/src/ostd/io/Serial.hpp b/src/ostd/io/Serial.hpp
index d684096..01ac452 100755
--- a/src/ostd/io/Serial.hpp
+++ b/src/ostd/io/Serial.hpp
@@ -21,6 +21,7 @@
#pragma once
#include
+// #include
#include
namespace ostd
@@ -307,8 +308,10 @@ namespace ostd
public:
inline Serial(void) : read(*this), write(*this) { }
inline Serial(u64 size, serial::Endianness endianness = serial::Endianness::LittleEndian, bool preInitialize = false, i8 initialValue = 0) : read(*this), write(*this) { construct(size, endianness, preInitialize, initialValue); }
+ Serial(StreamView copyData, serial::Endianness endianness = serial::Endianness::LittleEndian);
bool construct(u64 size, serial::Endianness endianness = serial::Endianness::LittleEndian, bool preInitialize = false, i8 initialValue = 0);
bool isValidAddress(u64 addr, u32 size = 1) const;
+ bool writeToFile(const String& filePath) const;
inline bool isValid(void) const { return m_data.isValid(); }
inline bool isInvalid(void) const { return !isValid(); }