From a110b0912f18ce1afd8e37e9577498c51930ea35 Mon Sep 17 00:00:00 2001 From: OmniaX-Dev Date: Sat, 7 Mar 2026 17:13:40 +0100 Subject: [PATCH] [0.3.2000] - Big file restructure --- CMakeLists.txt | 68 +-- other/build.nr | 2 +- src/ogfx/BasicRenderer.hpp | 22 +- src/ogfx/FontUtils.hpp | 24 +- src/ogfx/Image.hpp | 28 +- src/ogfx/PixelRenderer.cpp | 2 +- src/ogfx/PixelRenderer.hpp | 26 +- src/ogfx/RawTextInput.cpp | 16 +- src/ogfx/RawTextInput.hpp | 23 +- src/ogfx/SDLInclude.hpp | 20 + src/ogfx/WindowBase.cpp | 2 +- src/ogfx/WindowBase.hpp | 26 +- src/ogfx/WindowBaseOutputHandler.cpp | 2 +- src/ogfx/WindowBaseOutputHandler.hpp | 24 +- src/ostd/Defines.hpp | 86 ---- src/ostd/Errors.hpp | 36 -- src/ostd/Logic.hpp | 36 -- src/ostd/OutputHandlers.cpp | 504 ---------------------- src/ostd/QuadTree.hpp | 47 -- src/ostd/StringEditor.cpp | 331 -------------- src/ostd/{ => data_types}/BaseObject.cpp | 9 +- src/ostd/{ => data_types}/BaseObject.hpp | 43 +- src/ostd/{ => data_types}/Bitfields.hpp | 37 +- src/ostd/{ => data_types}/Color.cpp | 7 +- src/ostd/{ => data_types}/Color.hpp | 33 +- src/ostd/{ => data_types}/Types.hpp | 31 +- src/ostd/{ => io}/Console.cpp | 5 +- src/ostd/{ => io}/Console.hpp | 29 +- src/ostd/{ => io}/Errors.cpp | 2 +- src/ostd/io/Errors.hpp | 55 +++ src/ostd/{ => io}/File.cpp | 6 +- src/ostd/{ => io}/File.hpp | 33 +- src/ostd/{ => io}/FileSystem.cpp | 2 +- src/ostd/{ => io}/IOHandlers.hpp | 173 ++------ src/ostd/{ => io}/Json.cpp | 11 +- src/ostd/{ => io}/Json.hpp | 26 +- src/ostd/{ => io}/Keyboard.cpp | 26 +- src/ostd/{ => io}/Logger.cpp | 7 +- src/ostd/{ => io}/Logger.hpp | 31 +- src/ostd/{ => io}/Midi.cpp | 4 +- src/ostd/{ => io}/Midi.hpp | 24 +- src/ostd/io/OutputHandlers.cpp | 216 ++++++++++ src/ostd/{ => io}/Serial.cpp | 27 +- src/ostd/{ => io}/Serial.hpp | 36 +- src/ostd/{ => math}/Geometry.cpp | 6 +- src/ostd/{ => math}/Geometry.hpp | 45 +- src/ostd/{ => math}/Random.cpp | 0 src/ostd/{ => math}/Random.hpp | 27 +- src/ostd/{ => math}/ShuntingYard.cpp | 19 +- src/ostd/{ => math}/SineWave.cpp | 0 src/ostd/{ => math}/SineWave.hpp | 30 +- src/ostd/{ => math}/Spline.cpp | 61 ++- src/ostd/{ => math}/Spline.hpp | 41 +- src/ostd/ostd.hpp | 45 ++ src/ostd/{ => string}/String.cpp | 2 +- src/ostd/{ => string}/String.hpp | 135 +----- src/ostd/{ => string}/TextStyleParser.cpp | 2 +- src/ostd/{ => string}/TextStyleParser.hpp | 22 +- src/ostd/utils/Defines.hpp | 56 +++ src/ostd/{ => utils}/Logic.cpp | 3 +- src/ostd/utils/Logic.hpp | 52 +++ src/ostd/{ => utils}/PathFinder.cpp | 4 +- src/ostd/{ => utils}/PathFinder.hpp | 27 +- src/ostd/{ => utils}/QuadTree.cpp | 19 +- src/ostd/utils/QuadTree.hpp | 63 +++ src/ostd/{ => utils}/Signals.cpp | 4 +- src/ostd/{ => utils}/Signals.hpp | 30 +- src/ostd/{ => utils}/Time.cpp | 0 src/ostd/{ => utils}/Time.hpp | 32 +- src/ostd/{ => utils}/Utils.cpp | 9 +- src/ostd/{ => utils}/Utils.hpp | 36 +- src/ostd/{ => utils}/md5.cpp | 3 +- src/test.cpp | 23 +- 73 files changed, 1355 insertions(+), 1639 deletions(-) delete mode 100755 src/ostd/Defines.hpp delete mode 100755 src/ostd/Errors.hpp delete mode 100755 src/ostd/Logic.hpp delete mode 100755 src/ostd/OutputHandlers.cpp delete mode 100755 src/ostd/QuadTree.hpp delete mode 100755 src/ostd/StringEditor.cpp rename src/ostd/{ => data_types}/BaseObject.cpp (93%) rename src/ostd/{ => data_types}/BaseObject.hpp (70%) rename src/ostd/{ => data_types}/Bitfields.hpp (97%) rename src/ostd/{ => data_types}/Color.cpp (98%) rename src/ostd/{ => data_types}/Color.hpp (65%) rename src/ostd/{ => data_types}/Types.hpp (51%) rename src/ostd/{ => io}/Console.cpp (99%) rename src/ostd/{ => io}/Console.hpp (85%) rename src/ostd/{ => io}/Errors.cpp (98%) create mode 100755 src/ostd/io/Errors.hpp rename src/ostd/{ => io}/File.cpp (96%) rename src/ostd/{ => io}/File.hpp (57%) rename src/ostd/{ => io}/FileSystem.cpp (99%) rename src/ostd/{ => io}/IOHandlers.hpp (60%) rename src/ostd/{ => io}/Json.cpp (99%) rename src/ostd/{ => io}/Json.hpp (74%) rename src/ostd/{ => io}/Keyboard.cpp (97%) rename src/ostd/{ => io}/Logger.cpp (95%) rename src/ostd/{ => io}/Logger.hpp (66%) rename src/ostd/{ => io}/Midi.cpp (94%) rename src/ostd/{ => io}/Midi.hpp (79%) create mode 100755 src/ostd/io/OutputHandlers.cpp rename src/ostd/{ => io}/Serial.cpp (99%) rename src/ostd/{ => io}/Serial.hpp (75%) rename src/ostd/{ => math}/Geometry.cpp (84%) rename src/ostd/{ => math}/Geometry.hpp (91%) rename src/ostd/{ => math}/Random.cpp (100%) rename src/ostd/{ => math}/Random.hpp (82%) rename src/ostd/{ => math}/ShuntingYard.cpp (94%) rename src/ostd/{ => math}/SineWave.cpp (100%) rename src/ostd/{ => math}/SineWave.hpp (52%) rename src/ostd/{ => math}/Spline.cpp (74%) rename src/ostd/{ => math}/Spline.hpp (71%) create mode 100644 src/ostd/ostd.hpp rename src/ostd/{ => string}/String.cpp (99%) rename src/ostd/{ => string}/String.hpp (65%) rename src/ostd/{ => string}/TextStyleParser.cpp (99%) rename src/ostd/{ => string}/TextStyleParser.hpp (84%) create mode 100755 src/ostd/utils/Defines.hpp rename src/ostd/{ => utils}/Logic.cpp (98%) create mode 100755 src/ostd/utils/Logic.hpp rename src/ostd/{ => utils}/PathFinder.cpp (99%) rename src/ostd/{ => utils}/PathFinder.hpp (66%) rename src/ostd/{ => utils}/QuadTree.cpp (91%) create mode 100755 src/ostd/utils/QuadTree.hpp rename src/ostd/{ => utils}/Signals.cpp (98%) rename src/ostd/{ => utils}/Signals.hpp (80%) rename src/ostd/{ => utils}/Time.cpp (100%) rename src/ostd/{ => utils}/Time.hpp (82%) rename src/ostd/{ => utils}/Utils.cpp (96%) rename src/ostd/{ => utils}/Utils.hpp (75%) rename src/ostd/{ => utils}/md5.cpp (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a3d305..8796e1e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ #----------------------------------------------------------------------------------------- set(PROJ_NAME omnia-framework) set(MAJOR_VER 0) -set(MINOR_VER 2) +set(MINOR_VER 3) #----------------------------------------------------------------------------------------- #Setup @@ -42,33 +42,41 @@ list(APPEND OSTD_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/src/ostd/vendor/midifile/MidiMessage.cpp ${CMAKE_CURRENT_LIST_DIR}/src/ostd/vendor/midifile/Options.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/BaseObject.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Color.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Console.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Errors.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/File.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/FileSystem.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Geometry.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Json.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Keyboard.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Logger.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Logic.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/md5.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Midi.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/OutputHandlers.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/PathFinder.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/QuadTree.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/ShuntingYard.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Signals.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Random.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Serial.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/SineWave.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Spline.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/StringEditor.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/String.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/TextStyleParser.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Time.cpp - ${CMAKE_CURRENT_LIST_DIR}/src/ostd/Utils.cpp + # data_types + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/data_types/BaseObject.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/data_types/Color.cpp + + # io + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/io/Console.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/io/Errors.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/io/File.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/io/FileSystem.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/io/Json.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/io/Keyboard.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/io/Logger.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/io/Midi.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/io/OutputHandlers.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/io/Serial.cpp + + # math + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/math/Geometry.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/math/ShuntingYard.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/math/Random.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/math/SineWave.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/math/Spline.cpp + + # string + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/string/String.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/string/TextStyleParser.cpp + + # utils + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/utils/Logic.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/utils/md5.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/utils/PathFinder.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/utils/QuadTree.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/utils/Signals.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/utils/Time.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/ostd/utils/Utils.cpp ) list(APPEND OGFX_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/src/ogfx/FontUtils.cpp @@ -101,8 +109,12 @@ target_include_directories(${TEST_TARGET} PUBLIC ${INCLUDE_DIRS}) if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_compile_options(-O3 -MMD -MP -Wall -ggdb -fsanitize=address) + target_compile_definitions(${OMNIA_STD_LIB} PUBLIC OX_DEBUG_BUILD) + target_compile_definitions(${OMNIA_GFX_LIB} PUBLIC OX_DEBUG_BUILD) elseif(CMAKE_BUILD_TYPE STREQUAL "Release") add_compile_options(-MMD -MP -Wall) + target_compile_definitions(${OMNIA_STD_LIB} PUBLIC OX_RELEASE_BUILD) + target_compile_definitions(${OMNIA_GFX_LIB} PUBLIC OX_RELEASE_BUILD) endif() #----------------------------------------------------------------------------------------- diff --git a/other/build.nr b/other/build.nr index 54ece5b..2663d7c 100644 --- a/other/build.nr +++ b/other/build.nr @@ -1 +1 @@ -1974 +2001 diff --git a/src/ogfx/BasicRenderer.hpp b/src/ogfx/BasicRenderer.hpp index 7dbcea7..b8af068 100644 --- a/src/ogfx/BasicRenderer.hpp +++ b/src/ogfx/BasicRenderer.hpp @@ -1,7 +1,27 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 +#include #include namespace ogfx diff --git a/src/ogfx/FontUtils.hpp b/src/ogfx/FontUtils.hpp index b295430..feff883 100644 --- a/src/ogfx/FontUtils.hpp +++ b/src/ogfx/FontUtils.hpp @@ -1,8 +1,28 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 -#include +#include +#include namespace ogfx { diff --git a/src/ogfx/Image.hpp b/src/ogfx/Image.hpp index 4544b5f..8bd26cc 100644 --- a/src/ogfx/Image.hpp +++ b/src/ogfx/Image.hpp @@ -1,8 +1,28 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 #include -#include +#include namespace ogfx { @@ -15,8 +35,8 @@ namespace ogfx inline ~Image(void) { destroy(); } void destroy(void); Image& loadFromFile(const ostd::String& filePath, BasicRenderer2D& gfx); - inline ostd::IPoint getSize(void) const { return { m_width, m_height }; } - inline bool isLoaded(void) const { return m_loaded; } + inline ostd::IPoint getSize(void) const { return { m_width, m_height }; } + inline bool isLoaded(void) const { return m_loaded; } inline SDL_Texture* getSDLTexture(void) const { return m_sdl_texture; } private: diff --git a/src/ogfx/PixelRenderer.cpp b/src/ogfx/PixelRenderer.cpp index 88f81ee..3dd1579 100644 --- a/src/ogfx/PixelRenderer.cpp +++ b/src/ogfx/PixelRenderer.cpp @@ -1,6 +1,6 @@ #include "PixelRenderer.hpp" #include "WindowBase.hpp" -#include +#include "../ostd/utils/Utils.hpp" namespace ogfx { diff --git a/src/ogfx/PixelRenderer.hpp b/src/ogfx/PixelRenderer.hpp index 62f7a5c..e399c5b 100644 --- a/src/ogfx/PixelRenderer.hpp +++ b/src/ogfx/PixelRenderer.hpp @@ -1,8 +1,28 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 -#include +#include +#include +#include #include #include diff --git a/src/ogfx/RawTextInput.cpp b/src/ogfx/RawTextInput.cpp index 11dd097..5c7b5d5 100644 --- a/src/ogfx/RawTextInput.cpp +++ b/src/ogfx/RawTextInput.cpp @@ -1,6 +1,6 @@ #include "RawTextInput.hpp" #include -#include +#include namespace ogfx { @@ -165,7 +165,7 @@ namespace ogfx if (!found) parent.m_cursorPosition = text.len(); } - parent.m_cursorState = true; + parent.m_cursorState = true; } } @@ -195,7 +195,7 @@ namespace ogfx m_paddingX = (4.0f * geth()) / 30.0f; m_fontSize = (int32_t)(geth() * 0.66); float cursor_height_scale = 0.75f; - + ostd::IPoint strSize { 0, 0 }; if (m_cursorPosition > 0 && m_text != "") { @@ -206,19 +206,19 @@ namespace ogfx gfx.outlinedRect(*this, m_theme.backgroundColor, m_theme.borderColor, 2); if (m_text.len() > 0) gfx.drawString(m_text, getPosition() + ostd::Vec2 { m_paddingX + m_theme.extraPaddingLeft, m_paddingX + m_theme.extraPaddingTop}, m_theme.textColor, m_fontSize); - + if (m_cursorState || !m_theme.cursorBlink) gfx.fillRect({ getx() + m_paddingX + m_theme.extraPaddingLeft + strSize.x - 1, gety() + m_paddingX + m_theme.extraPaddingTop, (float)m_theme.cursorWidth, (float)m_fontSize * cursor_height_scale }, m_theme.cursorColor); - + onRender(gfx); } - + void RawTextInput::update(void) { m_keyRepeatCounter.update(); onUpdate(); } - + void RawTextInput::fixedUpdate(void) { if (m_theme.cursorBlink) @@ -284,4 +284,4 @@ namespace ogfx } } } -} \ No newline at end of file +} diff --git a/src/ogfx/RawTextInput.hpp b/src/ogfx/RawTextInput.hpp index 0b4ced4..3277f3d 100644 --- a/src/ogfx/RawTextInput.hpp +++ b/src/ogfx/RawTextInput.hpp @@ -1,7 +1,28 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 +#include + namespace ogfx { namespace gui diff --git a/src/ogfx/SDLInclude.hpp b/src/ogfx/SDLInclude.hpp index 687a169..fced569 100644 --- a/src/ogfx/SDLInclude.hpp +++ b/src/ogfx/SDLInclude.hpp @@ -1,3 +1,23 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 #ifdef _WIN32 diff --git a/src/ogfx/WindowBase.cpp b/src/ogfx/WindowBase.cpp index f5e26ce..4f5c766 100644 --- a/src/ogfx/WindowBase.cpp +++ b/src/ogfx/WindowBase.cpp @@ -1,5 +1,5 @@ #include "WindowBase.hpp" -#include "Time.hpp" +#include "../ostd/utils/Time.hpp" namespace ogfx { diff --git a/src/ogfx/WindowBase.hpp b/src/ogfx/WindowBase.hpp index 3a0a35a..0db6555 100644 --- a/src/ogfx/WindowBase.hpp +++ b/src/ogfx/WindowBase.hpp @@ -1,9 +1,29 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 -#include -#include +#include +#include +#include namespace ogfx { diff --git a/src/ogfx/WindowBaseOutputHandler.cpp b/src/ogfx/WindowBaseOutputHandler.cpp index 58e7ee0..265db29 100644 --- a/src/ogfx/WindowBaseOutputHandler.cpp +++ b/src/ogfx/WindowBaseOutputHandler.cpp @@ -1,6 +1,6 @@ #include "WindowBaseOutputHandler.hpp" #include "BasicRenderer.hpp" -#include "TextStyleParser.hpp" +#include "../string/TextStyleParser.hpp" namespace ogfx { diff --git a/src/ogfx/WindowBaseOutputHandler.hpp b/src/ogfx/WindowBaseOutputHandler.hpp index f06fd5c..4cb52d1 100644 --- a/src/ogfx/WindowBaseOutputHandler.hpp +++ b/src/ogfx/WindowBaseOutputHandler.hpp @@ -1,7 +1,27 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 +#include +#include #include namespace ogfx diff --git a/src/ostd/Defines.hpp b/src/ostd/Defines.hpp deleted file mode 100755 index cf0c401..0000000 --- a/src/ostd/Defines.hpp +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef __DEFINES_HPP__ -#define __DEFINES_HPP__ - -#if defined(_WIN32) || defined(_WIN64) - #define WINDOWS_OS - #ifdef _WIN32_WINNT - #undef _WIN32_WINNT - #endif - #define _WIN32_WINNT 0x0501 -#elif defined(__APPLE__) - #define MAC_OS -#else - #define LINUX_OS -#endif - -//Basic constants -#if !defined(BUILD_NR) - #define BUILD_NR 0 -#endif -#if !defined(MAJ_V) - #define MAJ_V 0 -#endif -#if !defined(MIN_V) - #define MIN_V 0 -#endif -#if !defined(VERSION_STR) - #define VERSION_STR "0.0.0" -#endif -#if !defined(NULL) - #define NULL 0 -#endif - -#define PI 3.1415926535898f -#define TWO_PI PI * 2.0f -#define HALF_PI PI / 2.0f -#define QUARTER_PI PI / 4.0f -#define DEG_TO_RAD(deg) (float)(deg * (PI / 180.0f)) -#define RAD_TO_DEG(rad) (float)(rad * (180.0f / PI)) - -//Game Time constants -#define TM_R_SECONDS_FOR_G_MINUTE 1 -#define TM_G_MINUTES_FOR_G_HOUR 60 -#define TM_G_HOURS_FOR_G_DAY 24 -#define TM_G_DAYS_FOR_G_LONG_MONTH 31 -#define TM_G_DAYS_FOR_G_MEDIUM_MONTH 30 -#define TM_G_DAYS_FOR_G_SHORT_MONTH 28 - -//Macro functions -#define ERROR_DATA() String(CPP_STR(__LINE__)), String(__FILE__) -#define STR_BOOL(b) (b ? "true" : "false") -#define INT_BOOL(i) (i == 0 ? false : true) -#define ZERO(n) (n > 0 ? n : 0) -#define FRAND() ((float)(rand() % 10000)) / 10000.0f -#define RANDOM(min, max) rand() % (max - min + 1) + min -#define LERP(n1, n2, f) (n2 - n1) * f + n1 -#define CAP(n, max) (n > max ? max : n) -#define CAPD(n, min) (n < min ? min : n) -#define CAPB(n, min, max) (n < min ? min : (n > max ? max : n)) -#define MAX(n1, n2) std::max(n1, n2) -#define MIN(n1, n2) std::min(n1, n2) -#define PROPORTION(w, x, y) ((x * w) / y) -#define CONVERT_1D_2D(i, width) ostd::IPoint(i % width, i / width) -#define CONVERT_2D_1D(x, y, width) (x + width * y) -#define PRINT(data) std::cout << data -#define PRINTLN(data) std::cout << data << "\n" -#define NEWLN() std::cout << "\n" -#define STDVEC_CONTAINS(vec, elem) (std::find(vec.begin(), vec.end(), elem) != vec.end()) - -//Memory management macros -#define new_sh(type) std::make_shared -#define sh_ptr(type) std::shared_ptr -#define new_un(type) std::make_unique -#define un_ptr(type) std::unique_ptr - -#define OX_NO_ERROR 0x00000000 -#define OX_WINDOW_ERR_MASK 0x00000000 -#define OX_SHADER_ERR_MASK 0x00001000 -#define OX_GLBUFFERS_ERR_MASK 0x00002000 -#define OX_TEXTURE_ERR_MASK 0x00003000 -#define OX_GFX_APPLICATION_2D_ERR_MASK 0x00004000 -#define OX_BITMAPFONT_ERR_MASK 0x00005000 -#define OX_RENDERER2D_ERR_MASK 0x00006000 -#define OX_RENDERTARGET_ERR_MASK 0x00007000 -#define OX_RENDERER2D_TEXT_ERR_MASK 0x00008000 - -#endif diff --git a/src/ostd/Errors.hpp b/src/ostd/Errors.hpp deleted file mode 100755 index 44e9c9d..0000000 --- a/src/ostd/Errors.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __ERRORS_HPP__ -#define __ERRORS_HPP__ - -#include -#include -#include - -namespace ostd -{ - struct tErrorLevel - { - inline static constexpr uint8_t NoError = 0x00; - inline static constexpr uint8_t Warning = 0x01; - inline static constexpr uint8_t Error = 0x02; - inline static constexpr uint8_t Fatal = 0x03; - }; - - class RuntimeError : public BaseObject - { - public: - inline RuntimeError(void) { invalidate(); } - inline RuntimeError(uint8_t group, uint64_t code, uint8_t level, const String& msg) { create(group, code, level, msg); } - RuntimeError& create(uint8_t group, uint64_t code, uint8_t level, const String& msg); - - void fire(const String& extraMessage = "", OutputHandlerBase* outputHandler = nullptr, BaseObject& userData = BaseObject::InvalidRef(), int32_t _line_num = 0, const String& _file_name = ""); - - private: - uint8_t m_errGroup { 0x00 }; - uint8_t m_errLevel { tErrorLevel::NoError }; - uint64_t m_errCode { 0x0000000000000000 }; - String m_message { "" }; - - }; -} - -#endif diff --git a/src/ostd/Logic.hpp b/src/ostd/Logic.hpp deleted file mode 100755 index 1ff7dd9..0000000 --- a/src/ostd/Logic.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __LOGIC_HPP__ -#define __LOGIC_HPP__ - -#include -#include - -namespace ostd -{ - enum class eLogicOp - { - AND = 0, - OR, - NOT, - XOR, - - NAND, - NOR, - XNOR, - - O_PARENTH = 125, - C_PARENTH = 126, - NONE = 127 - }; - - class LogicEvaluator - { - public: - static bool eval(String exp); - - private: - static bool applyOp(bool a, bool b, eLogicOp op); - static eLogicOp parseOp(char op); - }; -} - -#endif diff --git a/src/ostd/OutputHandlers.cpp b/src/ostd/OutputHandlers.cpp deleted file mode 100755 index 700497b..0000000 --- a/src/ostd/OutputHandlers.cpp +++ /dev/null @@ -1,504 +0,0 @@ -#include "Utils.hpp" -#include "Color.hpp" -#include "BaseObject.hpp" -#include "Logger.hpp" -#include "TextStyleParser.hpp" -#include "IOHandlers.hpp" -#include "String.hpp" - -#include "vendor/TermColor.hpp" - -#include -#include - -namespace ostd -{ - std::ostream &operator<<(std::ostream &os, ConsoleColors::tConsoleColor const &col) - { - if (col.background) - { - if (col.name == "red") os << termcolor::on_red; - else if (col.name == "brightred") os << termcolor::on_bright_red; - else if (col.name == "green") os << termcolor::on_green; - else if (col.name == "brightgreen") os << termcolor::on_bright_green; - else if (col.name == "blue") os << termcolor::on_blue; - else if (col.name == "brightblue") os << termcolor::on_bright_blue; - else if (col.name == "magenta") os << termcolor::on_magenta; - else if (col.name == "brightmagenta") os << termcolor::on_bright_magenta; - else if (col.name == "cyan") os << termcolor::on_cyan; - else if (col.name == "brightcyan") os << termcolor::on_bright_cyan; - else if (col.name == "yellow") os << termcolor::on_yellow; - else if (col.name == "brightyellow") os << termcolor::on_bright_yellow; - else if (col.name == "black") os << termcolor::on_grey; - else if (col.name == "darkgray") os << termcolor::on_bright_grey; - else if (col.name == "brightgray") os << termcolor::on_white; - else if (col.name == "white") os << termcolor::on_bright_white; - return os; - } - if (col.name == "red") os << termcolor::red; - else if (col.name == "brightred") os << termcolor::bright_red; - else if (col.name == "green") os << termcolor::green; - else if (col.name == "brightgreen") os << termcolor::bright_green; - else if (col.name == "blue") os << termcolor::blue; - else if (col.name == "brightblue") os << termcolor::bright_blue; - else if (col.name == "magenta") os << termcolor::magenta; - else if (col.name == "brightmagenta") os << termcolor::bright_magenta; - else if (col.name == "cyan") os << termcolor::cyan; - else if (col.name == "brightcyan") os << termcolor::bright_cyan; - else if (col.name == "yellow") os << termcolor::yellow; - else if (col.name == "brightyellow") os << termcolor::bright_yellow; - else if (col.name == "black") os << termcolor::grey; - else if (col.name == "darkgray") os << termcolor::bright_grey; - else if (col.name == "brightgray") os << termcolor::white; - else if (col.name == "white") os << termcolor::bright_white; - return os; - } - - - - OutputHandlerBase& ConsoleOutputHandler::bg(const ConsoleColors::tConsoleColor& color) - { - std::cout << color.asBackground(); - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::bg(const String& color) - { - std::cout << ConsoleColors::getFromName(color, true); - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::fg(const ConsoleColors::tConsoleColor& color) - { - std::cout << color.asForeground(); - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::fg(const String& color) - { - std::cout << ConsoleColors::getFromName(color, false); - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::pChar(char c) - { - std::cout << (char)c; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::pStyled(const String& styled) - { - return pStyled(TextStyleParser::parse(styled)); - } - - OutputHandlerBase& ConsoleOutputHandler::pStyled(const TextStyleParser::tStyledString& styled) - { - std::cout << styled; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::pStyled(TextStyleBuilder::IRichStringBase& styled) - { - std::cout << styled; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::pObject(const BaseObject& bo) - { - std::cout << bo; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::p(const String& se) - { - std::cout << se; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::p(uint8_t i) - { - std::cout << (uint8_t)i; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::p(int8_t i) - { - std::cout << (int8_t)i; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::p(uint16_t i) - { - std::cout << (uint16_t)i; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::p(int16_t i) - { - std::cout << (int16_t)i; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::p(uint32_t i) - { - std::cout << (uint32_t)i; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::p(int32_t i) - { - std::cout << (int32_t)i; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::p(uint64_t i) - { - std::cout << (uint64_t)i; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::p(int64_t i) - { - std::cout << (int64_t)i; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::p(float f, uint8_t precision) - { - if (precision == 0) - { - std::cout << f; - } - else - { - std::ios cout_state(nullptr); - std::cout << std::fixed << std::setprecision(precision) << f; - std::cout.copyfmt(cout_state); - } - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::p(double f, uint8_t precision) - { - if (precision == 0) - { - std::cout << f; - } - else - { - std::ios cout_state(nullptr); - std::cout << std::fixed << std::setprecision(precision) << f; - std::cout.copyfmt(cout_state); - } - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::nl(void) - { - std::cout << "\n"; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::flush(void) - { - std::cout << std::flush; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::reset(void) - { - std::cout << termcolor::reset; - return *this; - } - - OutputHandlerBase& ConsoleOutputHandler::clear(void) - { - Utils::clearConsole(); - return *this; - } - - - - - - namespace legacy - { - IOutputHandler& ConsoleOutputHandler::col(String color) - { - StringEditor cse = color; - cse.toLower().trim(); - if (cse.startsWith("@[") && cse.endsWith("]")) - { - OX_WARN("ox::ConsoleOutputHandler::col(ox::String): RGB Colors not supported for standard console output: %s", cse.c_str()); - return *this; - } - - //RED - if (cse.str() == ConsoleCol::Red) std::cout << termcolor::red; - else if (cse.str() == ConsoleCol::BrightRed) std::cout << termcolor::bright_red; - else if (cse.str() == ConsoleCol::OnRed) std::cout << termcolor::on_red; - else if (cse.str() == ConsoleCol::OnBrightRed) std::cout << termcolor::on_bright_red; - //GREEN - else if (cse.str() == ConsoleCol::Green) std::cout << termcolor::green; - else if (cse.str() == ConsoleCol::BrightGreen) std::cout << termcolor::bright_green; - else if (cse.str() == ConsoleCol::OnGreen) std::cout << termcolor::on_green; - else if (cse.str() == ConsoleCol::OnBrightGreen) std::cout << termcolor::on_bright_green; - //BLUE - else if (cse.str() == ConsoleCol::Blue) std::cout << termcolor::blue; - else if (cse.str() == ConsoleCol::BrightBlue) std::cout << termcolor::bright_blue; - else if (cse.str() == ConsoleCol::OnBlue) std::cout << termcolor::on_blue; - else if (cse.str() == ConsoleCol::OnBrightBlue) std::cout << termcolor::on_bright_blue; - //MAGENTA - else if (cse.str() == ConsoleCol::Magenta) std::cout << termcolor::magenta; - else if (cse.str() == ConsoleCol::BrightMagenta) std::cout << termcolor::bright_magenta; - else if (cse.str() == ConsoleCol::OnMagenta) std::cout << termcolor::on_magenta; - else if (cse.str() == ConsoleCol::OnBrightMagenta) std::cout << termcolor::on_bright_magenta; - //CYAN - else if (cse.str() == ConsoleCol::Cyan || cse.str() == "aqua") std::cout << termcolor::cyan; - else if (cse.str() == ConsoleCol::BrightCyan) std::cout << termcolor::bright_cyan; - else if (cse.str() == ConsoleCol::OnCyan || cse.str() == "o-aqua") std::cout << termcolor::on_cyan; - else if (cse.str() == ConsoleCol::OnBrightCyan) std::cout << termcolor::on_bright_cyan; - //YELLOW - else if (cse.str() == ConsoleCol::Yellow) std::cout << termcolor::yellow; - else if (cse.str() == ConsoleCol::BrightYellow) std::cout << termcolor::bright_yellow; - else if (cse.str() == ConsoleCol::OnYellow) std::cout << termcolor::on_yellow; - else if (cse.str() == ConsoleCol::OnBrightYellow) std::cout << termcolor::on_bright_yellow; - //GRAY - else if (cse.str() == ConsoleCol::Black || cse.str() == "black") std::cout << termcolor::grey; - else if (cse.str() == ConsoleCol::BrightGray) std::cout << termcolor::bright_grey; - else if (cse.str() == ConsoleCol::OnBlack || cse.str() == "o-black") std::cout << termcolor::on_grey; - else if (cse.str() == ConsoleCol::OnBrightGray) std::cout << termcolor::on_bright_grey; - //WHITE - else if (cse.str() == ConsoleCol::Gray) std::cout << termcolor::white; - else if (cse.str() == ConsoleCol::White || cse.str() == "b-lgray") std::cout << termcolor::bright_white; - else if (cse.str() == ConsoleCol::onGray) std::cout << termcolor::on_white; - else if (cse.str() == ConsoleCol::OnWhite || cse.str() == "o-white") std::cout << termcolor::on_bright_white; - else - OX_WARN("ox::ConsoleOutputHandler::col(ox::String): Unknown color string: %s", cse.c_str()); - return *this; - } - - IOutputHandler& ConsoleOutputHandler::col(const Color& color) - { - StringEditor cse = "@["; - cse.addi(color.r).add(", "); - cse.addi(color.g).add(", "); - cse.addi(color.b).add(", "); - cse.addi(color.a).add("]"); - return col(cse.str()); - } - - IOutputHandler& ConsoleOutputHandler::p(char c) - { - std::cout << (char)c; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::p(const StringEditor& se) - { - std::cout << se; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::pi(uint8_t i) - { - std::cout << (int64_t)i; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::pi(int8_t i) - { - std::cout << (int64_t)i; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::pi(uint16_t i) - { - std::cout << (int64_t)i; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::pi(int16_t i) - { - std::cout << (int64_t)i; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::pi(uint32_t i) - { - std::cout << (int64_t)i; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::pi(int32_t i) - { - std::cout << (int64_t)i; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::pi(uint64_t i) - { - std::cout << (uint64_t)i; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::pi(int64_t i) - { - std::cout << (int64_t)i; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::pf(float f, uint8_t precision) - { - if (precision == 0) - { - std::cout << f; - } - else - { - std::ios cout_state(nullptr); - std::cout << std::fixed << std::setprecision(precision) << f; - std::cout.copyfmt(cout_state); - } - return *this; - } - - IOutputHandler& ConsoleOutputHandler::pf(double f, uint8_t precision) - { - if (precision == 0) - { - std::cout << f; - } - else - { - std::ios cout_state(nullptr); - std::cout << std::fixed << std::setprecision(precision) << f; - std::cout.copyfmt(cout_state); - } - return *this; - } - - IOutputHandler& ConsoleOutputHandler::pStyled(const StringEditor& styled) - { - return pStyled(TextStyleParser::parse(styled.str())); - } - - IOutputHandler& ConsoleOutputHandler::pStyled(const TextStyleParser::tStyledString& styled) - { - std::cout << styled; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::pStyled(const TextStyleBuilder::IRichStringBase& styled) - { - std::cout << styled.getStyledString(); - return *this; - } - - IOutputHandler& ConsoleOutputHandler::nl(void) - { - std::cout << "\n"; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::flush(void) - { - std::cout << std::endl; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::reset(void) - { - std::cout << termcolor::reset; - return *this; - } - - IOutputHandler& ConsoleOutputHandler::clear(void) - { - Utils::clearConsole(); - return *this; - } - - - - - - IOutputHandler& BufferedOutputHandler::p(char c) - { - m_buffer.add(c); - return *this; - } - - IOutputHandler& BufferedOutputHandler::p(const StringEditor& se) - { - m_buffer.add(se.str()); - return *this; - } - - IOutputHandler& BufferedOutputHandler::pi(uint8_t i) - { - m_buffer.addi(i); - return *this; - } - - IOutputHandler& BufferedOutputHandler::pi(int8_t i) - { - m_buffer.addi(i); - return *this; - } - - IOutputHandler& BufferedOutputHandler::pi(uint16_t i) - { - m_buffer.addi(i); - return *this; - } - - IOutputHandler& BufferedOutputHandler::pi(int16_t i) - { - m_buffer.addi(i); - return *this; - } - - IOutputHandler& BufferedOutputHandler::pi(uint32_t i) - { - m_buffer.addi(i); - return *this; - } - - IOutputHandler& BufferedOutputHandler::pi(int32_t i) - { - m_buffer.addi(i); - return *this; - } - - IOutputHandler& BufferedOutputHandler::pi(uint64_t i) - { - m_buffer.addi(i); - return *this; - } - - IOutputHandler& BufferedOutputHandler::pi(int64_t i) - { - m_buffer.addi(i); - return *this; - } - - IOutputHandler& BufferedOutputHandler::pf(float f, uint8_t precision) - { - m_buffer.addf(f); - return *this; - } - - IOutputHandler& BufferedOutputHandler::pf(double f, uint8_t precision) - { - m_buffer.addf(f); - return *this; - } - - IOutputHandler& BufferedOutputHandler::nl(void) - { - m_buffer.add("\n"); - return *this; - } - } -} diff --git a/src/ostd/QuadTree.hpp b/src/ostd/QuadTree.hpp deleted file mode 100755 index 2686609..0000000 --- a/src/ostd/QuadTree.hpp +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __QUAD_TREE_HPP__ -#define __QUAD_TREE_HPP__ - -#include -#include -#include -#include -#include - -namespace ostd -{ - class QuadTree : public BaseObject - { - public: struct tElement - { - Vec2 pos; - void* data; - tElement(void); - tElement(Vec2 position, void* userData); - }; - public: - inline QuadTree(void) : m_points(nullptr), m_sw(nullptr), m_nw(nullptr), - m_se(nullptr),m_ne(nullptr), m_subdivided(false), - m_capacity(0), m_currentSize(0) - { invalidate(); } - inline QuadTree(Rectangle bounds, uint16_t capacity) { create(bounds, capacity); } - inline ~QuadTree(void) { destroy(); } - void destroy(void); - void create(Rectangle bounds, uint16_t capacity); - void subdivide(void); - bool insert(Vec2 point, void* data = nullptr); - void query(Rectangle range, std::vector& list); - - private: - tElement* m_points; - uint16_t m_currentSize; - uint16_t m_capacity; - Rectangle m_bounds; - bool m_subdivided; - un_ptr(QuadTree) m_nw; - un_ptr(QuadTree) m_sw; - un_ptr(QuadTree) m_ne; - un_ptr(QuadTree) m_se; - }; -} - -#endif diff --git a/src/ostd/StringEditor.cpp b/src/ostd/StringEditor.cpp deleted file mode 100755 index 1780c29..0000000 --- a/src/ostd/StringEditor.cpp +++ /dev/null @@ -1,331 +0,0 @@ -#include "Utils.hpp" -#include "String.hpp" -#include -#include -#include - -namespace ostd -{ - namespace legacy - { - String StringEditor::Tokens::next(void) - { - if (!hasNext()) return Tokens::END; - return m_tokens[m_current_index++]; - } - - String StringEditor::Tokens::previous(void) - { - if (!hasPrevious()) return Tokens::END; - return m_tokens[--m_current_index]; - } - - StringEditor& StringEditor::ltrim(void) - { - m_data.erase(m_data.begin(), std::find_if(m_data.begin(), m_data.end(), [](unsigned char ch) { - return !std::isspace(ch); - })); - return *this; - } - StringEditor& StringEditor::rtrim(void) - { - m_data.erase(std::find_if(m_data.rbegin(), m_data.rend(), [](unsigned char ch) { - return !std::isspace(ch); - }).base(), m_data.end()); - return *this; - } - StringEditor& StringEditor::trim(void) - { - return ltrim().rtrim(); - } - StringEditor& StringEditor::toLower(void) - { - std::transform(m_data.begin(), m_data.end(), m_data.begin(), [](unsigned char c){ return std::tolower(c); }); - return *this; - } - StringEditor& StringEditor::toUpper(void) - { - std::transform(m_data.begin(), m_data.end(), m_data.begin(), [](unsigned char c){ return std::toupper(c); }); - return *this; - } - StringEditor& StringEditor::addPadding(char c, uint32_t count) - { - for (uint16_t i = 0; i < count; i++) - m_data += c; - return *this; - } - - // StringEditor& StringEditor::add(const StringEditor& se) - // { - // m_data += se.m_data; - // return *this; - // } - - StringEditor& StringEditor::add(String str) - { - m_data += str; - return *this; - } - - StringEditor& StringEditor::add(char c) - { - m_data += c; - return *this; - } - - StringEditor& StringEditor::addi(uint8_t i) - { - m_data += std::to_string(i); - return *this; - } - - StringEditor& StringEditor::addi(int8_t i) - { - m_data += std::to_string(i); - return *this; - } - - StringEditor& StringEditor::addi(uint16_t i) - { - m_data += std::to_string(i); - return *this; - } - - StringEditor& StringEditor::addi(int16_t i) - { - m_data += std::to_string(i); - return *this; - } - - StringEditor& StringEditor::addi(uint32_t i) - { - m_data += std::to_string(i); - return *this; - } - - StringEditor& StringEditor::addi(int32_t i) - { - m_data += std::to_string(i); - return *this; - } - - StringEditor& StringEditor::addi(uint64_t i) - { - m_data += std::to_string(i); - return *this; - } - - StringEditor& StringEditor::addi(int64_t i) - { - m_data += std::to_string(i); - return *this; - } - - StringEditor& StringEditor::addf(float f) - { - m_data += std::to_string(f); - return *this; - } - - StringEditor& StringEditor::addf(double f) - { - m_data += std::to_string(f); - return *this; - } - - StringEditor& StringEditor::reverse(void) - { - std::reverse(m_data.begin(), m_data.end()); - return *this; - } - - StringEditor& StringEditor::replaceAll(String what, String with) - { - while (contains(what)) - replaceFirst(what, with); - return *this; - } - - StringEditor& StringEditor::replaceFirst(String what, String with) - { - int32_t index = indexOf(what); - if (index == -1) return *this; - m_data.replace(index, what.length(), with); - return *this; - } - - StringEditor& StringEditor::regexReplace(String regex_pattern, String replace_with, bool case_insensitive) - { - try - { - boost::regex rgx(regex_pattern, (case_insensitive ? boost::regex_constants::icase : boost::regex_constants::normal)); - m_data = boost::regex_replace(m_data, rgx, replace_with); - return *this; - } - catch(const boost::regex_error& err) - { - std::cerr << err.what() << '\n'; //TODO: Better error handling - return *this; - } - return *this; - } - - StringEditor& StringEditor::put(uint32_t index, char c) - { - if (index < m_data.length()) - m_data[index] = c; - return *this; - } - - int64_t StringEditor::toInt(void) - { - if (!isNumeric(false)) return 0; - return Utils::strToInt(m_data); - } - - float StringEditor::toFloat(void) - { - if (!isNumeric(true)) return 0; - return std::stof(m_data); - } - - double StringEditor::toDouble(void) - { - if (!isNumeric(true)) return 0; - return std::stod(m_data); - } - - bool StringEditor::isNumeric(bool decimal) - { - if (decimal) - { - std::istringstream iss(m_data); - double f; - iss >> std::noskipws >> f; - return iss.eof() && !iss.fail(); - } - return Utils::isInt(m_data); - } - - bool StringEditor::contains(char c) - { - return m_data.find(c) != std::string::npos; - } - - bool StringEditor::contains(String str) - { - return m_data.find(str) != std::string::npos; - } - - bool StringEditor::startsWith(String str) - { - return m_data.starts_with(str); - } - - bool StringEditor::endsWith(String str) - { - return m_data.ends_with(str); - } - - String StringEditor::getReverse(void) - { - StringEditor se(m_data); - return se.reverse().str(); - } - - uint32_t StringEditor::count(String str) - { - Tokens tok = tokenize(str, false, true); - if (tok.count() < 1) return 0; - return tok.count() - 1; - } - - int32_t StringEditor::indexOf(char c, uint32_t start) - { - String cc = ""; - cc += c; - int32_t pos = m_data.find(cc.c_str(), start); - if (pos == std::string::npos) return -1; - return pos; - } - - int32_t StringEditor::indexOf(String str, uint32_t start) - { - int32_t pos = m_data.find(str.c_str(), start); - if (pos == std::string::npos) return -1; - return pos; - } - - int32_t StringEditor::lastIndexOf(char c) - { - StringEditor se(m_data); - se.reverse(); - int32_t pos = se.indexOf(c); - if (pos < 0) return -1; - return len() - pos - 1; - } - - int32_t StringEditor::lastIndexOf(String str) - { - StringEditor se(m_data); - se.reverse(); - StringEditor se2(str); - int32_t pos = se.indexOf(se2.reverse().str()); - if (pos < 0) return -1; - return len() - pos - str.length(); - } - - String StringEditor::substr(uint32_t start, int32_t end) - { - if (end < 0) return m_data.substr(start); - return m_data.substr(start, end - start); - } - - StringEditor::Tokens StringEditor::tokenize(String delimiter, bool trim_tokens, bool allow_white_space_only_tokens) - { - Tokens tokens; - int32_t sindex = 0; - int32_t eindex = 0; - StringEditor __token = ""; - while ((eindex = indexOf(delimiter, sindex)) != -1) - { - __token = substr(sindex, eindex); - if (trim_tokens) - { - __token.trim(); - if (__token.str() != "") - tokens.m_tokens.push_back(__token.str()); - } - else - { - if (allow_white_space_only_tokens && __token.str() != "") - tokens.m_tokens.push_back(__token.str()); - else if (!allow_white_space_only_tokens && StringEditor(__token).trim().str() != "") - tokens.m_tokens.push_back(__token.str()); - } - sindex = eindex + delimiter.length(); - } - __token = substr(sindex); - if (trim_tokens) - { - __token.trim(); - if (__token.str() != "") - tokens.m_tokens.push_back(__token.str()); - } - else - { - if (allow_white_space_only_tokens && __token.str() != "") - tokens.m_tokens.push_back(__token.str()); - else if (!allow_white_space_only_tokens && StringEditor(__token).trim().str() != "") - tokens.m_tokens.push_back(__token.str()); - } - return tokens; - } - - std::ostream& operator<<(std::ostream& out, const StringEditor& val) - { - out << val.str(); - return out; - } - } -} diff --git a/src/ostd/BaseObject.cpp b/src/ostd/data_types/BaseObject.cpp similarity index 93% rename from src/ostd/BaseObject.cpp rename to src/ostd/data_types/BaseObject.cpp index 1925943..6aabc0a 100755 --- a/src/ostd/BaseObject.cpp +++ b/src/ostd/data_types/BaseObject.cpp @@ -1,8 +1,7 @@ #include "BaseObject.hpp" -#include "Utils.hpp" -#include "Defines.hpp" -#include "Signals.hpp" -#include "IOHandlers.hpp" +#include "../utils/Signals.hpp" +#include "../io/IOHandlers.hpp" +#include "../utils/Utils.hpp" namespace ostd { @@ -59,4 +58,4 @@ namespace ostd if (m_signalsEnabled) handleSignal(signal); } -} +} diff --git a/src/ostd/BaseObject.hpp b/src/ostd/data_types/BaseObject.hpp similarity index 70% rename from src/ostd/BaseObject.hpp rename to src/ostd/data_types/BaseObject.hpp index f1fb914..4b8a66a 100755 --- a/src/ostd/BaseObject.hpp +++ b/src/ostd/data_types/BaseObject.hpp @@ -1,11 +1,28 @@ -#ifndef __BASE_OBJECT_HPP__ -#define __BASE_OBJECT_HPP__ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 #include - -#include +#include namespace ostd { @@ -20,7 +37,7 @@ namespace ostd virtual inline uint64_t getID(void) const { return m_uid; } virtual inline void setID(uint64_t id) { m_uid = id; } - + virtual inline bool isValid(void) const { return !isInvalid(); } virtual inline bool isInvalid(void) const { return !m_valid || m_oid == 0; } virtual inline void invalidate(void) { m_valid = false; } @@ -30,12 +47,12 @@ namespace ostd inline uint64_t getCompareOID(void) const { return m_oid; } inline bool compareByOID(const BaseObject& other) const { return m_oid == other.m_oid; } - inline static BaseObject& InvalidRef(void) { return BaseObject::s_invalid_obj; } - + inline static BaseObject& InvalidRef(void) { return BaseObject::s_invalid_obj; } + inline void setTypeName(const String& tn) { m_typeName = tn; } inline String getTypeName(void) const { return m_typeName; } String getObjectHeaderString(void) const; - + inline bool signalsEnabled(void) { return m_signalsEnabled; } inline void enableSignals(bool e = true) { m_signalsEnabled = e; } @@ -44,7 +61,7 @@ namespace ostd virtual inline void handleSignal(tSignal& signal) { } void connectSignal(uint32_t signal_id); - + void __handle_signal(tSignal& signal); friend std::ostream& operator<<(std::ostream& os, const BaseObject& obj); @@ -64,8 +81,4 @@ namespace ostd inline static uint64_t s_next_oid { 1024 }; static BaseObject s_invalid_obj; }; -} - - - -#endif +} diff --git a/src/ostd/Bitfields.hpp b/src/ostd/data_types/Bitfields.hpp similarity index 97% rename from src/ostd/Bitfields.hpp rename to src/ostd/data_types/Bitfields.hpp index 2b85182..f95443b 100755 --- a/src/ostd/Bitfields.hpp +++ b/src/ostd/data_types/Bitfields.hpp @@ -1,5 +1,24 @@ -#ifndef __BITFIELDS_HPP__ -#define __BITFIELDS_HPP__ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 @@ -47,7 +66,7 @@ namespace ostd bool b15 : 1; } bits; }; - union BitField_32 + union BitField_32 { uint32_t value = 0; struct { @@ -235,7 +254,7 @@ namespace ostd default: break; } } - + //16-Bit field static inline bool get(const BitField_16& bf, const uint8_t& bit) { @@ -352,7 +371,7 @@ namespace ostd default: break; } } - + //32-Bit field static inline bool get(const BitField_32& bf, const uint8_t& bit) { @@ -549,7 +568,7 @@ namespace ostd default: break; } } - + //64-Bit field static inline bool get(const BitField_64& bf, const uint8_t& bit) { @@ -907,8 +926,4 @@ namespace ostd } } }; -} // namesoace ox - - - -#endif \ No newline at end of file +} diff --git a/src/ostd/Color.cpp b/src/ostd/data_types/Color.cpp similarity index 98% rename from src/ostd/Color.cpp rename to src/ostd/data_types/Color.cpp index 30b410a..d494983 100755 --- a/src/ostd/Color.cpp +++ b/src/ostd/data_types/Color.cpp @@ -1,9 +1,8 @@ #include "Color.hpp" #include - -#include "Utils.hpp" -#include "Logger.hpp" -#include "IOHandlers.hpp" +#include "../utils/Utils.hpp" +#include "../io/Logger.hpp" +#include "../io/IOHandlers.hpp" namespace ostd { diff --git a/src/ostd/Color.hpp b/src/ostd/data_types/Color.hpp similarity index 65% rename from src/ostd/Color.hpp rename to src/ostd/data_types/Color.hpp index 993c941..537ebd9 100755 --- a/src/ostd/Color.hpp +++ b/src/ostd/data_types/Color.hpp @@ -1,10 +1,29 @@ -#ifndef __COLOR_HPP__ -#define __COLOR_HPP__ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 -#include -#include +#include +#include +#include namespace ostd { @@ -61,7 +80,3 @@ namespace ostd uint8_t a; }; } - - - -#endif diff --git a/src/ostd/Types.hpp b/src/ostd/data_types/Types.hpp similarity index 51% rename from src/ostd/Types.hpp rename to src/ostd/data_types/Types.hpp index 3d26640..4f60619 100755 --- a/src/ostd/Types.hpp +++ b/src/ostd/data_types/Types.hpp @@ -1,5 +1,24 @@ -#ifndef __TYPES_HPP__ -#define __TYPES_HPP__ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 @@ -7,10 +26,6 @@ namespace ostd { - namespace legacy - { - typedef std::string String; - } typedef std::string cpp_string; typedef int64_t QWord; @@ -49,7 +64,3 @@ namespace ostd typedef std::vector ByteStream; } - - - -#endif diff --git a/src/ostd/Console.cpp b/src/ostd/io/Console.cpp similarity index 99% rename from src/ostd/Console.cpp rename to src/ostd/io/Console.cpp index 6dd145c..44d39d9 100644 --- a/src/ostd/Console.cpp +++ b/src/ostd/io/Console.cpp @@ -1,7 +1,6 @@ -#include "Utils.hpp" #include "Console.hpp" - -#include +#include "../vendor/TermColor.hpp" +#include "../utils/Utils.hpp" namespace ostd { diff --git a/src/ostd/Console.hpp b/src/ostd/io/Console.hpp similarity index 85% rename from src/ostd/Console.hpp rename to src/ostd/io/Console.hpp index 5f1a7c2..bd90ec8 100644 --- a/src/ostd/Console.hpp +++ b/src/ostd/io/Console.hpp @@ -1,10 +1,29 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 -#include - -#include "String.hpp" +#include +#include +#include +#include #ifndef WINDOWS_OS #include diff --git a/src/ostd/Errors.cpp b/src/ostd/io/Errors.cpp similarity index 98% rename from src/ostd/Errors.cpp rename to src/ostd/io/Errors.cpp index 998521b..2ea69b8 100755 --- a/src/ostd/Errors.cpp +++ b/src/ostd/io/Errors.cpp @@ -1,6 +1,6 @@ #include "Errors.hpp" #include "Logger.hpp" -#include "String.hpp" +#include "../string/String.hpp" namespace ostd { diff --git a/src/ostd/io/Errors.hpp b/src/ostd/io/Errors.hpp new file mode 100755 index 0000000..ffbe250 --- /dev/null +++ b/src/ostd/io/Errors.hpp @@ -0,0 +1,55 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 +#include + +#define ERROR_DATA() String(CPP_STR(__LINE__)), String(__FILE__) + +namespace ostd +{ + struct tErrorLevel + { + inline static constexpr uint8_t NoError = 0x00; + inline static constexpr uint8_t Warning = 0x01; + inline static constexpr uint8_t Error = 0x02; + inline static constexpr uint8_t Fatal = 0x03; + }; + + class RuntimeError : public BaseObject + { + public: + inline RuntimeError(void) { invalidate(); } + inline RuntimeError(uint8_t group, uint64_t code, uint8_t level, const String& msg) { create(group, code, level, msg); } + RuntimeError& create(uint8_t group, uint64_t code, uint8_t level, const String& msg); + + void fire(const String& extraMessage = "", OutputHandlerBase* outputHandler = nullptr, BaseObject& userData = BaseObject::InvalidRef(), int32_t _line_num = 0, const String& _file_name = ""); + + private: + uint8_t m_errGroup { 0x00 }; + uint8_t m_errLevel { tErrorLevel::NoError }; + uint64_t m_errCode { 0x0000000000000000 }; + String m_message { "" }; + + }; +} diff --git a/src/ostd/File.cpp b/src/ostd/io/File.cpp similarity index 96% rename from src/ostd/File.cpp rename to src/ostd/io/File.cpp index 397f159..b006c24 100755 --- a/src/ostd/File.cpp +++ b/src/ostd/io/File.cpp @@ -1,10 +1,8 @@ #include "File.hpp" -#include "Utils.hpp" -#include "String.hpp" - #include #include #include +#include "../string/String.hpp" namespace ostd { @@ -39,7 +37,7 @@ namespace ostd validate(); return *this; } - + std::vector TextFileBuffer::getLines(const String& separator, bool trim_tokens, bool allow_white_space_only_tokens) { if (!exists()) return { }; diff --git a/src/ostd/File.hpp b/src/ostd/io/File.hpp similarity index 57% rename from src/ostd/File.hpp rename to src/ostd/io/File.hpp index bd369ab..44643ec 100755 --- a/src/ostd/File.hpp +++ b/src/ostd/io/File.hpp @@ -1,10 +1,29 @@ -#ifndef __FILE_HPP__ -#define __FILE_HPP__ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 #include #include +#include +#include namespace ostd { @@ -21,12 +40,12 @@ namespace ostd inline const String& dir(void) const { return m_directoryName; } inline const String& fullName(void) const { return m_fullName; } inline const String& name(void) const { return m_name; } - + inline const String& rawContent(void) { return m_buffer; } std::vector getLines(const String& separator = "\n", bool trim_tokens = true, bool allow_white_space_only_tokens = false); inline bool exists(void) { return isValid(); } - + private: String m_extension { "" }; String m_fullPath { "" }; @@ -38,5 +57,3 @@ namespace ostd String m_buffer { "" }; }; } - -#endif diff --git a/src/ostd/FileSystem.cpp b/src/ostd/io/FileSystem.cpp similarity index 99% rename from src/ostd/FileSystem.cpp rename to src/ostd/io/FileSystem.cpp index 3f1d61c..9eb4c6a 100644 --- a/src/ostd/FileSystem.cpp +++ b/src/ostd/io/FileSystem.cpp @@ -1,4 +1,4 @@ -#include "Utils.hpp" +#include "../utils/Utils.hpp" #include "Logger.hpp" namespace ostd diff --git a/src/ostd/IOHandlers.hpp b/src/ostd/io/IOHandlers.hpp similarity index 60% rename from src/ostd/IOHandlers.hpp rename to src/ostd/io/IOHandlers.hpp index 66a1ac6..bb5cb4e 100644 --- a/src/ostd/IOHandlers.hpp +++ b/src/ostd/io/IOHandlers.hpp @@ -1,9 +1,29 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 -#include -#include +#include +#include +#include +#include namespace ogfx { @@ -193,149 +213,4 @@ namespace ostd OutputHandlerBase& reset(void) override; OutputHandlerBase& clear(void) override; }; - - - namespace legacy - { - struct ConsoleCol - { - inline static constexpr const char* Red = "red"; - inline static constexpr const char* BrightRed = "b-red"; - inline static constexpr const char* OnRed = "o-red"; - inline static constexpr const char* OnBrightRed = "ob-red"; - - inline static constexpr const char* Green = "green"; - inline static constexpr const char* BrightGreen = "b-green"; - inline static constexpr const char* OnGreen = "o-green"; - inline static constexpr const char* OnBrightGreen = "ob-green"; - - inline static constexpr const char* Blue = "blue"; - inline static constexpr const char* BrightBlue = "b-blue"; - inline static constexpr const char* OnBlue = "o-blue"; - inline static constexpr const char* OnBrightBlue = "ob-blue"; - - inline static constexpr const char* Magenta = "magenta"; - inline static constexpr const char* BrightMagenta = "b-magenta"; - inline static constexpr const char* OnMagenta = "o-magenta"; - inline static constexpr const char* OnBrightMagenta = "ob-magenta"; - - inline static constexpr const char* Cyan = "cyan"; - inline static constexpr const char* BrightCyan = "b-cyan"; - inline static constexpr const char* OnCyan = "o-cyan"; - inline static constexpr const char* OnBrightCyan = "ob-cyan"; - - inline static constexpr const char* Yellow = "yellow"; - inline static constexpr const char* BrightYellow = "b-yellow"; - inline static constexpr const char* OnYellow = "o-yellow"; - inline static constexpr const char* OnBrightYellow = "ob-yellow"; - - inline static constexpr const char* Black = "gray"; - inline static constexpr const char* BrightGray = "b-gray"; - inline static constexpr const char* OnBlack = "o-gray"; - inline static constexpr const char* OnBrightGray = "ob-gray"; - - inline static constexpr const char* Gray = "lgray"; - inline static constexpr const char* White = "white"; - inline static constexpr const char* onGray = "o-lgray"; - inline static constexpr const char* OnWhite = "o-white"; - }; - - class IOutputHandler - { - public: - virtual ~IOutputHandler(void) = default; - virtual IOutputHandler& col(String color) = 0; - virtual IOutputHandler& col(const Color& color) = 0; - //virtual IOutputHandler& p(String str) = 0; - virtual IOutputHandler& p(char c) = 0; - virtual IOutputHandler& p(const StringEditor& se) = 0; - //virtual IOutputHandler& p(const BaseObject& bo) = 0; - virtual IOutputHandler& pi(uint8_t i) = 0; - virtual IOutputHandler& pi(int8_t i) = 0; - virtual IOutputHandler& pi(uint16_t i) = 0; - virtual IOutputHandler& pi(int16_t i) = 0; - virtual IOutputHandler& pi(uint32_t i) = 0; - virtual IOutputHandler& pi(int32_t i) = 0; - virtual IOutputHandler& pi(uint64_t i) = 0; - virtual IOutputHandler& pi(int64_t i) = 0; - virtual IOutputHandler& pf(float f, uint8_t precision = 0) = 0; - virtual IOutputHandler& pf(double f, uint8_t precision = 0) = 0; - virtual IOutputHandler& pStyled(const StringEditor& styled) = 0; - virtual IOutputHandler& pStyled(const TextStyleParser::tStyledString& styled) = 0; - virtual IOutputHandler& pStyled(const TextStyleBuilder::IRichStringBase& styled) = 0; - virtual IOutputHandler& nl(void) = 0; - virtual IOutputHandler& flush(void) = 0; - virtual IOutputHandler& reset(void) = 0; - - virtual IOutputHandler& bgcol(const Color& color) = 0; - virtual IOutputHandler& bgcol(String color) = 0; - virtual IOutputHandler& resetColors(void) = 0; - virtual IOutputHandler& clear(void) = 0; - }; - - class ConsoleOutputHandler : public IOutputHandler - { - public: - IOutputHandler& col(String color) override; - IOutputHandler& col(const Color& color) override; - inline IOutputHandler& bgcol(const Color& color) override { return *this; } - inline IOutputHandler& bgcol(String color) override { return *this; } - inline IOutputHandler& resetColors(void) override { return *this; } - //IOutputHandler& p(String str); - IOutputHandler& p(char c) override; - IOutputHandler& p(const StringEditor& se) override; - //IOutputHandler& p(const BaseObject& bo); - IOutputHandler& pi(uint8_t i) override; - IOutputHandler& pi(int8_t i) override; - IOutputHandler& pi(uint16_t i) override; - IOutputHandler& pi(int16_t i) override; - IOutputHandler& pi(uint32_t i) override; - IOutputHandler& pi(int32_t i) override; - IOutputHandler& pi(uint64_t i) override; - IOutputHandler& pi(int64_t i) override; - IOutputHandler& pf(float f, uint8_t precision = 0) override; - IOutputHandler& pf(double f, uint8_t precision = 0) override; - IOutputHandler& pStyled(const StringEditor& styled) override; - IOutputHandler& pStyled(const TextStyleParser::tStyledString& styled) override; - IOutputHandler& pStyled(const TextStyleBuilder::IRichStringBase& styled) override; - IOutputHandler& nl(void) override; - IOutputHandler& flush(void) override; - IOutputHandler& reset(void) override; - IOutputHandler& clear(void) override; - }; - - class BufferedOutputHandler : public IOutputHandler - { - public: - inline IOutputHandler& col(String color) override { return *this; } - inline IOutputHandler& col(const Color& color) override { return *this; } - inline IOutputHandler& bgcol(const Color& color) override { return *this; } - inline IOutputHandler& bgcol(String color) override { return *this; } - inline IOutputHandler& resetColors(void) override { return *this; } - IOutputHandler& p(char c) override; - IOutputHandler& p(const StringEditor& se) override; - IOutputHandler& pi(uint8_t i) override; - IOutputHandler& pi(int8_t i) override; - IOutputHandler& pi(uint16_t i) override; - IOutputHandler& pi(int16_t i) override; - IOutputHandler& pi(uint32_t i) override; - IOutputHandler& pi(int32_t i) override; - IOutputHandler& pi(uint64_t i) override; - IOutputHandler& pi(int64_t i) override; - IOutputHandler& pf(float f, uint8_t precision = 0) override; - IOutputHandler& pf(double f, uint8_t precision = 0) override; - IOutputHandler& pStyled(const StringEditor& styled) override { return *this; }; - inline IOutputHandler& pStyled(const TextStyleParser::tStyledString& styled) override { return *this; } - inline IOutputHandler& pStyled(const TextStyleBuilder::IRichStringBase& styled) override { return *this; }; - IOutputHandler& nl(void) override; - inline IOutputHandler& flush(void) override { return *this; } - inline IOutputHandler& reset(void) override { return *this; } - - inline IOutputHandler& clear(void) override { m_buffer = ""; return *this; } - inline const StringEditor& getBuffer(void) { return m_buffer; } - - private: - StringEditor m_buffer; - }; - } } diff --git a/src/ostd/Json.cpp b/src/ostd/io/Json.cpp similarity index 99% rename from src/ostd/Json.cpp rename to src/ostd/io/Json.cpp index a4b5150..f0931a9 100644 --- a/src/ostd/Json.cpp +++ b/src/ostd/io/Json.cpp @@ -1,10 +1,9 @@ #include "Json.hpp" #include -#include -#include -#include -#include -#include +#include "../io/File.hpp" +#include "../io/Logger.hpp" +#include "../math/Geometry.hpp" +#include "../string/String.hpp" namespace ostd { @@ -455,7 +454,7 @@ namespace ostd } } }; - } // namespace detail + } static inline bool __navigate_json_path(const ostd::String& path, json*& outSource, ostd::String& outName) diff --git a/src/ostd/Json.hpp b/src/ostd/io/Json.hpp similarity index 74% rename from src/ostd/Json.hpp rename to src/ostd/io/Json.hpp index 23950e4..f2b6ca8 100644 --- a/src/ostd/Json.hpp +++ b/src/ostd/io/Json.hpp @@ -1,8 +1,28 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 -#include +#include +#include +#include #include // IWYU pragma: keep namespace ostd diff --git a/src/ostd/Keyboard.cpp b/src/ostd/io/Keyboard.cpp similarity index 97% rename from src/ostd/Keyboard.cpp rename to src/ostd/io/Keyboard.cpp index 7db15df..c6fc03c 100644 --- a/src/ostd/Keyboard.cpp +++ b/src/ostd/io/Keyboard.cpp @@ -1,7 +1,6 @@ #include "Console.hpp" - #include - + namespace ostd { KeyboardController::KeyboardController(void) @@ -17,12 +16,12 @@ namespace ostd tcsetattr(0, TCSANOW, &new_settings); peek_character = -1; #endif - + m_cmd = ""; m_output_enabled = true; m_cmd_buffer_enabled = true; } - + KeyboardController::~KeyboardController(void) { #ifndef WINDOWS_OS @@ -30,7 +29,7 @@ namespace ostd #endif } -#ifndef WINDOWS_OS +#ifndef WINDOWS_OS int KeyboardController::kbhit(void) { unsigned char ch; @@ -49,7 +48,7 @@ namespace ostd } return 0; } - + int KeyboardController::getch(void) { char ch; @@ -64,7 +63,7 @@ namespace ostd return ch; } #endif - + String KeyboardController::getKeyBuffer(void) { std::string __str = ""; @@ -98,7 +97,7 @@ namespace ostd m_key_buff.clear(); return __str; } - + eKeys KeyboardController::waitForKeyPress(void) //TODO: Add sleep to this method { eKeys key = eKeys::NoKeyPressed; @@ -114,7 +113,7 @@ namespace ostd if(kbhit()) { k1 = getch(); - + if (k1 == 127 || k1 == 8) { key = eKeys::Backspace; @@ -128,7 +127,7 @@ namespace ostd key = eKeys::Enter; if (isOutputEnabled()) std::cout << "\n" << std::flush; - if (isCommandBufferEnabled()) + if (isCommandBufferEnabled()) m_cmd = flushKeyBuffer(); } else if (k1 == 9) @@ -153,7 +152,7 @@ namespace ostd if (!kbhit()) { key = eKeys::Escape; - return key; + return key; } k2 = getch(); if (k2 == 91) @@ -180,10 +179,9 @@ namespace ostd key = eKeys::Escape; } #endif - + } else key = eKeys::NoKeyPressed; return key; } -} - +} diff --git a/src/ostd/Logger.cpp b/src/ostd/io/Logger.cpp similarity index 95% rename from src/ostd/Logger.cpp rename to src/ostd/io/Logger.cpp index 3341d27..eaa9cf5 100755 --- a/src/ostd/Logger.cpp +++ b/src/ostd/io/Logger.cpp @@ -1,9 +1,6 @@ #include "Logger.hpp" - #include #include -#include -#include "vendor/TermColor.hpp" #include "IOHandlers.hpp" namespace ostd @@ -21,7 +18,7 @@ namespace ostd va_start(arg_ptr, message); vsnprintf(buffer, sizeof(buffer), message.c_str(), arg_ptr); va_end(arg_ptr); - + switch (log_level) { case tLogLevel::Fatal: @@ -55,4 +52,4 @@ namespace ostd { m_out = &__destination; //TODO: Destroy old (only if still default) } -} +} diff --git a/src/ostd/Logger.hpp b/src/ostd/io/Logger.hpp similarity index 66% rename from src/ostd/Logger.hpp rename to src/ostd/io/Logger.hpp index 5f094f8..6e4d69e 100755 --- a/src/ostd/Logger.hpp +++ b/src/ostd/io/Logger.hpp @@ -1,7 +1,26 @@ -#ifndef __LOGGER_HPP__ -#define __LOGGER_HPP__ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 OmniaX-Dev -#include + 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 namespace ostd { @@ -27,14 +46,14 @@ namespace ostd private: static OutputHandlerBase* m_out; }; -} +} #define OX_LOG_WARN_ENABLED 1 #define OX_LOG_INFO_ENABLED 1 #define OX_LOG_DEBUG_ENABLED 1 #define OX_LOG_TRACE_ENABLED 1 -#if OX_RELEASE == 1 +#if OX_RELEASE_BUILD == 1 #define OX_LOG_DEBUG_ENABLED 0 #define OX_LOG_TRACE_ENABLED 0 #endif @@ -61,5 +80,3 @@ namespace ostd #else #define OX_TRACE(message, ...) #endif - -#endif diff --git a/src/ostd/Midi.cpp b/src/ostd/io/Midi.cpp similarity index 94% rename from src/ostd/Midi.cpp rename to src/ostd/io/Midi.cpp index 0551ebd..036f1ce 100644 --- a/src/ostd/Midi.cpp +++ b/src/ostd/io/Midi.cpp @@ -1,11 +1,9 @@ #include "Midi.hpp" -#include #include #include #include #include - - +#include "../vendor/midifile/MidiFile.h" namespace ostd { diff --git a/src/ostd/Midi.hpp b/src/ostd/io/Midi.hpp similarity index 79% rename from src/ostd/Midi.hpp rename to src/ostd/io/Midi.hpp index 53f04ef..4d7329c 100644 --- a/src/ostd/Midi.hpp +++ b/src/ostd/io/Midi.hpp @@ -1,7 +1,27 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 +#include +#include namespace ostd { diff --git a/src/ostd/io/OutputHandlers.cpp b/src/ostd/io/OutputHandlers.cpp new file mode 100755 index 0000000..fd7e929 --- /dev/null +++ b/src/ostd/io/OutputHandlers.cpp @@ -0,0 +1,216 @@ +#include "../utils/Utils.hpp" +#include +#include +#include "Logger.hpp" +#include "IOHandlers.hpp" +#include "../vendor/TermColor.hpp" +#include "../data_types/BaseObject.hpp" +#include "../string/TextStyleParser.hpp" +#include "../string/String.hpp" + +namespace ostd +{ + std::ostream &operator<<(std::ostream &os, ConsoleColors::tConsoleColor const &col) + { + if (col.background) + { + if (col.name == "red") os << termcolor::on_red; + else if (col.name == "brightred") os << termcolor::on_bright_red; + else if (col.name == "green") os << termcolor::on_green; + else if (col.name == "brightgreen") os << termcolor::on_bright_green; + else if (col.name == "blue") os << termcolor::on_blue; + else if (col.name == "brightblue") os << termcolor::on_bright_blue; + else if (col.name == "magenta") os << termcolor::on_magenta; + else if (col.name == "brightmagenta") os << termcolor::on_bright_magenta; + else if (col.name == "cyan") os << termcolor::on_cyan; + else if (col.name == "brightcyan") os << termcolor::on_bright_cyan; + else if (col.name == "yellow") os << termcolor::on_yellow; + else if (col.name == "brightyellow") os << termcolor::on_bright_yellow; + else if (col.name == "black") os << termcolor::on_grey; + else if (col.name == "darkgray") os << termcolor::on_bright_grey; + else if (col.name == "brightgray") os << termcolor::on_white; + else if (col.name == "white") os << termcolor::on_bright_white; + return os; + } + if (col.name == "red") os << termcolor::red; + else if (col.name == "brightred") os << termcolor::bright_red; + else if (col.name == "green") os << termcolor::green; + else if (col.name == "brightgreen") os << termcolor::bright_green; + else if (col.name == "blue") os << termcolor::blue; + else if (col.name == "brightblue") os << termcolor::bright_blue; + else if (col.name == "magenta") os << termcolor::magenta; + else if (col.name == "brightmagenta") os << termcolor::bright_magenta; + else if (col.name == "cyan") os << termcolor::cyan; + else if (col.name == "brightcyan") os << termcolor::bright_cyan; + else if (col.name == "yellow") os << termcolor::yellow; + else if (col.name == "brightyellow") os << termcolor::bright_yellow; + else if (col.name == "black") os << termcolor::grey; + else if (col.name == "darkgray") os << termcolor::bright_grey; + else if (col.name == "brightgray") os << termcolor::white; + else if (col.name == "white") os << termcolor::bright_white; + return os; + } + + + + OutputHandlerBase& ConsoleOutputHandler::bg(const ConsoleColors::tConsoleColor& color) + { + std::cout << color.asBackground(); + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::bg(const String& color) + { + std::cout << ConsoleColors::getFromName(color, true); + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::fg(const ConsoleColors::tConsoleColor& color) + { + std::cout << color.asForeground(); + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::fg(const String& color) + { + std::cout << ConsoleColors::getFromName(color, false); + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::pChar(char c) + { + std::cout << (char)c; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::pStyled(const String& styled) + { + return pStyled(TextStyleParser::parse(styled)); + } + + OutputHandlerBase& ConsoleOutputHandler::pStyled(const TextStyleParser::tStyledString& styled) + { + std::cout << styled; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::pStyled(TextStyleBuilder::IRichStringBase& styled) + { + std::cout << styled; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::pObject(const BaseObject& bo) + { + std::cout << bo; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::p(const String& se) + { + std::cout << se; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::p(uint8_t i) + { + std::cout << (uint8_t)i; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::p(int8_t i) + { + std::cout << (int8_t)i; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::p(uint16_t i) + { + std::cout << (uint16_t)i; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::p(int16_t i) + { + std::cout << (int16_t)i; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::p(uint32_t i) + { + std::cout << (uint32_t)i; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::p(int32_t i) + { + std::cout << (int32_t)i; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::p(uint64_t i) + { + std::cout << (uint64_t)i; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::p(int64_t i) + { + std::cout << (int64_t)i; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::p(float f, uint8_t precision) + { + if (precision == 0) + { + std::cout << f; + } + else + { + std::ios cout_state(nullptr); + std::cout << std::fixed << std::setprecision(precision) << f; + std::cout.copyfmt(cout_state); + } + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::p(double f, uint8_t precision) + { + if (precision == 0) + { + std::cout << f; + } + else + { + std::ios cout_state(nullptr); + std::cout << std::fixed << std::setprecision(precision) << f; + std::cout.copyfmt(cout_state); + } + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::nl(void) + { + std::cout << "\n"; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::flush(void) + { + std::cout << std::flush; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::reset(void) + { + std::cout << termcolor::reset; + return *this; + } + + OutputHandlerBase& ConsoleOutputHandler::clear(void) + { + Utils::clearConsole(); + return *this; + } +} diff --git a/src/ostd/Serial.cpp b/src/ostd/io/Serial.cpp similarity index 99% rename from src/ostd/Serial.cpp rename to src/ostd/io/Serial.cpp index adc0c71..540f27a 100755 --- a/src/ostd/Serial.cpp +++ b/src/ostd/io/Serial.cpp @@ -1,6 +1,5 @@ #include "Serial.hpp" -#include "vendor/TermColor.hpp" -#include "Utils.hpp" +#include "../utils/Utils.hpp" namespace ostd { @@ -44,7 +43,7 @@ namespace ostd else return false; return true; } - + bool SerialIO::r_DWord(StreamIndex addr, DWord& outVal) { if (!is_validAddr(addr, tTypeSize::DWORD)) return false; @@ -65,7 +64,7 @@ namespace ostd else return false; return true; } - + bool SerialIO::r_Word(StreamIndex addr, Word& outVal) { if (!is_validAddr(addr, tTypeSize::WORD)) return false; @@ -82,14 +81,14 @@ namespace ostd else return false; return true; } - + bool SerialIO::r_Byte(StreamIndex addr, Byte& outVal) { if (!is_validAddr(addr, tTypeSize::BYTE)) return false; outVal = m_data[addr]; return true; } - + bool SerialIO::r_Addr(StreamIndex addr, StreamIndex& outVal) { if (!is_validAddr(addr, tTypeSize::ADDR)) return false; @@ -164,7 +163,7 @@ namespace ostd outVal = dp.val; return true; } - + bool SerialIO::r_ByteStream(StreamIndex addr, ByteStream& outStream) { if (!is_validAddr(addr, tTypeSize::ADDR)) return false; @@ -256,7 +255,7 @@ namespace ostd else return false; return true; } - + bool SerialIO::w_DWord(StreamIndex addr, DWord val) { m_statuWriting = true; @@ -278,7 +277,7 @@ namespace ostd else return false; return true; } - + bool SerialIO::w_Word(StreamIndex addr, Word val) { m_statuWriting = true; @@ -296,7 +295,7 @@ namespace ostd else return false; return true; } - + bool SerialIO::w_Byte(StreamIndex addr, Byte val) { m_statuWriting = true; @@ -304,7 +303,7 @@ namespace ostd m_data[addr] = val; return true; } - + bool SerialIO::w_Addr(StreamIndex addr, StreamIndex val) { m_statuWriting = true; @@ -449,10 +448,10 @@ namespace ostd power *= 2; Utils::printByteStream(m_data, start, line_len, power / line_len, out); } - + bool SerialIO::saveToFile(const String& filePath) { return Utils::saveByteStreamToFile(getData(), filePath); } - } // namespace serial -} // namesoace ostd + } +} diff --git a/src/ostd/Serial.hpp b/src/ostd/io/Serial.hpp similarity index 75% rename from src/ostd/Serial.hpp rename to src/ostd/io/Serial.hpp index d832a3b..e380f29 100755 --- a/src/ostd/Serial.hpp +++ b/src/ostd/io/Serial.hpp @@ -1,10 +1,28 @@ -#ifndef __SERIAL_HPP__ -#define __SERIAL_HPP__ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 OmniaX-Dev -#include -#include -#include -#include + 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 +#include namespace ostd { @@ -70,7 +88,5 @@ namespace ostd public: inline static constexpr uint64_t DefaultMaxSize = 512; }; - } //namespace serial -} // namespace ostd - -#endif + } +} diff --git a/src/ostd/Geometry.cpp b/src/ostd/math/Geometry.cpp similarity index 84% rename from src/ostd/Geometry.cpp rename to src/ostd/math/Geometry.cpp index b0a1200..c4ce1a8 100755 --- a/src/ostd/Geometry.cpp +++ b/src/ostd/math/Geometry.cpp @@ -1,7 +1,5 @@ #include "Geometry.hpp" - -#include -#include "String.hpp" +#include "../string/String.hpp" namespace ostd { @@ -13,4 +11,4 @@ namespace ostd { return String("{ ").add(x).add(", ").add(y).add(", ").add(z).add(" }"); } -} +} diff --git a/src/ostd/Geometry.hpp b/src/ostd/math/Geometry.hpp similarity index 91% rename from src/ostd/Geometry.hpp rename to src/ostd/math/Geometry.hpp index b2e7d36..7e15383 100755 --- a/src/ostd/Geometry.hpp +++ b/src/ostd/math/Geometry.hpp @@ -1,10 +1,47 @@ -#ifndef __GEOMETRY_HPP__ -#define __GEOMETRY_HPP__ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 #include -#include +#include + +#define PI 3.1415926535898f +#define TWO_PI PI * 2.0f +#define HALF_PI PI / 2.0f +#define QUARTER_PI PI / 4.0f +#define DEG_TO_RAD(deg) (float)(deg * (PI / 180.0f)) +#define RAD_TO_DEG(rad) (float)(rad * (180.0f / PI)) + +#define LERP(n1, n2, f) (n2 - n1) * f + n1 +#define CAP(n, max) (n > max ? max : n) +#define CAPD(n, min) (n < min ? min : n) +#define CAPB(n, min, max) (n < min ? min : (n > max ? max : n)) +#define MAX(n1, n2) std::max(n1, n2) +#define MIN(n1, n2) std::min(n1, n2) +#define PROPORTION(w, x, y) ((x * w) / y) + +#define CONVERT_1D_2D(i, width) ostd::IPoint(i % width, i / width) +#define CONVERT_2D_1D(x, y, width) (x + width * y) namespace ostd { @@ -404,5 +441,3 @@ namespace ostd typedef Line I16Line; typedef Line I8Line; } - - #endif diff --git a/src/ostd/Random.cpp b/src/ostd/math/Random.cpp similarity index 100% rename from src/ostd/Random.cpp rename to src/ostd/math/Random.cpp diff --git a/src/ostd/Random.hpp b/src/ostd/math/Random.hpp similarity index 82% rename from src/ostd/Random.hpp rename to src/ostd/math/Random.hpp index 410d57c..93e466e 100755 --- a/src/ostd/Random.hpp +++ b/src/ostd/math/Random.hpp @@ -1,9 +1,28 @@ -#ifndef __RANDOM_HPP__ -#define __RANDOM_HPP__ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 -#include +#include #include namespace ostd @@ -87,5 +106,3 @@ namespace ostd inline static RandomGenerator s_gen; }; } - -#endif diff --git a/src/ostd/ShuntingYard.cpp b/src/ostd/math/ShuntingYard.cpp similarity index 94% rename from src/ostd/ShuntingYard.cpp rename to src/ostd/math/ShuntingYard.cpp index 460696d..4a1b2f1 100644 --- a/src/ostd/ShuntingYard.cpp +++ b/src/ostd/math/ShuntingYard.cpp @@ -1,24 +1,11 @@ -// --- --- -// This file uses the following materials. -// (1) Wikipedia article [Shunting-yard algorithm](https://en.wikipedia.org/wiki/Shunting-yard_algorithm), -// which is released under the [Creative Commons Attribution-Share-Alike License 3.0](https://creativecommons.org/licenses/by-sa/3.0/). -// (2) [Implementation notes for unary operators in Shunting-Yard algorithm](https://stackoverflow.com/a/5240912) by Austin Taylor -// which is released under the [Creative Commons Attribution-Share-Alike License 2.5](https://creativecommons.org/licenses/by-sa/2.5/). -// --- --- - - -#include -#include +#include "../utils/Utils.hpp" +#include "../string/String.hpp" #include #include #include -#include #include #include -#include "String.hpp" -#include "Utils.hpp" - namespace ostd { @@ -346,4 +333,4 @@ namespace ostd return stack.back(); } -} \ No newline at end of file +} diff --git a/src/ostd/SineWave.cpp b/src/ostd/math/SineWave.cpp similarity index 100% rename from src/ostd/SineWave.cpp rename to src/ostd/math/SineWave.cpp diff --git a/src/ostd/SineWave.hpp b/src/ostd/math/SineWave.hpp similarity index 52% rename from src/ostd/SineWave.hpp rename to src/ostd/math/SineWave.hpp index 41c0512..c00edee 100755 --- a/src/ostd/SineWave.hpp +++ b/src/ostd/math/SineWave.hpp @@ -1,10 +1,28 @@ -#ifndef __SINE_WAVE_HPP__ -#define __SINE_WAVE_HPP__ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 - -#include +#include namespace ostd { @@ -34,6 +52,4 @@ namespace ostd std::vector waves; std::vector additiveWaves; }; -} - -#endif +} diff --git a/src/ostd/Spline.cpp b/src/ostd/math/Spline.cpp similarity index 74% rename from src/ostd/Spline.cpp rename to src/ostd/math/Spline.cpp index 1ea4799..70dde38 100755 --- a/src/ostd/Spline.cpp +++ b/src/ostd/math/Spline.cpp @@ -1,5 +1,4 @@ #include "Spline.hpp" -#include "WindowBase.hpp" namespace ostd { @@ -9,36 +8,36 @@ namespace ostd void Spline::handleSignal(tSignal& signal) { - if (!isEditable()) return; - if (isUsingCustomEventHandler() && m_eventHandlerCallback) - { - m_eventHandlerCallback(signal); - return; - } - if (signal.ID == tBuiltinSignals::MousePressed) - { - ogfx::MouseEventData& evt = static_cast(signal.userData); - for (auto& node : m_points) - { - if (ostd::Rectangle(node.position.x - 20, node.position.y - 20, 40, 40).contains((float)evt.position_x, (float)evt.position_y)) - { - m_selectedNode = &node; - return; - } - } - } - else if (signal.ID == tBuiltinSignals::MouseReleased) - { - if (m_selectedNode != nullptr) - updateTotalLength(); - m_selectedNode = nullptr; - } - else if (signal.ID == tBuiltinSignals::MouseMoved) - { - ogfx::MouseEventData& evt = static_cast(signal.userData); - if (m_selectedNode != nullptr) - m_selectedNode->position = { (float)evt.position_x, (float)evt.position_y }; - } + // if (!isEditable()) return; + // if (isUsingCustomEventHandler() && m_eventHandlerCallback) + // { + // m_eventHandlerCallback(signal); + // return; + // } + // if (signal.ID == tBuiltinSignals::MousePressed) + // { + // ogfx::MouseEventData& evt = static_cast(signal.userData); + // for (auto& node : m_points) + // { + // if (ostd::Rectangle(node.position.x - 20, node.position.y - 20, 40, 40).contains((float)evt.position_x, (float)evt.position_y)) + // { + // m_selectedNode = &node; + // return; + // } + // } + // } + // else if (signal.ID == tBuiltinSignals::MouseReleased) + // { + // if (m_selectedNode != nullptr) + // updateTotalLength(); + // m_selectedNode = nullptr; + // } + // else if (signal.ID == tBuiltinSignals::MouseMoved) + // { + // ogfx::MouseEventData& evt = static_cast(signal.userData); + // if (m_selectedNode != nullptr) + // m_selectedNode->position = { (float)evt.position_x, (float)evt.position_y }; + // } } tSplineNode Spline::getPoint(float t) diff --git a/src/ostd/Spline.hpp b/src/ostd/math/Spline.hpp similarity index 71% rename from src/ostd/Spline.hpp rename to src/ostd/math/Spline.hpp index 3b0ab24..0930802 100755 --- a/src/ostd/Spline.hpp +++ b/src/ostd/math/Spline.hpp @@ -1,30 +1,28 @@ /* -License -~~~~~~~ -Copyright (C) 2018 Javidx9 -GNU GPLv3 https://github.com/OneLoneCoder/videos/blob/master/LICENSE + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 OmniaX-Dev -Author -~~~~~~ - Twitter: @javidx9 - Blog: www.onelonecoder.com - Original works located at: - https://www.github.com/onelonecoder - https://www.onelonecoder.com - https://www.youtube.com/javidx9 + This file is part of OmniaFramework. - Videos Explaining Splines: - ~~~~~~~~~~~~~~~~~~~~~~~~ - https://youtu.be/9_aJGUTePYo - https://youtu.be/DzjtU4WLYNs + 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 . */ -#ifndef __SPLINE_HPP__ -#define __SPLINE_HPP__ +#pragma once #include -#include -#include +#include +#include namespace ostd { @@ -34,7 +32,6 @@ namespace ostd float length; }; - class RenderCore; class Spline : public BaseObject { public: @@ -79,5 +76,3 @@ namespace ostd DrawCallback m_drawCallback { nullptr }; }; } - -#endif diff --git a/src/ostd/ostd.hpp b/src/ostd/ostd.hpp new file mode 100644 index 0000000..1d9009f --- /dev/null +++ b/src/ostd/ostd.hpp @@ -0,0 +1,45 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include diff --git a/src/ostd/String.cpp b/src/ostd/string/String.cpp similarity index 99% rename from src/ostd/String.cpp rename to src/ostd/string/String.cpp index 28074ed..cfcb9a2 100644 --- a/src/ostd/String.cpp +++ b/src/ostd/string/String.cpp @@ -1,8 +1,8 @@ -#include "Utils.hpp" #include "String.hpp" #include #include #include +#include "../utils/Utils.hpp" namespace ostd { diff --git a/src/ostd/String.hpp b/src/ostd/string/String.hpp similarity index 65% rename from src/ostd/String.hpp rename to src/ostd/string/String.hpp index 2db159f..a867fb2 100644 --- a/src/ostd/String.hpp +++ b/src/ostd/string/String.hpp @@ -1,8 +1,28 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 #include +#include namespace ostd { @@ -26,7 +46,7 @@ namespace ostd inline auto cend(void) const { return m_tokens.end(); } inline auto begin(void) const { return m_tokens.begin(); } inline auto end(void) const { return m_tokens.end(); } - + private: inline Tokens(void) { m_current_index = 0; } @@ -148,115 +168,6 @@ namespace ostd private: ostd::cpp_string m_data; }; - - - - - - namespace legacy - { - class StringEditor - { - public: class Tokens - { - public: - inline bool hasNext(void) { return m_tokens.size() > 0 && m_current_index < m_tokens.size(); } - inline bool hasPrevious(void) { return m_tokens.size() > 0 && m_current_index > 0; } - String next(void); - String previous(void); - inline uint32_t count(void) { return m_tokens.size(); } - inline std::vector getRawData(void) { return m_tokens; } - inline uint32_t getCurrentIndex(void) { return m_current_index; } - inline void cycle(void) { m_current_index = 0; } - - inline auto begin(void) { return m_tokens.begin(); } - inline auto end(void) { return m_tokens.end(); } - inline auto cbegin(void) const { return m_tokens.begin(); } - inline auto cend(void) const { return m_tokens.end(); } - inline auto begin(void) const { return m_tokens.begin(); } - inline auto end(void) const { return m_tokens.end(); } - - private: - inline Tokens(void) { m_current_index = 0; } - - private: - std::vector m_tokens; - uint32_t m_current_index; - - public: - inline static const String END = "%END%"; - - friend class StringEditor; - }; - - public: - inline StringEditor(void) { m_data = ""; } - inline StringEditor(const String& str) { m_data = str; } - inline StringEditor(const char* str) { m_data = str; } - inline String str(void) const { return m_data; } - inline uint32_t len(void) const { return m_data.length(); } - inline StringEditor& clr(void) { m_data = ""; return *this; } - inline const char* c_str(void) const { return m_data.c_str(); } - inline char at(uint32_t index) const { return m_data[index]; } - inline char operator[](uint32_t index) const { return m_data[index]; } - inline StringEditor& set(String str) { m_data = str; return *this; } - - StringEditor& ltrim(void); - StringEditor& rtrim(void); - StringEditor& trim(void); - - StringEditor& toLower(void); - StringEditor& toUpper(void); - - StringEditor& addPadding(char c = ' ', uint32_t count = 10); - //StringEditor& add(const StringEditor& se); - StringEditor& add(String str); - StringEditor& add(char c); - StringEditor& addi(uint8_t i); - StringEditor& addi(int8_t i); - StringEditor& addi(uint16_t i); - StringEditor& addi(int16_t i); - StringEditor& addi(uint32_t i); - StringEditor& addi(int32_t i); - StringEditor& addi(uint64_t i); - StringEditor& addi(int64_t i); - StringEditor& addf(float f); - StringEditor& addf(double f); - - StringEditor& reverse(void); - StringEditor& replaceAll(String what, String with); - StringEditor& replaceFirst(String what, String with); - StringEditor& regexReplace(String regex_pattern, String replace_with, bool case_insensitive = false); - - StringEditor& put(uint32_t index, char c); - - int64_t toInt(void); - float toFloat(void); - double toDouble(void); - bool isNumeric(bool decimal = false); - bool contains(char c); - bool contains(String str); - bool startsWith(String str); - bool endsWith(String str); - String getReverse(void); - - uint32_t count(String str); - - int32_t indexOf(char c, uint32_t start = 0); - int32_t indexOf(String str, uint32_t start = 0); - int32_t lastIndexOf(char c); - int32_t lastIndexOf(String str); - - String substr(uint32_t start, int32_t end = -1); - Tokens tokenize(String delimiter = " ", bool trim_tokens = true, bool allow_white_space_only_tokens = false); - - friend std::ostream& operator<<(std::ostream& out, const StringEditor& val); - - private: - String m_data; - }; - } - } @@ -269,4 +180,4 @@ struct std::hash hash hasher; return hasher(str.cpp_str()); } -}; \ No newline at end of file +}; diff --git a/src/ostd/TextStyleParser.cpp b/src/ostd/string/TextStyleParser.cpp similarity index 99% rename from src/ostd/TextStyleParser.cpp rename to src/ostd/string/TextStyleParser.cpp index 467283c..233bc20 100644 --- a/src/ostd/TextStyleParser.cpp +++ b/src/ostd/string/TextStyleParser.cpp @@ -1,5 +1,5 @@ #include "TextStyleParser.hpp" -#include "IOHandlers.hpp" +#include "../io/IOHandlers.hpp" namespace ostd { diff --git a/src/ostd/TextStyleParser.hpp b/src/ostd/string/TextStyleParser.hpp similarity index 84% rename from src/ostd/TextStyleParser.hpp rename to src/ostd/string/TextStyleParser.hpp index 3fe241f..99a9ef4 100644 --- a/src/ostd/TextStyleParser.hpp +++ b/src/ostd/string/TextStyleParser.hpp @@ -1,6 +1,26 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 { diff --git a/src/ostd/utils/Defines.hpp b/src/ostd/utils/Defines.hpp new file mode 100755 index 0000000..9c23ac2 --- /dev/null +++ b/src/ostd/utils/Defines.hpp @@ -0,0 +1,56 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 + +#if defined(_WIN32) || defined(_WIN64) + #define WINDOWS_OS + #ifdef _WIN32_WINNT + #undef _WIN32_WINNT + #endif + #define _WIN32_WINNT 0x0501 +#elif defined(__APPLE__) + #define MAC_OS +#else + #define LINUX_OS +#endif + +//Basic constants +#if !defined(BUILD_NR) + #define BUILD_NR 0 +#endif +#if !defined(MAJ_V) + #define MAJ_V 0 +#endif +#if !defined(MIN_V) + #define MIN_V 0 +#endif +#if !defined(VERSION_STR) + #define VERSION_STR "0.0.0" +#endif +#if !defined(NULL) + #define NULL 0 +#endif + +#ifndef OX_DEBUG_BUILD + #ifndef OX_RELEASE_BUILD + #define OX_RELEASE_BUILD + #endif +#endif diff --git a/src/ostd/Logic.cpp b/src/ostd/utils/Logic.cpp similarity index 98% rename from src/ostd/Logic.cpp rename to src/ostd/utils/Logic.cpp index aa00a0a..a2980da 100755 --- a/src/ostd/Logic.cpp +++ b/src/ostd/utils/Logic.cpp @@ -1,6 +1,5 @@ #include "Logic.hpp" -#include "Utils.hpp" -#include "String.hpp" +#include "../string/String.hpp" #ifndef __APPLE__ #include #endif diff --git a/src/ostd/utils/Logic.hpp b/src/ostd/utils/Logic.hpp new file mode 100755 index 0000000..2486b21 --- /dev/null +++ b/src/ostd/utils/Logic.hpp @@ -0,0 +1,52 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 + +namespace ostd +{ + enum class eLogicOp + { + AND = 0, + OR, + NOT, + XOR, + + NAND, + NOR, + XNOR, + + O_PARENTH = 125, + C_PARENTH = 126, + NONE = 127 + }; + + class LogicEvaluator + { + public: + static bool eval(String exp); + + private: + static bool applyOp(bool a, bool b, eLogicOp op); + static eLogicOp parseOp(char op); + }; +} diff --git a/src/ostd/PathFinder.cpp b/src/ostd/utils/PathFinder.cpp similarity index 99% rename from src/ostd/PathFinder.cpp rename to src/ostd/utils/PathFinder.cpp index a059d79..788e857 100755 --- a/src/ostd/PathFinder.cpp +++ b/src/ostd/utils/PathFinder.cpp @@ -215,10 +215,10 @@ namespace ostd case eHeuristicType::Diagonal: hh = std::max(std::abs(n.x - __goal.x), std::abs(n.y - __goal.y)); break; - default: + default: hh = 0.0f; break; } return hh; } -} +} diff --git a/src/ostd/PathFinder.hpp b/src/ostd/utils/PathFinder.hpp similarity index 66% rename from src/ostd/PathFinder.hpp rename to src/ostd/utils/PathFinder.hpp index ca274c6..bd5305a 100755 --- a/src/ostd/PathFinder.hpp +++ b/src/ostd/utils/PathFinder.hpp @@ -1,5 +1,24 @@ -#ifndef __PATH_FINDER_HPP__ -#define __PATH_FINDER_HPP__ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 @@ -78,6 +97,4 @@ namespace ostd bool m_initialized; }; -} - -#endif +} diff --git a/src/ostd/QuadTree.cpp b/src/ostd/utils/QuadTree.cpp similarity index 91% rename from src/ostd/QuadTree.cpp rename to src/ostd/utils/QuadTree.cpp index 1f16a20..535bc3d 100755 --- a/src/ostd/QuadTree.cpp +++ b/src/ostd/utils/QuadTree.cpp @@ -1,4 +1,5 @@ #include "QuadTree.hpp" +#include namespace ostd { @@ -13,9 +14,9 @@ namespace ostd pos = position; data = userData; } - - - + + + void QuadTree::destroy(void) { m_nw = nullptr; @@ -30,7 +31,7 @@ namespace ostd m_bounds = { 0, 0, 0, 0 }; setValid(false); } - + void QuadTree::create(Rectangle bounds, uint16_t capacity) { m_bounds = bounds; @@ -50,16 +51,16 @@ namespace ostd { if (m_subdivided) return; auto center = m_bounds.getCenter(); - m_nw = new_un(QuadTree)(Rectangle( + m_nw = std::make_unique(Rectangle( m_bounds.x, m_bounds.y, m_bounds.w / 2, m_bounds.h / 2 ), m_capacity); - m_ne = new_un(QuadTree)(Rectangle( + m_ne = std::make_unique(Rectangle( center.x, m_bounds.y, m_bounds.w / 2, m_bounds.h / 2 ), m_capacity); - m_sw = new_un(QuadTree)(Rectangle( + m_sw = std::make_unique(Rectangle( m_bounds.x, center.y, m_bounds.w / 2, m_bounds.h / 2 ), m_capacity); - m_se = new_un(QuadTree)(Rectangle( + m_se = std::make_unique(Rectangle( center.x, center.y, m_bounds.w / 2, m_bounds.h / 2 ), m_capacity); m_subdivided = true; @@ -106,4 +107,4 @@ namespace ostd m_se->query(range, list); } } -} +} diff --git a/src/ostd/utils/QuadTree.hpp b/src/ostd/utils/QuadTree.hpp new file mode 100755 index 0000000..fbdb85f --- /dev/null +++ b/src/ostd/utils/QuadTree.hpp @@ -0,0 +1,63 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 +#include +#include + +namespace ostd +{ + class QuadTree : public BaseObject + { + public: struct tElement + { + Vec2 pos; + void* data; + tElement(void); + tElement(Vec2 position, void* userData); + }; + public: + inline QuadTree(void) : m_points(nullptr), m_sw(nullptr), m_nw(nullptr), + m_se(nullptr),m_ne(nullptr), m_subdivided(false), + m_capacity(0), m_currentSize(0) + { invalidate(); } + inline QuadTree(Rectangle bounds, uint16_t capacity) { create(bounds, capacity); } + inline ~QuadTree(void) { destroy(); } + void destroy(void); + void create(Rectangle bounds, uint16_t capacity); + void subdivide(void); + bool insert(Vec2 point, void* data = nullptr); + void query(Rectangle range, std::vector& list); + + private: + tElement* m_points; + uint16_t m_currentSize; + uint16_t m_capacity; + Rectangle m_bounds; + bool m_subdivided; + std::unique_ptr m_nw; + std::unique_ptr m_sw; + std::unique_ptr m_ne; + std::unique_ptr m_se; + }; +} diff --git a/src/ostd/Signals.cpp b/src/ostd/utils/Signals.cpp similarity index 98% rename from src/ostd/Signals.cpp rename to src/ostd/utils/Signals.cpp index 8901518..f932a56 100755 --- a/src/ostd/Signals.cpp +++ b/src/ostd/utils/Signals.cpp @@ -1,6 +1,6 @@ #include "Signals.hpp" -#include "BaseObject.hpp" -#include "Logger.hpp" +#include "../data_types/BaseObject.hpp" +#include "../io/Logger.hpp" namespace ostd { diff --git a/src/ostd/Signals.hpp b/src/ostd/utils/Signals.hpp similarity index 80% rename from src/ostd/Signals.hpp rename to src/ostd/utils/Signals.hpp index 229acf3..2f6163f 100755 --- a/src/ostd/Signals.hpp +++ b/src/ostd/utils/Signals.hpp @@ -1,8 +1,27 @@ -#ifndef __SIGNALS_HPP__ -#define __SIGNALS_HPP__ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 OmniaX-Dev -#include -#include + 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 #include namespace ostd @@ -107,7 +126,4 @@ namespace ostd validate(); } }; - } - -#endif diff --git a/src/ostd/Time.cpp b/src/ostd/utils/Time.cpp similarity index 100% rename from src/ostd/Time.cpp rename to src/ostd/utils/Time.cpp diff --git a/src/ostd/Time.hpp b/src/ostd/utils/Time.hpp similarity index 82% rename from src/ostd/Time.hpp rename to src/ostd/utils/Time.hpp index 975fe6c..1eaf75c 100644 --- a/src/ostd/Time.hpp +++ b/src/ostd/utils/Time.hpp @@ -1,9 +1,37 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 +#include +#include #include +//Game Time constants +#define TM_R_SECONDS_FOR_G_MINUTE 1 +#define TM_G_MINUTES_FOR_G_HOUR 60 +#define TM_G_HOURS_FOR_G_DAY 24 +#define TM_G_DAYS_FOR_G_LONG_MONTH 31 +#define TM_G_DAYS_FOR_G_MEDIUM_MONTH 30 +#define TM_G_DAYS_FOR_G_SHORT_MONTH 28 + namespace ostd { enum class eTimeUnits diff --git a/src/ostd/Utils.cpp b/src/ostd/utils/Utils.cpp similarity index 96% rename from src/ostd/Utils.cpp rename to src/ostd/utils/Utils.cpp index 4467727..6291d58 100755 --- a/src/ostd/Utils.cpp +++ b/src/ostd/utils/Utils.cpp @@ -1,10 +1,4 @@ #include "Utils.hpp" -#include "String.hpp" -#include "Defines.hpp" -#include "IOHandlers.hpp" - -#include "vendor/TermColor.hpp" - #include #include #include @@ -16,6 +10,9 @@ #include #include #include +#include "../vendor/TermColor.hpp" +#include "../string/String.hpp" +#include "../io/IOHandlers.hpp" #define __get_local_time() \ std::time_t __cur_t = std::time(0); \ diff --git a/src/ostd/Utils.hpp b/src/ostd/utils/Utils.hpp similarity index 75% rename from src/ostd/Utils.hpp rename to src/ostd/utils/Utils.hpp index 9998935..b28864f 100755 --- a/src/ostd/Utils.hpp +++ b/src/ostd/utils/Utils.hpp @@ -1,13 +1,33 @@ -#ifndef __DATATYPES__HPP__ -#define __DATATYPES__HPP__ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 OmniaX-Dev -#include -#include -#include -#include -#include + 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 +#include +#include +#include + +#define STR_BOOL(b) (b ? "true" : "false") +#define STDVEC_CONTAINS(vec, elem) (std::find(vec.begin(), vec.end(), elem) != vec.end()) namespace ostd { @@ -90,5 +110,3 @@ namespace ostd inline static uint64_t s_startTime_ms; }; } - -#endif diff --git a/src/ostd/md5.cpp b/src/ostd/utils/md5.cpp similarity index 99% rename from src/ostd/md5.cpp rename to src/ostd/utils/md5.cpp index af998bb..f89a852 100644 --- a/src/ostd/md5.cpp +++ b/src/ostd/utils/md5.cpp @@ -1,11 +1,10 @@ +#include "Utils.hpp" #include #include #include #include #include -#include "Utils.hpp" - // Rotation amounts namespace { constexpr uint32_t S11 = 7; diff --git a/src/test.cpp b/src/test.cpp index b7ac4d7..f6a1fbb 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -1,3 +1,23 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2025 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 . +*/ + // #include // #include // #include @@ -5,8 +25,7 @@ #include #include -#include - +#include ostd::ConsoleOutputHandler out;