Compare commits

..

No commits in common. "main" and "v1.0.0" have entirely different histories.
main ... v1.0.0

232 changed files with 3236 additions and 9655 deletions

View File

@ -8,9 +8,6 @@ on:
jobs: jobs:
Windows-AMD64-Build: Windows-AMD64-Build:
runs-on: windows-x86_64 runs-on: windows-x86_64
defaults:
run:
shell: powershell
steps: steps:
- name: Check out repository code - name: Check out repository code
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -22,10 +19,8 @@ jobs:
- name: Building/Compiling/Installing Project - name: Building/Compiling/Installing Project
run: | run: |
cd ${{ gitea.workspace }} cd ${{ gitea.workspace }}
vcpkg install cmake -A x64 -DCMAKE_BUILD_TYPE=Release --preset=default .
mkdir build
cd build cd build
cmake -A x64 -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release cmake --build . --config Release
cmake --install . cmake --install .
@ -33,12 +28,10 @@ jobs:
run: | run: |
cd ${{ gitea.workspace }} cd ${{ gitea.workspace }}
mkdir bin mkdir bin
mv build/Release/EHS_Dyn.dll bin
mv build/Release/StrToHash.exe bin mv build/Release/StrToHash.exe bin
mv build/Release/zlib1.dll bin mv build/Release/zlib1.dll bin
mkdir lib mkdir lib
mv build/Release/EHS_Stc.lib lib mv build/Release/EHS.lib lib
mv build/Release/EHS_Dyn.lib lib
- name: Zipping Binaries - name: Zipping Binaries
run: | run: |
@ -65,7 +58,7 @@ jobs:
- name: Installing Dependencies - name: Installing Dependencies
run: | run: |
sudo pacman -S --noconfirm doxygen zip alsa-lib libxcb xcb-util-cursor pipewire sudo pacman -S --noconfirm doxygen zip alsa-lib libxcb xcb-util-cursor
- name: Generating Documentation - name: Generating Documentation
run: | run: |
@ -80,12 +73,10 @@ jobs:
- name: Creating Appropriate Directories - name: Creating Appropriate Directories
run: | run: |
cd ${{ gitea.workspace }}
mkdir bin mkdir bin
mv libEHS_Dyn.so bin
mv StrToHash bin mv StrToHash bin
mkdir lib mkdir lib
mv libEHS_Stc.a lib mv libEHS.a lib
- name: Zipping Binaries - name: Zipping Binaries
run: zip -r ehs-linux-amd64.zip include bin lib docs LICENSE RADME.md run: zip -r ehs-linux-amd64.zip include bin lib docs LICENSE RADME.md
@ -109,7 +100,7 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Installing Dependencies - name: Installing Dependencies
run: sudo apt install -y doxygen zip libasound2-dev libxcb1-dev libxcb-xinput-dev libxcb-cursor-dev libpipewire-0.3-dev run: sudo apt install -y doxygen zip libasound2-dev libxcb1-dev libxcb-xinput-dev libxcb-cursor-dev
- name: Generating Documentation - name: Generating Documentation
run: | run: |
@ -124,12 +115,10 @@ jobs:
- name: Creating Appropriate Directories - name: Creating Appropriate Directories
run: | run: |
cd ${{ gitea.workspace }}
mkdir bin mkdir bin
mv libEHS_Dyn.so bin
mv StrToHash bin mv StrToHash bin
mkdir lib mkdir lib
mv libEHS_Stc.a lib mv libEHS.a lib
- name: Zipping Binaries - name: Zipping Binaries
run: zip -r ehs-linux-aarch64.zip include bin lib docs LICENSE README.md run: zip -r ehs-linux-aarch64.zip include bin lib docs LICENSE README.md

View File

@ -13,8 +13,7 @@ project(EHS CXX C)
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
set(IS_OS_WINDOWS TRUE) set(IS_OS_WINDOWS TRUE)
set(USER_HOME_DIRECTORY "$ENV{USERPROFILE}") set(USER_HOME_DIRECTORY $ENV{USERPROFILE})
string(REPLACE "\\" "/" USER_HOME_DIRECTORY "${USER_HOME_DIRECTORY}")
message("Building for the Windows operating system.") message("Building for the Windows operating system.")
elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux") elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
set(IS_OS_LINUX TRUE) set(IS_OS_LINUX TRUE)
@ -40,198 +39,164 @@ endif ()
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(EHS_SOURCES set(EHS_SOURCES
src/EHS.cpp include/ehs/EHS.h src/EHS.cpp include/ehs/EHS.h
src/Type.cpp include/ehs/Type.h src/Type.cpp include/ehs/Type.h
src/BaseObj.cpp include/ehs/BaseObj.h src/BaseObj.cpp include/ehs/BaseObj.h
src/GC.cpp include/ehs/GC.h src/GarbageCollector.cpp include/ehs/GarbageCollector.h
src/Log.cpp include/ehs/Log.h src/Log.cpp include/ehs/Log.h
src/URI.cpp include/ehs/URI.h src/URI.cpp include/ehs/URI.h
src/Math.cpp include/ehs/Math.h src/Math.cpp include/ehs/Math.h
src/Color4.cpp include/ehs/Color4.h src/Color4.cpp include/ehs/Color4.h
src/Color3.cpp include/ehs/Color3.h src/Color3.cpp include/ehs/Color3.h
src/Version.cpp include/ehs/Version.h src/Version.cpp include/ehs/Version.h
src/Base64.cpp include/ehs/Base64.h src/Base64.cpp include/ehs/Base64.h
src/Data.cpp include/ehs/Data.h src/Data.cpp include/ehs/Data.h
src/Range.cpp include/ehs/Range.h src/Range.cpp include/ehs/Range.h
src/Util.cpp include/ehs/Util.h src/Util.cpp include/ehs/Util.h
src/Task.cpp include/ehs/Task.h src/Task.cpp include/ehs/Task.h
src/DataType.cpp include/ehs/DataType.h src/DataType.cpp include/ehs/DataType.h
include/ehs/Anchor.h include/ehs/Anchor.h
include/ehs/Dock.h include/ehs/Dock.h
include/ehs/HashMap.h include/ehs/HashMap.h
include/ehs/HRNG.h include/ehs/HRNG.h
include/ehs/Link.h include/ehs/Link.h
include/ehs/LinkedList.h include/ehs/LinkedList.h
include/ehs/Mat2.h include/ehs/Mat2.h
include/ehs/Mat3.h include/ehs/Mat3.h
include/ehs/Mat4.h include/ehs/Mat4.h
include/ehs/PRNG.h include/ehs/PRNG.h
include/ehs/Quat.h include/ehs/Quat.h
include/ehs/Rect.h include/ehs/Rect.h
include/ehs/Str.h include/ehs/Str.h
include/ehs/Types.h include/ehs/Types.h
include/ehs/UTF.h include/ehs/UTF.h
include/ehs/Vec2.h include/ehs/Vec2.h
include/ehs/Vec3.h include/ehs/Vec3.h
include/ehs/Vec4.h include/ehs/Vec4.h
include/ehs/Serializer.h include/ehs/Serializer.h
include/ehs/Array.h include/ehs/Array.h
include/ehs/Vector.h include/ehs/Vector.h
include/ehs/SArray.h include/ehs/SArray.h
src/PtrData.cpp include/ehs/PtrData.h src/PtrData.cpp include/ehs/PtrData.h
include/ehs/UniPtr.h include/ehs/UniPtr.h
include/ehs/ShdPtr.h include/ehs/ShdPtr.h
include/ehs/WkPtr.h include/ehs/WkPtr.h
src/db/DbVarTmpl.cpp include/ehs/db/DbVarTmpl.h src/database/DVar.cpp include/ehs/database/DVar.h
src/system/CPU.cpp include/ehs/system/CPU.h src/system/CPU.cpp include/ehs/system/CPU.h
src/system/Thread.cpp include/ehs/system/Thread.h src/system/Thread.cpp include/ehs/system/Thread.h
src/system/BaseMutex.cpp include/ehs/system/BaseMutex.h src/system/BaseMutex.cpp include/ehs/system/BaseMutex.h
src/system/BaseSemaphore.cpp include/ehs/system/BaseSemaphore.h src/system/BaseSemaphore.cpp include/ehs/system/BaseSemaphore.h
src/system/BaseSystem.cpp include/ehs/system/BaseSystem.h src/system/BaseSystem.cpp include/ehs/system/BaseSystem.h
src/system/BaseOpen.cpp include/ehs/system/BaseOpen.h src/system/BaseOpen.cpp include/ehs/system/BaseOpen.h
include/ehs/system/Architecture.h include/ehs/system/Architecture.h
include/ehs/system/Mutex.h include/ehs/system/Mutex.h
include/ehs/system/Open.h include/ehs/system/Open.h
include/ehs/system/OS.h include/ehs/system/OS.h
include/ehs/system/Semaphore.h include/ehs/system/Semaphore.h
include/ehs/system/System.h include/ehs/system/System.h
src/json/Json.cpp include/ehs/json/Json.h src/json/Json.cpp include/ehs/json/Json.h
src/json/JsonBase.cpp include/ehs/json/JsonBase.h src/json/JsonBase.cpp include/ehs/json/JsonBase.h
src/json/JsonNum.cpp include/ehs/json/JsonNum.h src/json/JsonNum.cpp include/ehs/json/JsonNum.h
src/json/JsonBool.cpp include/ehs/json/JsonBool.h src/json/JsonBool.cpp include/ehs/json/JsonBool.h
src/json/JsonStr.cpp include/ehs/json/JsonStr.h src/json/JsonStr.cpp include/ehs/json/JsonStr.h
src/json/JsonObj.cpp include/ehs/json/JsonObj.h src/json/JsonObj.cpp include/ehs/json/JsonObj.h
src/json/JsonArray.cpp include/ehs/json/JsonArray.h src/json/JsonArray.cpp include/ehs/json/JsonArray.h
src/json/JsonVar.cpp include/ehs/json/JsonVar.h src/json/JsonVar.cpp include/ehs/json/JsonVar.h
src/io/Resource.cpp include/ehs/io/Resource.h src/io/Resource.cpp include/ehs/io/Resource.h
src/io/Console.cpp include/ehs/io/Console.h src/io/Console.cpp include/ehs/io/Console.h
src/io/RIFF_Chunk.cpp include/ehs/io/RIFF_Chunk.h src/io/RIFF_Chunk.cpp include/ehs/io/RIFF_Chunk.h
src/io/RIFF.cpp include/ehs/io/RIFF.h src/io/RIFF.cpp include/ehs/io/RIFF.h
src/io/BaseWindow.cpp include/ehs/io/BaseWindow.h src/io/BaseWindow.cpp include/ehs/io/BaseWindow.h
src/io/BaseFile.cpp include/ehs/io/BaseFile.h src/io/BaseFile.cpp include/ehs/io/BaseFile.h
src/io/Glyph.cpp include/ehs/io/Glyph.h src/io/Glyph.cpp include/ehs/io/Glyph.h
src/io/FontAtlas.cpp include/ehs/io/FontAtlas.h src/io/FontAtlas.cpp include/ehs/io/FontAtlas.h
src/io/BaseFileMonitor.cpp include/ehs/io/BaseFileMonitor.h src/io/BaseFileMonitor.cpp include/ehs/io/BaseFileMonitor.h
include/ehs/io/COM.h include/ehs/io/COM.h
include/ehs/io/File.h include/ehs/io/File.h
include/ehs/io/FileMonitor.h include/ehs/io/FileMonitor.h
include/ehs/io/Window.h include/ehs/io/Window.h
include/ehs/io/socket/Socket.h src/io/socket/Request.cpp include/ehs/io/socket/Request.h
src/io/socket/Request.cpp include/ehs/io/socket/Request.h src/io/socket/Response.cpp include/ehs/io/socket/Response.h
src/io/socket/Response.cpp include/ehs/io/socket/Response.h src/io/socket/DNS.cpp include/ehs/io/socket/DNS.h
src/io/socket/BaseDNS.cpp include/ehs/io/socket/BaseDNS.h src/io/socket/BaseUDP.cpp include/ehs/io/socket/BaseUDP.h
include/ehs/io/socket/DNS.h src/io/socket/BaseTCP.cpp include/ehs/io/socket/BaseTCP.h
src/io/socket/BaseUDP.cpp include/ehs/io/socket/BaseUDP.h src/io/socket/SSL.cpp include/ehs/io/socket/SSL.h
include/ehs/io/socket/UDP.h
src/io/socket/BaseTCP.cpp include/ehs/io/socket/BaseTCP.h
include/ehs/io/socket/TCP.h
src/io/socket/SSL.cpp include/ehs/io/socket/SSL.h
include/ehs/io/socket/ehc/NetUtils.h src/io/socket/rest/Twitch.cpp include/ehs/io/socket/rest/Twitch.h
src/io/socket/EHC.cpp include/ehs/io/socket/EHC.h src/io/socket/rest/TwitchChat.cpp include/ehs/io/socket/rest/TwitchChat.h
src/io/socket/ehc/NetFrags.cpp include/ehs/io/socket/ehc/NetFrags.h src/io/socket/rest/Spotify.cpp include/ehs/io/socket/rest/Spotify.h
src/io/socket/ehc/NetEnd.cpp include/ehs/io/socket/ehc/NetEnd.h include/ehs/io/socket/Socket.h
src/io/socket/ehc/NetSys.cpp include/ehs/io/socket/ehc/NetSys.h include/ehs/io/socket/TCP.h
src/io/socket/ehc/NetOp.cpp include/ehs/io/socket/ehc/NetOp.h include/ehs/io/socket/UDP.h
src/io/socket/rest/Twitch.cpp include/ehs/io/socket/rest/Twitch.h src/io/audio/Audio.cpp include/ehs/io/audio/Audio.h
src/io/socket/rest/TwitchChat.cpp include/ehs/io/socket/rest/TwitchChat.h src/io/audio/BaseAudioDevice.cpp include/ehs/io/audio/BaseAudioDevice.h
src/io/socket/rest/Spotify.cpp include/ehs/io/socket/rest/Spotify.h src/io/audio/AudioCodec.cpp include/ehs/io/audio/AudioCodec.h
include/ehs/io/audio/AudioDevice.h
src/io/audio/Audio.cpp include/ehs/io/audio/Audio.h src/io/img/PNG.cpp include/ehs/io/img/PNG.h
src/io/audio/BaseAudioDevice.cpp include/ehs/io/audio/BaseAudioDevice.h src/io/img/Img.cpp include/ehs/io/img/Img.h
src/io/audio/AudioCodec.cpp include/ehs/io/audio/AudioCodec.h src/io/img/PNG_Chunk.cpp include/ehs/io/img/PNG_Chunk.h
include/ehs/io/audio/AudioDevice.h src/io/img/ImgCodec.cpp include/ehs/io/img/ImgCodec.h
src/io/img/PNG.cpp include/ehs/io/img/PNG.h include/ehs/io/model/Vertex.h
src/io/img/Img.cpp include/ehs/io/img/Img.h src/io/model/Mesh.cpp include/ehs/io/model/Mesh.h
src/io/img/PNG_Chunk.cpp include/ehs/io/img/PNG_Chunk.h src/io/model/Bone.cpp include/ehs/io/model/Bone.h
src/io/img/ImgCodec.cpp include/ehs/io/img/ImgCodec.h src/io/model/Model.cpp include/ehs/io/model/Model.h
src/io/model/Animation.cpp include/ehs/io/model/Animation.h
src/io/model/AnimBone.cpp include/ehs/io/model/AnimBone.h
src/io/model/KeyFrame.cpp include/ehs/io/model/KeyFrame.h
src/io/model/PropertyChange.cpp include/ehs/io/model/PropertyChange.h
include/ehs/io/mdl/Vertex.h src/io/hid/ButtonState.cpp include/ehs/io/hid/ButtonState.h
src/io/model/Mesh.cpp include/ehs/io/mdl/Mesh.h src/io/hid/Button.cpp include/ehs/io/hid/Button.h
src/io/model/Bone.cpp include/ehs/io/mdl/Bone.h src/io/hid/Mouse.cpp include/ehs/io/hid/Mouse.h
src/io/model/Mdl.cpp include/ehs/io/mdl/Mdl.h src/io/hid/Keyboard.cpp include/ehs/io/hid/Keyboard.h
src/io/model/Animation.cpp include/ehs/io/mdl/Animation.h src/io/hid/HID.cpp include/ehs/io/hid/HID.h
src/io/model/AnimBone.cpp include/ehs/io/mdl/AnimBone.h src/io/hid/InputHandler.cpp include/ehs/io/hid/InputHandler.h
src/io/model/KeyFrame.cpp include/ehs/io/mdl/KeyFrame.h src/io/hid/Input.cpp include/ehs/io/hid/Input.h
src/io/model/PropertyChange.cpp include/ehs/io/mdl/PropertyChange.h
src/io/hid/ButtonState.cpp include/ehs/io/hid/ButtonState.h
src/io/hid/Button.cpp include/ehs/io/hid/Button.h
src/io/hid/Mouse.cpp include/ehs/io/hid/Mouse.h
src/io/hid/Keyboard.cpp include/ehs/io/hid/Keyboard.h
src/io/hid/HID.cpp include/ehs/io/hid/HID.h
src/io/hid/InputHandler.cpp include/ehs/io/hid/InputHandler.h
src/io/hid/Input.cpp include/ehs/io/hid/Input.h
src/io/model/MdlCodec.cpp
include/ehs/io/mdl/MdlCodec.h
include/ehs/io/UsbBase.h
src/io/UsbBase.cpp
include/ehs/db/DbTable.h
include/ehs/db/DbObject.h
include/ehs/db/DbVar.h
src/db/DbVar.cpp
include/ehs/db/Database.h
src/db/DbObject.cpp
src/db/Database.cpp
src/db/Database.cpp
src/db/DbTable.cpp
include/ehs/io/BaseDirectory.h
src/io/BaseDirectory.cpp
include/ehs/io/Directory.h
include/ehs/io/socket/ehc/NetEnc.h
src/io/socket/ehc/NetEnc.cpp
) )
if (IS_OS_WINDOWS) if (IS_OS_WINDOWS)
list(APPEND EHS_SOURCES list(APPEND EHS_SOURCES
src/io/socket/UDP_W32.cpp include/ehs/io/socket/UDP_W32.h src/io/socket/UDP_W32.cpp include/ehs/io/socket/UDP_W32.h
src/io/socket/TCP_W32.cpp include/ehs/io/socket/TCP_W32.h src/io/socket/TCP_W32.cpp include/ehs/io/socket/TCP_W32.h
src/io/socket/DNS_W32.cpp include/ehs/io/socket/DNS_W32.h src/system/Semaphore_W32.cpp include/ehs/system/Semaphore_W32.h
src/system/Semaphore_W32.cpp include/ehs/system/Semaphore_W32.h src/system/System_W32.cpp include/ehs/system/System_W32.h
src/system/System_W32.cpp include/ehs/system/System_W32.h src/system/Mutex_W32.cpp include/ehs/system/Mutex_W32.h
src/system/Mutex_W32.cpp include/ehs/system/Mutex_W32.h src/system/Open_W32.cpp include/ehs/system/Open_W32.h
src/system/Open_W32.cpp include/ehs/system/Open_W32.h src/io/audio/audioDevice_W32.cpp include/ehs/io/audio/audioDevice_W32.h
src/io/audio/audioDevice_W32.cpp include/ehs/io/audio/audioDevice_W32.h src/io/File_W32.cpp include/ehs/io/File_W32.h
src/io/File_W32.cpp include/ehs/io/File_W32.h src/io/FileMonitor_W32.cpp include/ehs/io/FileMonitor_W32.h
src/io/FileMonitor_W32.cpp include/ehs/io/FileMonitor_W32.h src/io/Window_W32.cpp include/ehs/io/Window_W32.h
src/io/Window_W32.cpp include/ehs/io/Window_W32.h src/io/COM.cpp include/ehs/io/COM.h
src/io/COM.cpp include/ehs/io/COM.h src/system/CPU_MSVC_AMD64.asm src/HRNG_MSVC.asm src/Math_MSVC_AMD64.asm
src/system/CPU_MSVC_AMD64.asm src/HRNG_MSVC.asm src/Math_MSVC_AMD64.asm
src/io/Directory_W32.cpp include/ehs/io/Directory_W32.h
) )
elseif (IS_OS_LINUX) elseif (IS_OS_LINUX)
list(APPEND EHS_SOURCES list(APPEND EHS_SOURCES
src/io/socket/UDP_BSD.cpp include/ehs/io/socket/UDP_BSD.h src/io/socket/UDP_BSD.cpp include/ehs/io/socket/UDP_BSD.h
src/io/socket/TCP_BSD.cpp include/ehs/io/socket/TCP_BSD.h src/io/socket/TCP_BSD.cpp include/ehs/io/socket/TCP_BSD.h
src/io/socket/DNS_LNX.cpp include/ehs/io/socket/DNS_LNX.h src/system/Semaphore_P.cpp include/ehs/system/Semaphore_P.h
src/system/Semaphore_P.cpp include/ehs/system/Semaphore_P.h src/system/System_LNX.cpp include/ehs/system/System_LNX.h
src/system/System_LNX.cpp include/ehs/system/System_LNX.h src/system/Open_UNX.cpp include/ehs/system/Open_UNX.h
src/system/Open_UNX.cpp include/ehs/system/Open_UNX.h src/io/File_UNX.cpp include/ehs/io/File_UNX.h
src/io/File_UNX.cpp include/ehs/io/File_UNX.h src/io/FileMonitor_UNX.cpp include/ehs/io/FileMonitor_UNX.h
src/io/FileMonitor_UNX.cpp include/ehs/io/FileMonitor_UNX.h src/system/Mutex_PT.cpp include/ehs/system/Mutex_PT.h
src/system/Mutex_PT.cpp include/ehs/system/Mutex_PT.h src/io/audio/AudioDevice_ALSA.cpp include/ehs/io/audio/AudioDevice_ALSA.h
src/io/audio/AudioDevice_PW.cpp include/ehs/io/audio/AudioDevice_PW.h src/system/FileSystem.cpp include/ehs/system/FileSystem.h
src/system/FileSystem.cpp include/ehs/system/FileSystem.h src/system/User.cpp include/ehs/system/User.h
src/system/User.cpp include/ehs/system/User.h
src/io/Directory_LNX.cpp include/ehs/io/Directory_LNX.h
src/io/Usb_LNX.cpp include/ehs/io/Usb_LNX.h
) )
#set(LINUX_WINDOW_SYSTEM "Wayland" CACHE STRING "Linux Window System") set(LINUX_WINDOW_SYSTEM "Wayland" CACHE STRING "Linux Window System")
if (LINUX_WINDOW_SYSTEM STREQUAL "Wayland") if (LINUX_WINDOW_SYSTEM STREQUAL "Wayland")
add_compile_definitions(EHS_WS_WAYLAND) add_compile_definitions(EHS_WS_WAYLAND)
list(APPEND EHS_SOURCES list(APPEND EHS_SOURCES src/io/xdg-shell-protocol.c include/ehs/io/xdg-shell-client-protocol.h src/io/Window_Way.cpp include/ehs/io/Window_Way.h)
src/io/xdg-shell-protocol.c include/ehs/io/xdg-shell-client-protocol.h
src/io/xdg-decoration.c include/ehs/io/xdg-decoration.h
src/io/Window_Way.cpp include/ehs/io/Window_Way.h)
message("Building for Wayland.") message("Building for Wayland.")
elseif (LINUX_WINDOW_SYSTEM STREQUAL "XCB") elseif (LINUX_WINDOW_SYSTEM STREQUAL "XCB")
add_compile_definitions(EHS_WS_XCB) add_compile_definitions(EHS_WS_XCB)
@ -249,37 +214,23 @@ endif()
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
#message("${CMAKE_CXX_FLAGS}") #message("${CMAKE_CXX_FLAGS}")
add_library(EHS_Stc STATIC ${EHS_SOURCES}) add_library(EHS ${EHS_SOURCES})
add_library(EHS_Dyn SHARED ${EHS_SOURCES})
add_executable(StrToHash src/StrToHash.cpp) add_executable(StrToHash src/StrToHash.cpp)
target_compile_definitions(EHS_Dyn PRIVATE EHS_LIB_EXPORT) target_include_directories(EHS PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_include_directories(EHS_Stc PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_include_directories(EHS_Dyn PUBLIC ${PROJECT_SOURCE_DIR}/include)
if (IS_OS_LINUX) if (IS_OS_LINUX)
set(CMAKE_INSTALL_PREFIX "${USER_HOME_DIRECTORY}/.local") set(CMAKE_INSTALL_PREFIX "${USER_HOME_DIRECTORY}/.local")
install(TARGETS EHS_Dyn LIBRARY DESTINATION "bin")
find_package(PkgConfig REQUIRED)
pkg_check_modules(PIPEWIRE REQUIRED libpipewire-0.3)
target_include_directories(EHS_Stc PRIVATE ${PIPEWIRE_INCLUDE_DIRS})
target_include_directories(EHS_Dyn PRIVATE ${PIPEWIRE_INCLUDE_DIRS})
elseif (IS_OS_WINDOWS) elseif (IS_OS_WINDOWS)
set(CMAKE_INSTALL_PREFIX "${USER_HOME_DIRECTORY}/EHS") set(CMAKE_INSTALL_PREFIX "${USER_HOME_DIRECTORY}/EHS")
install(TARGETS EHS_Dyn LIBRARY DESTINATION "lib")
install(TARGETS EHS_Dyn RUNTIME DESTINATION "bin")
file(GLOB DLL_FILES "${CMAKE_CURRENT_BINARY_DIR}/*.dll")
install(FILES ${DLL_FILES} DESTINATION "bin")
endif () endif ()
install(TARGETS EHS_Stc DESTINATION "lib") install(TARGETS EHS DESTINATION lib)
install(TARGETS StrToHash DESTINATION "bin")
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION "include") install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include)
install(TARGETS StrToHash DESTINATION bin)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
if (ZLIB_FOUND) if (ZLIB_FOUND)
@ -295,22 +246,16 @@ else ()
message(STATUS "OpenSSL was not found.") message(STATUS "OpenSSL was not found.")
endif () endif ()
target_link_libraries(EHS_Stc OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB) target_link_libraries(EHS OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB)
target_link_libraries(EHS_Dyn OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB)
target_link_libraries(StrToHash OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB)
if (IS_OS_WINDOWS) if (IS_OS_WINDOWS)
target_link_libraries(EHS_Dyn avrt ws2_32) target_link_libraries(StrToHash ws2_32 avrt EHS)
target_link_libraries(StrToHash ws2_32 avrt EHS_Stc)
elseif (IS_OS_LINUX) elseif (IS_OS_LINUX)
if (LINUX_WINDOW_SYSTEM STREQUAL "Wayland") if (LINUX_WINDOW_SYSTEM STREQUAL "Wayland")
target_link_libraries(EHS_Dyn wayland-client)
target_link_libraries(StrToHash wayland-client) target_link_libraries(StrToHash wayland-client)
elseif (LINUX_WINDOW_SYSTEM STREQUAL "XCB") elseif (LINUX_WINDOW_SYSTEM STREQUAL "XCB")
target_link_libraries(EHS_Dyn xcb xcb-cursor xcb-xfixes xcb-xinput)
target_link_libraries(StrToHash xcb xcb-cursor xcb-xfixes xcb-xinput) target_link_libraries(StrToHash xcb xcb-cursor xcb-xfixes xcb-xinput)
endif () endif ()
target_link_libraries(EHS_Dyn z asound pipewire-0.3) target_link_libraries(StrToHash z asound EHS)
target_link_libraries(StrToHash z asound EHS_Stc)
endif () endif ()

12
CMakePresets.json Normal file
View File

@ -0,0 +1,12 @@
{
"version": 3,
"configurePresets": [
{
"name": "default",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
]
}

View File

@ -8,7 +8,6 @@ This project does not fully follow the C++ standard.
### Features ### Features
- Audio IO/Processing/Manipulation - Audio IO/Processing/Manipulation
- Image Processing/Manipulation - Image Processing/Manipulation
- Databases
- 3D Model & Mesh Processing/Manipulation - 3D Model & Mesh Processing/Manipulation
- File IO - File IO
- Basic File Monitoring - Basic File Monitoring
@ -21,7 +20,7 @@ This project does not fully follow the C++ standard.
- Mutexes - Mutexes
- Semaphores - Semaphores
- CPU information and features at runtime - CPU information and features at runtime
- HTTP(S) Socket Layer - HTTP(S) Sockets
- TCP Socket - TCP Socket
- UDP Socket - UDP Socket
- COM (Serial) IO - COM (Serial) IO
@ -30,13 +29,12 @@ This project does not fully follow the C++ standard.
- Twitch Integration - Twitch Integration
- Json Parsing/Writing - Json Parsing/Writing
- User Friendly HID Input - User Friendly HID Input
- Heap Garbage Collector - Basic Garbage Collector
- Linked List - Linked List
- Array - Array
- Vector - Vector
- Asynchronous Task System - Asynchronous Task System
- URI Parsing - URI Parsing
- USB (WIP)
### Supported Architectures ### Supported Architectures
- AMD64 - AMD64
@ -73,10 +71,8 @@ Wayland Window System. Wayland support is currently not fully supported yet, use
- [CMake](https://cmake.org/) - [CMake](https://cmake.org/)
- [vcpkg](https://learn.microsoft.com/en-us/vcpkg/get_started/get-started?pivots=shell-cmd) - [vcpkg](https://learn.microsoft.com/en-us/vcpkg/get_started/get-started?pivots=shell-cmd)
`vcpkg install` - Use this command in the directory where `vcpkg.json` is located to download/install dependencies.
### Building ### Building
`cmake -A x64 -DCMAKE_BUILD_TYPE=Release /path/to/source` `cmake -A x64 -DCMAKE_BUILD_TYPE=Release --preset=default /path/to/source`
### Compiling ### Compiling
`cmake --build /path/to/build --config Release` `cmake --build /path/to/build --config Release`
@ -91,10 +87,12 @@ This will require the terminal to be running in administrator mode.
#include <ehs/EHS.h> #include <ehs/EHS.h>
#include <ehs/io/Console.h> #include <ehs/io/Console.h>
int main() ehs::Int_32 Main(ehs::Str_8* appName, ehs::Str_8* appVerId, ehs::Version* appVer)
{ {
// Simple identifying meta-data for the logger. // Simple identifying meta-data for the logger.
ehs::Initialize("Simple Example App", "Release", {1, 0, 0}); *appName = "Simple Example App"; // The application's name
*appVerId = "Release"; // The app's version prefix; i.e. Alpha, Beta or Release as an example.
*appVer = {1, 0, 0}; // The app's version major, minor and patch number.
ehs::Console::Write_8("How old are you?"); // Write to the console in UTF_8 character encoding. ehs::Console::Write_8("How old are you?"); // Write to the console in UTF_8 character encoding.
@ -103,15 +101,13 @@ int main()
if (!response.IsNum()) if (!response.IsNum())
{ {
ehs::Console::Clear(); // Clear the console's buffer. ehs::Console::Clear(); // Clear the console's buffer.
return main(); // Repeat process if given response is not a number. return Main(appName, appVerId, appVer); // Repeat process if given response is not a number.
} }
ehs::UInt_8 age = response.ToDecimal<ehs::UInt_8>(); // Converts the string number into a number based primitive. ehs::UInt_8 age = response.ToDecimal<ehs::UInt_8>(); // Converts the string number into a number based primitive.
ehs::Console::Write("Your age is " + ehs::Str_8::FromNum(age) + "."); // Write the console with the age converted back to string. ehs::Console::Write("Your age is " + ehs::Str_8::FromNum(age) + "."); // Write the console with the age converted back to string.
ehs::Uninitialize();
return 0; return 0;
} }
``` ```

View File

@ -5,20 +5,20 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Base64 class Base64
{ {
private: private:
static const char ascii[]; static const char ascii[];
public: public:
static Str_8 Encode(const Str_8 &input); static Str_8 Encode(const Str_8 input);
static Str_8 Decode(const Str_8 &input); static Str_8 Decode(const Str_8 input);
private: private:
static char Find(char c); static char Find(const char c);
static bool IsBase64(char c); static bool IsBase64(const char c);
}; };
} }

View File

@ -5,7 +5,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO BaseObj class BaseObj
{ {
private: private:
Type* hierarchy; Type* hierarchy;

View File

@ -4,7 +4,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Color3 class Color3
{ {
public: public:
float r; float r;
@ -13,13 +13,13 @@ namespace ehs
Color3(); Color3();
Color3(float scalar); Color3(const float scalar);
Color3(float r, float g, float b); Color3(const float r, const float g, const float b);
Color3(const Color3& color); Color3(const Color3& color);
Color3& operator=(float scalar); Color3& operator=(const float scalar);
Color3& operator=(const Color3& color); Color3& operator=(const Color3& color);
@ -27,9 +27,9 @@ namespace ehs
bool operator!=(const Color3& color) const; bool operator!=(const Color3& color) const;
float operator[](UInt_64 i) const; float operator[](const UInt_64 i) const;
float& operator[](UInt_64 i); float& operator[](const UInt_64 i);
Color3& operator*=(const Color3& color); Color3& operator*=(const Color3& color);

View File

@ -5,7 +5,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Color4 class Color4
{ {
public: public:
float r; float r;
@ -15,15 +15,15 @@ namespace ehs
Color4(); Color4();
Color4(float scalar); Color4(const float scalar);
explicit Color4(const Color3& color); explicit Color4(const Color3& color);
Color4(float r, float g, float b, float a = 1.0f); Color4(const float r, const float g, const float b, const float a = 1.0f);
Color4(const Color4& color); Color4(const Color4& color);
Color4& operator=(float scalar); Color4& operator=(const float scalar);
Color4& operator=(const Color3& color); Color4& operator=(const Color3& color);
@ -33,9 +33,9 @@ namespace ehs
bool operator!=(const Color4& color) const; bool operator!=(const Color4& color) const;
float operator[](UInt_64 i) const; float operator[](const UInt_64 i) const;
float& operator[](UInt_64 i); float& operator[](const UInt_64 i);
Color4& operator*=(const Color4& color); Color4& operator*=(const Color4& color);

View File

@ -5,7 +5,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Data class Data
{ {
public: public:
template<typename T> template<typename T>

View File

@ -21,9 +21,9 @@ namespace ehs
UINT_8 UINT_8
}; };
EHS_LIB_IO DataType FromAudioBitDepth(UInt_16 bitDepth); DataType FromAudioBitDepth(UInt_16 bitDepth);
EHS_LIB_IO UInt_8 ToByteDepth(DataType type); UInt_8 ToByteDepth(DataType type);
EHS_LIB_IO UInt_8 ToBitDepth(DataType type); UInt_8 ToBitDepth(DataType type);
} }

View File

@ -13,53 +13,51 @@
namespace ehs namespace ehs
{ {
enum class MemoryPattern enum class MemoryPattern
{ {
SPEED, SPEED,
SIZE SIZE
}; };
EHS_LIB_IO void Initialize(Str_8 appName, Str_8 appVerId, const Version &appVer);
EHS_LIB_IO void Uninitialize();
/// Retrieves the UTF32 C-style string as "Event Horizon Standard" /// Retrieves the UTF32 C-style string as "Event Horizon Standard"
/// @returns The result. /// @returns The result.
EHS_LIB_IO const Char_32* GetName_32(); const Char_32* GetName_32();
/// Retrieves the UTF16 C-style string as "Event Horizon Standard" /// Retrieves the UTF16 C-style string as "Event Horizon Standard"
/// @returns The result. /// @returns The result.
EHS_LIB_IO const Char_16* GetName_16(); const Char_16* GetName_16();
/// Retrieves the UTF8 C-style string as "Event Horizon Standard" /// Retrieves the UTF8 C-style string as "Event Horizon Standard"
/// @returns The result. /// @returns The result.
EHS_LIB_IO const Char_8* GetName_8(); const Char_8* GetName_8();
EHS_LIB_IO Str_8 GetAppName_8(); Str_8 GetAppName_8();
EHS_LIB_IO const Char_32* GetAcronym_32(); const Char_32* GetAcronym_32();
EHS_LIB_IO const Char_16* GetAcronym_16(); const Char_16* GetAcronym_16();
EHS_LIB_IO const Char_8* GetAcronym_8(); const Char_8* GetAcronym_8();
/// Retrieves the version identifier in UTF32. /// Retrieves the version identifier in UTF32.
/// @returns The result. /// @returns The result.
EHS_LIB_IO const Char_32* GetVersionId_32(); const Char_32* GetVersionId_32();
/// Retrieves the version identifier in UTF16. /// Retrieves the version identifier in UTF16.
/// @returns The result. /// @returns The result.
EHS_LIB_IO const Char_16* GetVersionId_16(); const Char_16* GetVersionId_16();
/// Retrieves the version identifier in UTF8. /// Retrieves the version identifier in UTF8.
/// @returns The result. /// @returns The result.
EHS_LIB_IO const Char_8* GetVersionId_8(); const Char_8* GetVersionId_8();
EHS_LIB_IO Str_8 GetAppVersionId_8(); Str_8 GetAppVersionId_8();
/// Retrieves the current Event Horizon Standard version. /// Retrieves the current Event Horizon Standard version.
/// @returns The result. /// @returns The result.
EHS_LIB_IO Version GetVersion(); Version GetVersion();
EHS_LIB_IO Version GetAppVersion(); Version GetAppVersion();
}; };
extern ehs::SInt_32 Main(ehs::Str_8* appName, ehs::Str_8* appVerId, ehs::Version* appVer);

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "EHS.h"
#include "Vector.h" #include "Vector.h"
#include "BaseObj.h" #include "BaseObj.h"
#include "ehs/system/Mutex.h" #include "ehs/system/Mutex.h"
@ -9,10 +10,10 @@ namespace ehs
{ {
typedef bool (*GcLogic)(BaseObj*); typedef bool (*GcLogic)(BaseObj*);
class EHS_LIB_IO GC class GarbageCollector
{ {
private: private:
static Array<GcLogic> logic; static Vector<GcLogic>* logic;
static Vector<BaseObj*> garbage; static Vector<BaseObj*> garbage;
static UInt_64 max; static UInt_64 max;
static Thread thread; static Thread thread;
@ -26,17 +27,13 @@ namespace ehs
static void Stop(); static void Stop();
static bool HasLogic(GcLogic logicCb);
static bool AddLogic(GcLogic logicCb);
/// Adds an object to the garbage pile to be deleted. /// Adds an object to the garbage pile to be deleted.
/// @param[in] obj The object to be deleted. /// @param[in] obj The object to be deleted.
static void Add(BaseObj* obj); static void Add(BaseObj* obj);
/// Sets the maximum amount of garbage to delete per poll. /// Sets the maximum amount of garbage to delete per poll.
/// @param[in] newMax The new maximum. /// @param[in] newMax The new maximum.
static void SetMax(UInt_64 newMax); static void SetMax(const UInt_64 newMax);
/// Gets the maximum amount of garbage to delete per poll. /// Gets the maximum amount of garbage to delete per poll.
/// @returns The maximum. /// @returns The maximum.
@ -44,7 +41,7 @@ namespace ehs
/// Sets a new amount for memory pre-allocation to save on memory operations. /// Sets a new amount for memory pre-allocation to save on memory operations.
/// @param[in] newStride The stride to pre-allocate. /// @param[in] newStride The stride to pre-allocate.
static void SetStride(UInt_64 newStride); static void SetStride(const UInt_64 newStride);
/// The amount of data pre-allocated to save on memory operations. /// The amount of data pre-allocated to save on memory operations.
/// @returns The stride. /// @returns The stride.
@ -62,8 +59,5 @@ namespace ehs
static void Dump(); static void Dump();
static bool IsRunning(); static bool IsRunning();
private:
static bool ShouldDelete(BaseObj *obj);
}; };
} }

View File

@ -5,7 +5,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO HRNG class HRNG
{ {
public: public:
static UInt_64 GenerateSeed_u64(); static UInt_64 GenerateSeed_u64();

View File

@ -9,53 +9,26 @@
namespace ehs namespace ehs
{ {
class Log;
typedef void (*LogRaisedCb)(const Log &);
typedef void (*LogOutputCb)(const Array<Log> &);
enum class LogType : UInt_8
{
SUCCESS,
ERR,
WARN,
INFO
};
/// A helper class for holding error information and handling them. /// A helper class for holding error information and handling them.
/// @tparam T The character data type to use. /// @tparam T The character data type to use.
/// @tparam N The number data type to use. /// @tparam N The number data type to use.
class EHS_LIB_IO Log class Log
{ {
private: private:
static void DefaultRaisedCb(const Log &log); static void (*logCb)(const Log&);
static void DefaultOutputCb(const Array<Log> &logs);
static LogRaisedCb raisedCb;
static LogOutputCb outputCb;
static Array<Log> logs;
static Log lastLog; static Log lastLog;
static bool immediate;
LogType type;
Array<Str_8> tags; Array<Str_8> tags;
UInt_64 code; UInt_64 code;
Str_8 msg; Str_8 msg;
public: public:
static void SetRaisedCallback(LogRaisedCb newCb); static void SetCallback(void (*newLogCb)(const Log&));
static void SetOutputCallback(LogOutputCb newCb); static void Raise(const Log& log);
static void OnExit();
static void Raise(Log log);
/// Retrieves the last log raised. /// Retrieves the last log raised.
static Log GetLastLog(); static Log GetLastLog();
static void EnableImmediateMode(bool enable);
/// Default members initialization. /// Default members initialization.
Log(); Log();
@ -63,26 +36,22 @@ namespace ehs
/// @param [in] tags The tags to associate this log with. /// @param [in] tags The tags to associate this log with.
/// @param [in] code The unique code to use. /// @param [in] code The unique code to use.
/// @param [in] msg Detailed information about what happened. /// @param [in] msg Detailed information about what happened.
Log(LogType type, const std::initializer_list<Str_8> &tags, UInt_64 code, Str_8 msg); Log(std::initializer_list<Str_8> tags, const UInt_64 code, const Str_8& msg);
/// Initializes members with the given information. /// Initializes members with the given information.
/// @param [in] tags The tags to associate this log with. /// @param [in] tags The tags to associate this log with.
/// @param [in] code The unique code to use. /// @param [in] code The unique code to use.
/// @param [in] msg Detailed information about what happened. /// @param [in] msg Detailed information about what happened.
Log(LogType type, Array<Str_8> tags, UInt_64 code, Str_8 msg); Log(Array<Str_8>& tags, const UInt_64 code, const Str_8& msg);
Log(Log &&log) noexcept;
/// Copies all members from the given log. /// Copies all members from the given log.
/// @param [in] log The log to copy from. /// @param [in] log The log to copy from.
Log(const Log &log); Log(const Log& log);
Log &operator=(Log &&log) noexcept;
/// Copies all members from the given log. /// Copies all members from the given log.
/// @param [in] log The log to copy from. /// @param [in] log The log to copy from.
/// @returns The log that has been assigned to. /// @returns The log that has been assigned to.
Log &operator=(const Log &log); Log& operator=(const Log& log);
/* /*
/// Compares with another given log. /// Compares with another given log.
@ -96,26 +65,24 @@ namespace ehs
bool operator!=(const Log log); bool operator!=(const Log log);
*/ */
LogType GetType() const; /// Checks whether or not this log has the given tags.
/// @param [in] tags The tags to look for.
/// @returns True if all tags were found, otherwise false.
bool HasTags(const std::initializer_list<Str_8> tags) const;
/// Checks whether or not this log has the given tags. /// Checks whether or not this log has the given tags.
/// @param [in] tags The tags to look for. /// @param [in] tags The tags to look for.
/// @returns True if all tags were found, otherwise false. /// @returns True if all tags were found, otherwise false.
bool HasTags(const std::initializer_list<Str_8> &tags) const; bool HasTags(const Array<Str_8>& tags) const;
/// Checks whether or not this log has the given tags.
/// @param [in] tags The tags to look for.
/// @returns True if all tags were found, otherwise false.
bool HasTags(const Array<Str_8> &tags) const;
/// Checks whether or not this log has the given tag. /// Checks whether or not this log has the given tag.
/// @param [in] tag The tag to look for. /// @param [in] tag The tag to look for.
/// @returns True if tag was found, otherwise false. /// @returns True if tag was found, otherwise false.
bool HasTag(const Str_8 &tag) const; bool HasTag(const Str_8& tag) const;
/// Retrieves all the tags. /// Retrieves all the tags.
/// @returns The result. /// @returns The result.
const Array<Str_8> &GetTags() const; Array<Str_8> GetTags() const;
UInt_64 GetCode() const; UInt_64 GetCode() const;
@ -134,20 +101,16 @@ namespace ehs
#ifndef EHS_LOG_INT #ifndef EHS_LOG_INT
#ifdef EHS_DEBUG #ifdef EHS_DEBUG
#define EHS_LOG_INT(type, code, msg) ehs::Log::Raise({type, {ehs::GetAcronym_8(), EHS_FILE, EHS_FUNC, ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE)}, code, msg}) #define EHS_LOG_INT(type, code, msg) Log::Raise({{type, GetAcronym_8(), EHS_FILE, EHS_FUNC, Str_8::FromNum((UInt_32)EHS_LINE)}, code, msg})
#else #else
#define EHS_LOG_INT(type, code, msg) ehs::Log::Raise({type, {ehs::GetAcronym_8(), EHS_FUNC}, code, msg}) #define EHS_LOG_INT(type, code, msg) Log::Raise({{type, GetAcronym_8(), EHS_FUNC}, code, msg})
#endif #endif
#endif #endif
#ifndef EHS_LOG #ifndef EHS_LOG
#ifdef EHS_DEBUG #ifdef EHS_DEBUG
#define EHS_LOG(type, code, msg) ehs::Log::Raise({type, {ehs::GetAppName_8(), EHS_FILE, EHS_FUNC, ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE)}, code, msg}) #define EHS_LOG(type, code, msg) ehs::Log::Raise({{type, ehs::GetAppName_8(), EHS_FILE, EHS_FUNC, ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE)}, code, msg})
#else #else
#define EHS_LOG(type, code, msg) ehs::Log::Raise({type, {ehs::GetAppName_8(), EHS_FUNC}, code, msg}) #define EHS_LOG(type, code, msg) ehs::Log::Raise({{type, ehs::GetAppName_8(), EHS_FUNC}, code, msg})
#endif #endif
#endif
#ifndef EHS_LOG_SUCCESS
#define EHS_LOG_SUCCESS() ehs::Log::Raise({})
#endif #endif

View File

@ -120,7 +120,7 @@ namespace ehs
Mat2<T> GetMinor() const Mat2<T> GetMinor() const
{ {
Mat2<T> result; Mat2<T> result(0);
result.data[0] = data[3]; result.data[0] = data[3];
result.data[1] = data[2]; result.data[1] = data[2];
result.data[2] = data[1]; result.data[2] = data[1];
@ -187,7 +187,7 @@ namespace ehs
Mat2<T> GetInverse() const Mat2<T> GetInverse() const
{ {
T det = GetDeterminant(); T det = GetDeterminant();
if (Math::ComCmp(det, 0)) if (Math::ComCmp(det, 0.0f))
return {}; return {};
return GetAdjugate() * (1 / det); return GetAdjugate() * (1 / det);
@ -196,7 +196,7 @@ namespace ehs
void Inverse() void Inverse()
{ {
T det = GetDeterminant(); T det = GetDeterminant();
if (Math::ComCmp(det, 0)) if (Math::ComCmp(det, 0.0f))
return; return;
Adjugate(); Adjugate();
@ -212,9 +212,6 @@ namespace ehs
} }
}; };
template class EHS_LIB_IO Mat2<float>;
template class EHS_LIB_IO Mat2<double>;
typedef Mat2<float> Mat2_f; typedef Mat2<float> Mat2_f;
typedef Mat2<double> Mat2_d; typedef Mat2<double> Mat2_d;
} }

View File

@ -50,7 +50,7 @@ namespace ehs
Mat2<T> result; Mat2<T> result;
for (UInt_8 i = 0; i < 4; ++i) for (UInt_8 i = 0; i < 4; ++i)
result[i] = data[i / 2 * 4 + i % 2]; result.data[i] = data[i / 2 * 4 + i % 2];
return result; return result;
} }
@ -234,7 +234,7 @@ namespace ehs
Mat3<T> GetInverse() const Mat3<T> GetInverse() const
{ {
T det = GetDeterminant(); T det = GetDeterminant();
if (Math::ComCmp(det, 0)) if (Math::ComCmp(det, 0.0f))
return {}; return {};
return GetAdjugate() * (1 / det); return GetAdjugate() * (1 / det);
@ -243,7 +243,7 @@ namespace ehs
void Inverse() void Inverse()
{ {
T det = GetDeterminant(); T det = GetDeterminant();
if (Math::ComCmp(det, 0)) if (Math::ComCmp(det, 0.0f))
return; return;
Adjugate(); Adjugate();
@ -317,9 +317,6 @@ namespace ehs
} }
}; };
template class EHS_LIB_IO Mat3<float>;
template class EHS_LIB_IO Mat3<double>;
typedef Mat3<float> Mat3_f; typedef Mat3<float> Mat3_f;
typedef Mat3<double> Mat3_d; typedef Mat3<double> Mat3_d;
} }

View File

@ -268,7 +268,7 @@ namespace ehs
Mat4<T> GetInverse() const Mat4<T> GetInverse() const
{ {
T det = GetDeterminant(); T det = GetDeterminant();
if (Math::ComCmp(det, 0)) if (Math::ComCmp(det, 0.0f))
return {}; return {};
return GetAdjugate() * (1 / det); return GetAdjugate() * (1 / det);
@ -277,7 +277,7 @@ namespace ehs
void Inverse() void Inverse()
{ {
T det = GetDeterminant(); T det = GetDeterminant();
if (Math::ComCmp(det, 0)) if (Math::ComCmp(det, 0.0f))
return; return;
Adjugate(); Adjugate();
@ -332,14 +332,14 @@ namespace ehs
static Mat4<T> YawRotate(const T angle) static Mat4<T> YawRotate(const T angle)
{ {
T radians = Math::Rads<T>(angle); T radians = Math::Rads(angle);
Mat4<T> result; Mat4<T> result;
result.data[0] = Math::Cos<T>(radians); result.data[0] = Math::Cos(radians);
result.data[2] = -Math::Sin<T>(radians); result.data[2] = -Math::Sin(radians);
result.data[5] = 1; result.data[5] = 1;
result.data[8] = Math::Sin<T>(radians); result.data[8] = Math::Sin(radians);
result.data[10] = Math::Cos<T>(radians); result.data[10] = Math::Cos(radians);
result.data[15] = 1; result.data[15] = 1;
return result; return result;
@ -347,7 +347,7 @@ namespace ehs
static Mat4<T> RollRotate(const T angle) static Mat4<T> RollRotate(const T angle)
{ {
T radians = Math::Rads<T>(angle); T radians = Math::Rads(angle);
Mat4<T> result; Mat4<T> result;
result.data[0] = Math::Cos(radians); result.data[0] = Math::Cos(radians);
@ -367,7 +367,7 @@ namespace ehs
static Mat4<T> RH_Perspective(const T fov, const T aspect, const T zNear, const T zFar) static Mat4<T> RH_Perspective(const T fov, const T aspect, const T zNear, const T zFar)
{ {
const T tanHalfFovy = Math::Tan<T>(Math::Rads(fov) / 2.0f); const float tanHalfFovy = tan(Math::Rads(fov) / 2.0f);
Mat4<T> result; Mat4<T> result;
result[0] = 1.0f / (aspect * tanHalfFovy); result[0] = 1.0f / (aspect * tanHalfFovy);
@ -380,7 +380,7 @@ namespace ehs
static Mat4<T> LH_Perspective(const T fov, const T aspect, const T zNear, const T zFar) static Mat4<T> LH_Perspective(const T fov, const T aspect, const T zNear, const T zFar)
{ {
const T tanHalfFovy = Math::Tan<T>(Math::Rads(fov) / 2.0f); const float tanHalfFovy = Math::Tan(Math::Rads(fov) / 2.0f);
Mat4<T> result; Mat4<T> result;
result[0] = 1.0f / (aspect * tanHalfFovy); result[0] = 1.0f / (aspect * tanHalfFovy);
@ -421,9 +421,6 @@ namespace ehs
} }
}; };
template class EHS_LIB_IO Mat4<float>;
template class EHS_LIB_IO Mat4<double>;
typedef Mat4<float> Mat4_f; typedef Mat4<float> Mat4_f;
typedef Mat4<double> Mat4_d; typedef Mat4<double> Mat4_d;
} }

View File

@ -6,7 +6,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Math class Math
{ {
private: private:
static float Sqrt_AVX(const float from); static float Sqrt_AVX(const float from);
@ -26,22 +26,22 @@ namespace ehs
constexpr static double dblEpsilon = 1e-16; constexpr static double dblEpsilon = 1e-16;
/// Absolute tolerance comparison for single precision floats. /// Absolute tolerance comparison for single precision floats.
static bool AbsCmp(float a, float b); static bool AbsCmp(const float a, const float b);
/// Absolute tolerance comparison for double precision floats. /// Absolute tolerance comparison for double precision floats.
static bool AbsCmp(double a, double b); static bool AbsCmp(const double a, const double b);
/// Relative tolerance comparison for single precision floats. /// Relative tolerance comparison for single precision floats.
static bool RelCmp(float a, float b); static bool RelCmp(const float a, const float b);
/// Relative tolerance comparison for double precision floats. /// Relative tolerance comparison for double precision floats.
static bool RelCmp(double a, double b); static bool RelCmp(const double a, const double b);
/// Combined absolute and relative tolerance comparison for single precision floats. /// Combined absolute and relative tolerance comparison for single precision floats.
static bool ComCmp(float a, float b); static bool ComCmp(const float a, const float b);
/// Combined absolute and relative tolerance comparison for double precision floats. /// Combined absolute and relative tolerance comparison for double precision floats.
static bool ComCmp(double a, double b); static bool ComCmp(const double a, const double b);
template<typename T = float> template<typename T = float>
static T Max(const T a, const T b) static T Max(const T a, const T b)
@ -101,113 +101,29 @@ namespace ehs
return from * 57.295779513082320876798154814105; return from * 57.295779513082320876798154814105;
} }
template <typename T = float>
static T Exp(const T x)
{
T sum = 1;
T term = 1;
for (int n = 1; n <= 20; ++n)
{
term *= x / n;
sum += term;
}
return sum;
}
template <typename T = float>
static T Ln_Taylor(T x)
{
T result = 0;
T term = (x - 1) / (x + 1);
T term_squared = term * term;
T denominator = 1;
T current_term = term;
for (int n = 0; n < 100; ++n)
{
result += current_term / denominator;
current_term *= term_squared;
denominator += 2;
}
return 2 * result;
}
template <typename T = float>
static T Ln(T x)
{
if (x <= 0)
return -1;
if (x == 1)
return 0;
SSize exp = 0;
while (x > 2)
{
x /= 2;
exp++;
}
while (x < 0.5)
{
x *= 2;
exp--;
}
T result = Ln_Taylor<T>(x);
result += exp * Ln_Taylor<T>(2);
return result;
}
/// A method for use of exponents. /// A method for use of exponents.
/// @tparam T The data type to return; /// @tparam T The data type to return;
/// @tparam I The data type to use as the exponent. /// @tparam I The data type to use as the exponent.
/// @param [in] from The value to use the exponent on. /// @param [in] from The value to use the exponent on.
/// @param [in] of The exponent. /// @param [in] of The exponent.
/// @returns The result. /// @returns The result.
template<typename T = float, typename I = float> template<typename T = float, typename I = UInt_64>
static T Pow(const T base, const I exponent) static T Pow(const T from, const I of)
{ {
if (base == 0) if (of < 0)
return (exponent == 0) ? 1 : 0; {
if (from == 0)
return -0;
if (exponent == 0) return 1 / (from * Pow<T>(from, (-of) - 1));
return 1; }
SSize intExp = (SSize)exponent; if (of == 0)
bool isInteger = exponent == intExp; return 1;
bool isNeg = base < 0; else if (of == 1)
return from;
if (isNeg && isInteger) return from * Pow<T>(from, of - 1);
{
T result = Exp<T>(exponent * Ln<T>(-base));
if ((SSize)exponent % 2)
result = -result;
return result;
}
if (isNeg && !isInteger)
{
T magnitude = Exp<T>(exponent * Ln<T>(-base));
T angle = exponent * Pi<T>();
T realPart = magnitude * Cos<T>(angle);
T imagPart = magnitude * Sin<T>(angle);
return realPart;
}
return Exp<T>(exponent * Ln<T>(base));
}
template <typename T = float>
static T Log10(const T x)
{
return Ln<T>(x) / Ln<T>(10);
} }
static float Near(const float from); static float Near(const float from);

View File

@ -10,9 +10,9 @@ namespace ehs
void* data; void* data;
}; };
EHS_LIB_IO bool HasPtrData(void* data); bool HasPtrData(void* data);
EHS_LIB_IO void AddPtrData(void* data); void AddPtrData(void* data);
EHS_LIB_IO bool RemovePtrData(void* data); bool RemovePtrData(void* data);
} }

View File

@ -130,7 +130,7 @@ namespace ehs
case 3: case 3:
return h; return h;
default: default:
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Rectangle."); EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Rectangle.");
return x; return x;
} }
} }
@ -148,7 +148,7 @@ namespace ehs
case 3: case 3:
return h; return h;
default: default:
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Rectangle."); EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Rectangle.");
return x; return x;
} }
} }

View File

@ -87,7 +87,7 @@ namespace ehs
{ {
if (index >= size) if (index >= size)
{ {
EHS_LOG_INT(LogType::WARN, 0, "Cannot insert value at " + Str_8::FromNum(index) + " because it is outside of array range of " + size + "."); EHS_LOG_INT("Warning", 0, "Cannot insert value at " + Str_8::FromNum(index) + " because it is outside of array range of " + size + ".");
return; return;
} }

View File

@ -194,7 +194,8 @@ namespace ehs
Byte* r = new Byte[this->size + remainder]; Byte* r = new Byte[this->size + remainder];
Util::Copy(r, data, this->size); for (N i = 0; i < this->size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -264,7 +265,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -334,7 +336,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -395,87 +398,17 @@ namespace ehs
offset += sizeof(T) * value.Size(); offset += sizeof(T) * value.Size();
} }
template<typename T, typename O = UInt_64>
void WriteStr(const T* str, N inSize = 0)
{
bool sizeKnown = inSize;
if (!sizeKnown)
while (str[inSize])
inSize++;
N bSize = sizeof(T) * inSize;
N bSizeN = bSize;
if (!sizeKnown)
bSizeN += sizeof(T);
if (bSizeN > size - offset)
{
N remainder = bSizeN - (size - offset);
Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size);
delete[] data;
data = r;
size += remainder;
}
if (CPU::GetEndianness() == Endianness::LE)
{
if (endianness == Endianness::LE)
{
Util::Copy(&data[offset], &str[0], bSize);
if (!sizeKnown)
*(T*)&data[offset + inSize] = 0;
}
else
{
for (N i = 0; i < inSize; ++i)
for (N b = 0; b < sizeof(T); ++b)
data[offset + sizeof(T) * i + b] = ((Byte*)&str[i])[sizeof(T) - i - 1];
if (!sizeKnown)
*(T*)&data[offset + bSize] = 0;
}
}
else
{
if (endianness == Endianness::LE)
{
for (N i = 0; i < inSize; ++i)
for (N b = 0; b < sizeof(T); ++b)
data[offset + sizeof(T) * i + b] = ((Byte*)&str[i])[sizeof(T) - i - 1];
if (!sizeKnown)
*(T*)&data[offset + bSize] = 0;
}
else
{
Util::Copy(&data[offset], &str[0], bSize);
if (!sizeKnown)
*(T*)&data[offset + bSize] = 0;
}
}
offset += bSizeN;
}
template<typename T, typename O = UInt_64> template<typename T, typename O = UInt_64>
void WriteStr(const Str<T, O>& str) void WriteStr(const Str<T, O>& str)
{ {
N inSize = sizeof(T) * (str.Size() + 1); if (sizeof(N) + sizeof(T) * str.Size() > size - offset)
if (inSize > size - offset)
{ {
N remainder = inSize - (size - offset); N remainder = sizeof(N) + sizeof(T) * str.Size() - (size - offset);
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -486,38 +419,54 @@ namespace ehs
{ {
if (endianness == Endianness::LE) if (endianness == Endianness::LE)
{ {
Util::Copy(&data[offset], &str[0], str.Size(true)); *(N*)&data[offset] = (N)str.Size();
*(T*)&data[offset + str.Size(true)] = 0; offset += sizeof(N);
for (N i = 0; i < str.Size(); ++i)
*(T*)&data[offset + i * sizeof(T)] = str[i];
} }
else else
{ {
N tmpSize = (N)str.Size();
for (N i = 0; i < sizeof(N); ++i)
data[offset + i] = ((Byte*)&tmpSize)[sizeof(N) - i - 1];
offset += sizeof(N);
for (N i = 0; i < str.Size(); ++i) for (N i = 0; i < str.Size(); ++i)
for (N b = 0; b < sizeof(T); ++b) for (N b = 0; b < sizeof(T); ++b)
data[offset + sizeof(T) * i + b] = ((Byte*)&str[i])[sizeof(T) - i - 1]; data[offset + i * sizeof(T) + b] = ((Byte*)&str[i])[sizeof(T) - i - 1];
*(T*)&data[offset + str.Size(true)] = 0;
} }
} }
else else
{ {
if (endianness == Endianness::LE) if (endianness == Endianness::LE)
{ {
N tmpSize = (N)str.Size();
for (N i = 0; i < sizeof(N); ++i)
data[offset + i] = ((Byte*)&tmpSize)[sizeof(N) - i - 1];
offset += sizeof(N);
for (N i = 0; i < str.Size(); ++i) for (N i = 0; i < str.Size(); ++i)
for (N b = 0; b < sizeof(T); ++b) for (N b = 0; b < sizeof(T); ++b)
data[offset + sizeof(T) * i + b] = ((Byte*)&str[i])[sizeof(T) - i - 1]; data[offset + i * sizeof(T) + b] = ((Byte*)&str[i])[sizeof(T) - i - 1];
*(T*)&data[offset + str.Size(true)] = 0;
} }
else else
{ {
Util::Copy(&data[offset], &str[0], str.Size(true)); *(N*)&data[offset] = (N)str.Size();
*(T*)&data[offset + str.Size(true)] = 0; offset += sizeof(N);
for (N i = 0; i < str.Size(); ++i)
*(T*)&data[offset + i * sizeof(T)] = str[i];
} }
} }
offset += inSize; offset += str.Size() * sizeof(T);
} }
void WriteVersion(const Version& value) void WriteVersion(const Version& value)
@ -528,7 +477,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -568,7 +518,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -608,7 +559,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -647,7 +599,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -687,7 +640,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -727,7 +681,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -766,7 +721,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -806,7 +762,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -846,7 +803,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -886,7 +844,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -926,7 +885,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -984,26 +944,6 @@ namespace ehs
offset += ser.Size(); offset += ser.Size();
} }
void WritePadding(const N size)
{
if (size > this->size - offset)
{
N remainder = size - (this->size - offset);
Byte* r = new Byte[this->size + remainder];
Util::Copy(r, data, this->size);
delete[] data;
data = r;
this->size += remainder;
}
Util::Zero(&data[offset], size);
offset += size;
}
template<typename T> template<typename T>
void Write(const T value) void Write(const T value)
{ {
@ -1013,7 +953,8 @@ namespace ehs
Byte* r = new Byte[size + remainder]; Byte* r = new Byte[size + remainder];
Util::Copy(r, data, size); for (N i = 0; i < size; ++i)
r[i] = data[i];
delete[] data; delete[] data;
data = r; data = r;
@ -1044,10 +985,7 @@ namespace ehs
void ReadArray(T* const value, O* const size) void ReadArray(T* const value, O* const size)
{ {
if (!*size) if (!*size)
{ *size = (O)Read<N>();
*size = (O)Read<N>();
return;
}
for (N i = 0; i < *size; ++i) for (N i = 0; i < *size; ++i)
value[i] = Read<T>(); value[i] = Read<T>();
@ -1075,40 +1013,13 @@ namespace ehs
return result; return result;
} }
template<typename T = Char_8, typename O = UInt_64> template<typename T, typename O>
Str<T, O> ReadStr(O size = 0) Str<T, O> ReadStr(const O size = 0)
{ {
bool sizeKnown = size; Str<T, O> result(size ? size : (O)Read<N>());
if (!sizeKnown) for (O i = 0; i < result.Size(); ++i)
while (((T*)&data[offset])[size]) result[i] = Read<T>();
++size;
Str<T, O> result(size);
if (CPU::GetEndianness() == Endianness::LE)
{
if (endianness == Endianness::LE)
Util::Copy(&result[0], &data[offset], result.Size(true));
else
for (N i = 0; i < size; ++i)
for (N b = 0; b < sizeof(T); ++b)
((Byte*)&result[i])[b] = data[offset + sizeof(T) * i + b];
}
else
{
if (endianness == Endianness::LE)
for (N i = 0; i < size; ++i)
for (N b = 0; b < sizeof(T); ++b)
((Byte*)&result[i])[b] = data[offset + sizeof(T) * i + b];
else
Util::Copy(&result[0], &data[offset], result.Size(true));
}
offset += result.Size(true);
if (!sizeKnown)
offset++;
return result; return result;
} }

View File

@ -564,7 +564,7 @@ namespace ehs
return; return;
} }
Util::Copy(&data[dstOffset], src, src.Size(true)); Util::Copy(data[dstOffset], src, src.Size(true));
} }
/// Copies a C-style string to the referenced string object. /// Copies a C-style string to the referenced string object.
@ -580,7 +580,7 @@ namespace ehs
return; return;
} }
Util::Copy(&data[dstOffset], src, srcSize * sizeof(T)); Util::Copy(data[dstOffset], src, srcSize * sizeof(T));
} }
/// Copies a C-style string to the referenced string object. /// Copies a C-style string to the referenced string object.
@ -595,7 +595,7 @@ namespace ehs
return; return;
} }
Util::Copy(&data[dstOffset], src, srcSize * sizeof(T)); Util::Copy(data[dstOffset], src, srcSize * sizeof(T));
} }
/// Inserts a string at a specified index. /// Inserts a string at a specified index.
@ -747,7 +747,7 @@ namespace ehs
T* result = new T[size + inSize + 1]; T* result = new T[size + inSize + 1];
Util::Copy(result, data, Size(true)); Util::Copy(result, data, Size(true));
Util::Copy(&result[size], value, inSize * sizeof(T)); Util::Copy(result[size], value, inSize * sizeof(T));
result[size + inSize] = 0; result[size + inSize] = 0;
@ -1027,7 +1027,7 @@ namespace ehs
/// @param [in] pattern The search pattern for optimization. /// @param [in] pattern The search pattern for optimization.
/// @param [in] result What index to return where the first instance is found. /// @param [in] result What index to return where the first instance is found.
/// @returns The index where the instance was found with the result varying from the result parameter. /// @returns The index where the instance was found with the result varying from the result parameter.
bool Find(const Str<T, N> &ide, N* const index = nullptr, const SearchPattern pattern = SearchPattern::LEFT_RIGHT, const IndexResult result = IndexResult::BEGINNING) const bool Find(const Str<T, N>& ide, N* const index = nullptr, const SearchPattern pattern = SearchPattern::LEFT_RIGHT, const IndexResult result = IndexResult::BEGINNING) const
{ {
if (pattern == SearchPattern::LEFT_RIGHT) if (pattern == SearchPattern::LEFT_RIGHT)
{ {
@ -1271,11 +1271,8 @@ namespace ehs
/// @note Use "IsNum" before this if the string object is not guaranteed to be a number. /// @note Use "IsNum" before this if the string object is not guaranteed to be a number.
float ToFloat() const float ToFloat() const
{ {
Str<T, N> ide;
ide.Push(46);
N decPoint = size; N decPoint = size;
Find(ide, &decPoint); Find(".", &decPoint);
float result = 0.0f; float result = 0.0f;
float fraction = 0.0f; float fraction = 0.0f;
@ -1300,11 +1297,8 @@ namespace ehs
/// @note Use "IsNum" before this if the string object is not guaranteed to be a number. /// @note Use "IsNum" before this if the string object is not guaranteed to be a number.
double ToDouble() const double ToDouble() const
{ {
Str<T, N> ide;
ide.Push(46);
N decPoint = size; N decPoint = size;
Find(ide, &decPoint); Find(".", &decPoint);
double result = 0.0f; double result = 0.0f;
double fraction = 0.0f; double fraction = 0.0f;
@ -1329,11 +1323,8 @@ namespace ehs
/// @note Use "IsNum" before this if the string object is not guaranteed to be a number. /// @note Use "IsNum" before this if the string object is not guaranteed to be a number.
long double ToLDouble() const long double ToLDouble() const
{ {
Str<T, N> ide;
ide.Push(46);
N decPoint = size; N decPoint = size;
Find(ide, &decPoint); Find(".", &decPoint);
long double result = 0.0f; long double result = 0.0f;
long double fraction = 0.0f; long double fraction = 0.0f;
@ -1688,7 +1679,7 @@ namespace ehs
Str<T, N> result; Str<T, N> result;
if (whole < 0) if (whole < 0)
result.Push(45); result += "-";
result += Str<T, N>::FromNum(whole); result += Str<T, N>::FromNum(whole);
@ -1700,7 +1691,7 @@ namespace ehs
if (!fraction) if (!fraction)
return result; return result;
result.Push(46); result += ".";
Str<T, N> fResult(maxDecimals); Str<T, N> fResult(maxDecimals);
N i = 0; N i = 0;
@ -1730,7 +1721,7 @@ namespace ehs
Str<T, N> result; Str<T, N> result;
if (whole < 0) if (whole < 0)
result.Push(45); result += "-";
result += Str<T, N>::FromNum(whole); result += Str<T, N>::FromNum(whole);
@ -1742,7 +1733,7 @@ namespace ehs
if (!fraction) if (!fraction)
return result; return result;
result.Push(46); result += ".";
Str<T, N> fResult(maxDecimals); Str<T, N> fResult(maxDecimals);
N i = 0; N i = 0;
@ -1772,7 +1763,7 @@ namespace ehs
Str<T, N> result; Str<T, N> result;
if (whole < 0) if (whole < 0)
result.Push(45); result += "-";
result += Str<T, N>::FromNum(whole); result += Str<T, N>::FromNum(whole);
@ -1784,7 +1775,7 @@ namespace ehs
if (!fraction) if (!fraction)
return result; return result;
result.Push(46); result += ".";
Str<T, N> fResult(maxDecimals); Str<T, N> fResult(maxDecimals);
N i = 0; N i = 0;
@ -1804,23 +1795,23 @@ namespace ehs
return result; return result;
} }
/// A 32-bit FNV-1a hash algorithm. /// A 32-bit FNV-1a hash algorithm.
/// @param [in] str The string to hash. /// @param [in] str The string to hash.
/// @returns The resulting hash. Zero if string does not contain any characters. /// @returns The resulting hash. Zero if string does not contain any characters.
static UInt_32 Hash_32(const Str<T, N>& str) static UInt_32 Hash_32(const Str<T, N>& str)
{ {
if (!str.Size()) if (!str.Size())
return 0; return 0;
const Byte* const bytes = str.ToBytes(); const Byte* const bytes = str.ToBytes();
UInt_32 hash = 2166136261ul; UInt_32 hash = 2166136261ul;
for (N i = 0; i < str.Size(true); ++i) for (N i = 0; i < str.Size(true); ++i)
hash = (hash ^ bytes[i]) * 16777619; hash = (hash ^ bytes[i]) * 16777619;
return hash; return hash;
} }
/// A 32-bit FNV-1a hash algorithm. /// A 32-bit FNV-1a hash algorithm.
/// @returns The resulting hash. Zero if string does not contain any characters. /// @returns The resulting hash. Zero if string does not contain any characters.
@ -1839,23 +1830,23 @@ namespace ehs
return hash; return hash;
} }
/// A 64-bit FNV-1a hash algorithm. /// A 64-bit FNV-1a hash algorithm.
/// @param [in] str The string to hash. /// @param [in] str The string to hash.
/// @returns The resulting hash. Zero if string does not contain any characters. /// @returns The resulting hash. Zero if string does not contain any characters.
static UInt_64 Hash_64(const Str<T, N>& str) static UInt_64 Hash_64(const Str<T, N>& str)
{ {
if (!str.Size()) if (!str.Size())
return 0; return 0;
const Byte* const bytes = str.ToBytes(); const Byte* const bytes = str.ToBytes();
UInt_64 hash = 14695981039346656037ull; UInt_64 hash = 14695981039346656037ull;
for (N i = 0; i < str.Size(true); ++i) for (N i = 0; i < str.Size(true); ++i)
hash = (hash ^ bytes[i]) * 1099511628211; hash = (hash ^ bytes[i]) * 1099511628211;
return hash; return hash;
} }
/// A 64-bit FNV-1a hash algorithm. /// A 64-bit FNV-1a hash algorithm.
/// @returns The resulting hash. Zero if string does not contain any characters. /// @returns The resulting hash. Zero if string does not contain any characters.
@ -1879,9 +1870,6 @@ namespace ehs
/// @returns The character count. /// @returns The character count.
static N Len(const T* const str) static N Len(const T* const str)
{ {
if (!str)
return 0;
N count = 0; N count = 0;
while (str[count]) while (str[count])
++count; ++count;
@ -1900,14 +1888,14 @@ namespace ehs
if (aSize != bSize) if (aSize != bSize)
return false; return false;
return Util::Compare(a, b, aSize); for (UInt_64 i = 0; i < aSize; ++i)
if (a[i] != b[i])
return false;
return true;
} }
}; };
template class EHS_LIB_IO Str<Char_32, UInt_64>;
template class EHS_LIB_IO Str<Char_16, UInt_64>;
template class EHS_LIB_IO Str<Char_8, UInt_64>;
typedef Str<Char_32, UInt_64> Str_32; typedef Str<Char_32, UInt_64> Str_32;
typedef Str<Char_16, UInt_64> Str_16; typedef Str<Char_16, UInt_64> Str_16;
typedef Str<Char_8, UInt_64> Str_8; typedef Str<Char_8, UInt_64> Str_8;

View File

@ -9,7 +9,7 @@ namespace ehs
{ {
typedef void (*TaskCb)(Serializer<UInt_64>*); typedef void (*TaskCb)(Serializer<UInt_64>*);
class EHS_LIB_IO Task class Task
{ {
private: private:
bool working; bool working;

View File

@ -5,7 +5,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Type class Type
{ {
private: private:
friend class BaseObj; friend class BaseObj;

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include "ehs/system/OS.h" #include "ehs/system/OS.h"
#include "ehs/system/Architecture.h"
#define EHS_MAX_PATH 0x104 #define EHS_MAX_PATH 0x104
#define EHS_UINT_8_MAX 0xFF #define EHS_UINT_8_MAX 0xFF
@ -26,12 +25,6 @@
#define EHS_LDOUBLE_MAX 1.79769e+308 #define EHS_LDOUBLE_MAX 1.79769e+308
#define EHS_LDOUBLE_MIN 2.22507e-308 #define EHS_LDOUBLE_MIN 2.22507e-308
#if defined(EHS_64_BIT)
#define EHS_SIZE_MAX 0xFFFFFFFFFFFFFFFF
#elif defined(EHS_32_BIT)
#define EHS_SIZE_MAX 0xFFFFFFFF
#endif
#define EHS_INFINITE EHS_UINT_32_MAX #define EHS_INFINITE EHS_UINT_32_MAX
namespace ehs namespace ehs
@ -59,12 +52,4 @@ namespace ehs
typedef signed long SInt_64; typedef signed long SInt_64;
typedef long Int_64; typedef long Int_64;
#endif #endif
#if defined(EHS_64_BIT)
typedef UInt_64 Size;
typedef SInt_64 SSize;
#elif defined(EHS_32_BIT)
typedef UInt_32 Size;
typedef SInt_32 SSize;
#endif
} }

View File

@ -5,7 +5,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO URI class URI
{ {
public: public:
/// Encodes specialized characters in the URI. /// Encodes specialized characters in the URI.

View File

@ -13,7 +13,7 @@ namespace ehs
}; };
/// A helper class for converting between UTF8, 16 and 32. /// A helper class for converting between UTF8, 16 and 32.
class EHS_LIB_IO UTF class UTF
{ {
public: public:
/// Converts the given UTF16 C-style string into UTF32. /// Converts the given UTF16 C-style string into UTF32.

View File

@ -4,7 +4,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Util class Util
{ {
public: public:
static bool Compare(const void* a, const void* b, UInt_64 size); static bool Compare(const void* a, const void* b, UInt_64 size);

View File

@ -229,7 +229,7 @@ namespace ehs
case 1: case 1:
return y; return y;
default: default:
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3."); EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3.");
return x; return x;
} }
} }
@ -243,7 +243,7 @@ namespace ehs
case 1: case 1:
return y; return y;
default: default:
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3."); EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3.");
return x; return x;
} }
} }

View File

@ -266,7 +266,7 @@ namespace ehs
case 2: case 2:
return z; return z;
default: default:
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3."); EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3.");
return x; return x;
} }
} }
@ -282,7 +282,7 @@ namespace ehs
case 2: case 2:
return z; return z;
default: default:
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3."); EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3.");
return x; return x;
} }
} }

View File

@ -279,7 +279,7 @@ namespace ehs
case 3: case 3:
return w; return w;
default: default:
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 4."); EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 4.");
return x; return x;
} }
} }
@ -297,7 +297,7 @@ namespace ehs
case 3: case 3:
return w; return w;
default: default:
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 4."); EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 4.");
return x; return x;
} }
} }

View File

@ -5,7 +5,7 @@
namespace ehs namespace ehs
{ {
/// A helper class for storing version major, minor and patch. /// A helper class for storing version major, minor and patch.
class EHS_LIB_IO Version class Version
{ {
public: public:
UInt_32 major; UInt_32 major;

View File

@ -0,0 +1,20 @@
#pragma once
#include "ehs/EHS.h"
#include "ehs/BaseObj.h"
#include "ehs/Str.h"
namespace ehs
{
enum class DType : UInt_8
{
};
class DVar : public BaseObj
{
private:
Str_8 id;
UInt_64 hashId;
};
}

View File

@ -1,56 +0,0 @@
#pragma once
#include "ehs/Array.h"
#include "DbTable.h"
namespace ehs
{
class EHS_LIB_IO Database
{
private:
UInt_64 hashId;
Str_8 id;
Version version;
Array<DbTable> tables;
Str_8 dir;
public:
Database();
Database(Str_8 id, const Version& version);
Database(Str_8 filePath);
Database(Database&& db) noexcept;
Database(const Database& db);
Database& operator=(Database&& db) noexcept;
Database& operator=(const Database& db);
UInt_64 GetHashId() const;
void SetId(Str_8 newId);
Str_8 GetId() const;
void SetVersion(const Version& newVersion);
Version GetVersion() const;
bool HasTable(UInt_64 hashId) const;
bool HasTable(const Str_8& id) const;
DbTable* CreateTable(Str_8 id);
DbTable* GetTable(UInt_64 hashId) const;
DbTable* GetTable(const Str_8& id) const;
Str_8 GetDirectory() const;
void Save(Str_8 directory);
};
}

View File

@ -1,52 +0,0 @@
#pragma once
#include "ehs/Array.h"
#include "DbVar.h"
namespace ehs
{
class DbTable;
class EHS_LIB_IO DbObject
{
private:
friend class DbTable;
friend class DbVar;
UInt_64 id;
DbTable* parent;
Array<DbVar> vars;
public:
DbObject();
DbObject(UInt_64 id);
DbObject(DbObject&& obj) noexcept;
DbObject(const DbObject& obj);
DbObject& operator=(DbObject&& obj) noexcept;
DbObject& operator=(const DbObject& obj);
UInt_64 GetId() const;
bool HasVariable(UInt_64 hashId) const;
DbVar* GetVariable(UInt_64 hashId) const;
DbVar* GetVariable(const Str_8& id) const;
void Save() const;
void Load();
bool IsLoaded() const;
void Free();
private:
void CreateVariable(DbVarTmpl* master);
};
}

View File

@ -1,66 +0,0 @@
#pragma once
#include "ehs/Version.h"
#include "ehs/Array.h"
#include "DbVarTmpl.h"
#include "DbObject.h"
#include "ehs/Serializer.h"
namespace ehs
{
class Database;
class EHS_LIB_IO DbTable
{
private:
friend class Database;
friend class DbVar;
friend class DbObject;
Database *parent;
UInt_64 hashId;
Str_8 id;
Array<DbVarTmpl> varTmpls;
Array<DbObject> objects;
public:
DbTable();
DbTable(Str_8 id);
DbTable(DbTable&& table) noexcept;
DbTable(const DbTable& table);
DbTable& operator=(DbTable&& table) noexcept;
DbTable& operator=(const DbTable& table);
UInt_64 GetHashId() const;
void SetId(Str_8 newId);
Str_8 GetId() const;
bool HasVariable(UInt_64 hashId) const;
bool HasVariable(const Str_8& id) const;
bool CreateVariable(DbVarTmpl var);
DbObject *CreateObject();
DbObject *GetObject(UInt_64 variableHashId, const Str_8 &value) const;
DbObject *GetObject(const Str_8 &variable, const Str_8 &value) const;
DbObject *GetObject(UInt_64 id) const;
private:
DbVarTmpl *GetVariableTemplate(UInt_64 hashId) const;
void Serialize(const Str_8 &dir, Serializer<UInt_64>& data) const;
void Deserialize(const Str_8 &dir, Serializer<UInt_64>& data);
};
}

View File

@ -1,105 +0,0 @@
#pragma once
#include "ehs/Types.h"
#include "ehs/Serializer.h"
namespace ehs
{
class DbVarTmpl;
class DbObject;
class EHS_LIB_IO DbVar
{
private:
friend class DbObject;
UInt_64 hashId;
DbObject *parent;
Byte *value;
UInt_64 size;
public:
~DbVar();
DbVar();
DbVar(UInt_64 hashId, const DbVarTmpl *master);
DbVar(DbVar &&var) noexcept;
DbVar(const DbVar &var);
DbVar &operator=(DbVar &&var) noexcept;
DbVar &operator=(const DbVar &var);
explicit operator Byte *() const;
UInt_64 GetHashId() const;
template<typename T>
void SetValueArray(const T* const newValue, const UInt_64 newSize)
{
size = sizeof(T) * newSize;
value = new Byte[size];
Util::Copy(value, newValue, size);
}
template<typename T = Char_8>
void SetValueStr(const T * const newValue)
{
size = sizeof(T) * Str<Char_8, UInt_64>::Len(newValue);
value = new Byte[size];
Util::Copy(value, newValue, size);
}
template<typename T = Char_8, typename I = UInt_64>
void SetValueStr(const Str<T, I>& newValue)
{
size = newValue.Size(true);
value = new Byte[size];
Util::Copy(value, &newValue[0], size);
}
template<typename T>
void SetValue(const Byte* newValue)
{
size = sizeof(T);
value = new Byte[size];
Util::Copy(value, newValue, size);
}
template<typename T>
T* GetValueArray() const
{
return (T*)value;
}
template<typename T = Char_8, typename I = UInt_64>
Str<T, I> GetValueStr() const
{
return {(T*)value, size / sizeof(T)};
}
template<typename T>
T GetValue() const
{
return *(T*)value;
}
UInt_64 GetSize() const;
private:
void Serialize(Serializer<UInt_64> &data) const;
void Deserialize(Serializer<UInt_64> &data);
};
}

View File

@ -1,77 +0,0 @@
#pragma once
#include "ehs/EHS.h"
#include "ehs/Serializer.h"
#include "ehs/Str.h"
namespace ehs
{
class DbVar;
class EHS_LIB_IO DbVarTmpl
{
private:
friend class DbTable;
UInt_64 hashId;
Str_8 id;
Byte* def;
UInt_64 size;
public:
~DbVarTmpl();
DbVarTmpl();
template<typename T>
DbVarTmpl(Str_8 id, const T* const def, UInt_64 size)
: hashId(id.Hash_64()), id((Str_8&&)id), def(new Byte[sizeof(T) * size]), size(sizeof(T) * size)
{
Util::Copy(this->def, def, this->size);
}
template<typename T>
DbVarTmpl(Str_8 id, const T* const def)
: hashId(id.Hash_64()), id((Str_8&&)id), def(new Byte[sizeof(T)]), size(sizeof(T))
{
Util::Copy(this->def, def, this->size);
}
DbVarTmpl(Str_8 id);
DbVarTmpl(DbVarTmpl&& varTmpl) noexcept;
DbVarTmpl(const DbVarTmpl& varTmpl);
DbVarTmpl& operator=(DbVarTmpl&& varTmpl) noexcept;
DbVarTmpl& operator=(const DbVarTmpl& varTmpl);
operator Byte *() const;
UInt_64 GetHashId() const;
void SetId(Str_8 newId);
Str_8 GetId() const;
template<typename T>
T* GetDefaultArray() const
{
return (T*)def;
}
template<typename T>
T GetDefault() const
{
return *(T*)def;
}
UInt_64 GetSize() const;
private:
void Serialize(Serializer<UInt_64> &data) const;
void Deserialize(Serializer<UInt_64> &data);
};
}

View File

@ -1,17 +0,0 @@
#pragma once
#include "ehs/Array.h"
#include "ehs/Str.h"
namespace ehs
{
class EHS_LIB_IO BaseDirectory
{
public:
static Array<Str_8> GetAllFiles(const Str_8 &dir);
static void CreateRecursive(Str_8 dir);
static void Create(const Str_8 &dir);
};
}

View File

@ -25,7 +25,7 @@ namespace ehs
}; };
/// A cross-platform wrapper class that handles native file input/output. /// A cross-platform wrapper class that handles native file input/output.
class EHS_LIB_IO BaseFile class BaseFile
{ {
protected: protected:
Str_8 path; Str_8 path;

View File

@ -11,7 +11,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO BaseFileMonitor class BaseFileMonitor
{ {
protected: protected:
Str_8 filePath; Str_8 filePath;

View File

@ -1,7 +1,9 @@
#pragma once #pragma once
#include "ehs/EHS.h"
#include "ehs/Str.h" #include "ehs/Str.h"
#include "ehs/Vec2.h" #include "ehs/Vec2.h"
#include "ehs/Rect.h"
#include "ehs/io/hid/Input.h" #include "ehs/io/hid/Input.h"
namespace ehs namespace ehs
@ -18,7 +20,7 @@ namespace ehs
I_BEAM I_BEAM
}; };
class EHS_LIB_IO BaseWindow class BaseWindow
{ {
protected: protected:
bool created; bool created;
@ -58,6 +60,10 @@ namespace ehs
bool HasFocus() const; bool HasFocus() const;
void EnableResizing(bool enable);
bool IsResizable() const;
/// Gets the cursors position on the desktop in pixels. /// Gets the cursors position on the desktop in pixels.
/// @param [in] relative Whether the position should be relative to the windows client. /// @param [in] relative Whether the position should be relative to the windows client.
/// @returns The current value. /// @returns The current value.

View File

@ -20,7 +20,7 @@ namespace ehs
TWO TWO
}; };
class EHS_LIB_IO COM class COM
{ {
private: private:
UInt_8 port; UInt_8 port;

View File

@ -12,7 +12,7 @@ namespace ehs
typedef int ConsoleHdl; typedef int ConsoleHdl;
#endif #endif
class EHS_LIB_IO Console class Console
{ {
private: private:
static ConsoleHdl hdlOut; static ConsoleHdl hdlOut;

View File

@ -1,9 +0,0 @@
#pragma once
#include "ehs/system/OS.h"
#if defined(EHS_OS_WINDOWS)
#include "Directory_W32.h"
#elif defined(EHS_OS_LINUX)
#include "Directory_LNX.h"
#endif

View File

@ -1,16 +0,0 @@
#pragma once
#include "BaseDirectory.h"
namespace ehs
{
class EHS_LIB_IO Directory : public BaseDirectory
{
public:
static Array<Str_8> GetAllFiles(const Str_8 &dir);
static void CreateRecursive(Str_8 dir);
static void Create(const Str_8 &dir);
};
}

View File

@ -1,16 +0,0 @@
#pragma once
#include "BaseDirectory.h"
namespace ehs
{
class EHS_LIB_IO Directory : public BaseDirectory
{
public:
static Array<Str_8> GetAllFiles(const Str_8 &dir);
static void CreateRecursive(Str_8 dir);
static void Create(const Str_8 &dir);
};
}

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "ehs/system/OS.h" #include "ehs/EHS.h"
#if defined(EHS_OS_WINDOWS) #if defined(EHS_OS_WINDOWS)
#include "File_W32.h" #include "File_W32.h"

View File

@ -5,7 +5,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO FileMonitor : public BaseFileMonitor class FileMonitor : public BaseFileMonitor
{ {
private: private:
int hdl; int hdl;

View File

@ -5,7 +5,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO FileMonitor final : public BaseFileMonitor class FileMonitor final : public BaseFileMonitor
{ {
private: private:
Handle hdl; Handle hdl;

View File

@ -10,7 +10,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO File : public BaseFile class File : public BaseFile
{ {
private: private:
int hdl; int hdl;

View File

@ -10,7 +10,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO File : public BaseFile class File : public BaseFile
{ {
private: private:
HANDLE hdl; HANDLE hdl;

View File

@ -6,11 +6,11 @@
#include "Glyph.h" #include "Glyph.h"
#include "ehs/Anchor.h" #include "ehs/Anchor.h"
#include "ehs/io/img/Img.h" #include "ehs/io/img/Img.h"
#include "ehs/io/mdl/Mesh.h" #include "ehs/io/model/Mesh.h"
namespace ehs namespace ehs
{ {
class EHS_LIB_IO FontAtlas : public BaseObj class FontAtlas : public BaseObj
{ {
private: private:
UInt_64 hashId; UInt_64 hashId;

View File

@ -7,7 +7,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Glyph class Glyph
{ {
private: private:
Char_32 code; Char_32 code;
@ -20,7 +20,7 @@ namespace ehs
public: public:
Glyph(); Glyph();
Glyph(Serializer<UInt_64>& ser); Glyph(Serializer<>& ser);
Glyph(const Char_32 code); Glyph(const Char_32 code);

View File

@ -8,7 +8,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO RIFF class RIFF
{ {
private: private:
Str_8 type; Str_8 type;

View File

@ -6,7 +6,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO RIFF_Chunk class RIFF_Chunk
{ {
private: private:
Str_8 id; Str_8 id;

View File

@ -7,7 +7,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Resource : public BaseObj class Resource : public BaseObj
{ {
private: private:
ehs::UInt_64 hashId; ehs::UInt_64 hashId;

View File

@ -1,48 +0,0 @@
#pragma once
#include "ehs/Types.h"
namespace ehs
{
class EHS_LIB_IO UsbBase
{
private:
UInt_32 bus;
UInt_32 address;
public:
virtual ~UsbBase() = default;
UsbBase();
UsbBase(UInt_32 bus, UInt_32 address);
UsbBase(UsbBase&& usb) noexcept;
UsbBase(const UsbBase& usb);
UsbBase& operator=(UsbBase&& usb) noexcept;
UsbBase& operator=(const UsbBase& usb);
virtual void Initialize() = 0;
virtual void Release() = 0;
virtual bool IsInitialized() const = 0;
virtual Size Send(const Byte* data, Size size) = 0;
void BulkSend(const Byte* data, Size size);
virtual Size Receive(Byte* data, Size size) = 0;
void BulkReceive(Byte** data, Size* size);
UInt_32 GetBus() const;
UInt_32 GetAddress() const;
bool IsValid() const;
};
}

View File

@ -1,34 +0,0 @@
#pragma once
#include "UsbBase.h"
#include "File.h"
namespace ehs
{
class EHS_LIB_IO Usb final : public UsbBase
{
private:
int hdl;
public:
~Usb() override;
Usb();
Usb(UInt_32 bus, UInt_32 address);
Usb(Usb&& usb) noexcept;
Usb(const Usb& usb);
Usb& operator=(Usb&& usb) noexcept;
Usb& operator=(const Usb& usb);
void Initialize() override;
void Release() override;
bool IsInitialized() const override;
};
}

View File

@ -14,7 +14,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Window : public BaseWindow class Window : public BaseWindow
{ {
private: private:
UInt_32 owner; UInt_32 owner;
@ -71,6 +71,13 @@ namespace ehs
void SetIcon(const Str_8& filePath); void SetIcon(const Str_8& filePath);
/// Sets the windows client scale.
/// @param [in] w The width in pixels.
/// @param [in] h The height in pixels.
void SetClientSize(const Vec2<UInt_32>& size);
Vec2<UInt_32> GetClientSize();
/// Gets the windows native handle for the operating system or other native tasks. /// Gets the windows native handle for the operating system or other native tasks.
/// @returns The window's native handle. /// @returns The window's native handle.
HWND GetHdl() const; HWND GetHdl() const;

View File

@ -4,27 +4,21 @@
#include <wayland-client.h> #include <wayland-client.h>
#include "xdg-shell-client-protocol.h" #include "xdg-shell-client-protocol.h"
#include "xdg-decoration.h"
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Window : public BaseWindow class Window : public BaseWindow
{ {
protected: private:
wl_display *display; wl_display* display;
wl_registry *registry; wl_registry *registry;
wl_compositor *compositor; wl_compositor* compositor;
wl_surface *wlSurface; wl_surface* surface;
xdg_wm_base *xdgShell; xdg_wm_base *xdgShell;
xdg_surface *xdgSurface; xdg_surface *xdgSurface;
xdg_toplevel *xdgToplevel; xdg_toplevel *xdgToplevel;
zxdg_decoration_manager_v1 *decManager;
zxdg_toplevel_decoration_v1 *dec;
wl_seat *seat;
wl_pointer *pointer;
Vec2_u32 scale;
static void SurfaceConfigEvent(void *data, xdg_surface *xdg_surface, UInt_32 serial); static void SurfaceConfigure(void *data, xdg_surface *xdg_surface, UInt_32 serial);
static void ShellPing(void *data, xdg_wm_base *shell, UInt_32 serial); static void ShellPing(void *data, xdg_wm_base *shell, UInt_32 serial);
@ -32,32 +26,16 @@ namespace ehs
static void RegistryRemoved(void *data, wl_registry *registry, UInt_32 id); static void RegistryRemoved(void *data, wl_registry *registry, UInt_32 id);
static void ResizeEvent(void *data, xdg_toplevel *xdg_toplevel, Int_32 width, Int_32 height, wl_array *states);
static void CloseEvent(void *data, xdg_toplevel *xdg_toplevel);
static void SeatCapabilitiesEvent(void *data, wl_seat *seat, UInt_32 capabilities);
static void PointerMotionEvent(void *data, wl_pointer *pointer, UInt_32 time, wl_fixed_t sx, wl_fixed_t sy);
public: public:
~Window() override; ~Window() override;
Window(); Window();
Window(Window &&win) noexcept; void Create_32(const Str_32& title, const Vec2_s32& pos, const Vec2_u32 scale) override;
Window(const Window &win); void Create_16(const Str_16& title, const Vec2_s32& pos, const Vec2_u32 scale) override;
Window &operator=(Window &&win) noexcept; void Create_8(const Str_8& title, const Vec2_s32& pos, const Vec2_u32 scale) override;
Window &operator=(const Window &win);
void Create_32(const Str_32& title, const Vec2_s32& pos, Vec2_u32 scale) override;
void Create_16(const Str_16& title, const Vec2_s32& pos, Vec2_u32 scale) override;
void Create_8(const Str_8& title, const Vec2_s32& pos, Vec2_u32 scale) override;
void OnCreated() override; void OnCreated() override;

View File

@ -8,7 +8,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Window : public BaseWindow class Window : public BaseWindow
{ {
protected: protected:
friend class Input; friend class Input;

View File

@ -11,7 +11,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Audio : public Resource class Audio : public Resource
{ {
private: private:
static Array<AudioCodec> codecs; static Array<AudioCodec> codecs;
@ -39,9 +39,7 @@ namespace ehs
Audio(); Audio();
Audio(const Str_8& filePath); Audio(Str_8 id);
Audio(const Str_8& filePath, DataType type);
Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, UInt_64 frames, const Byte* data); Audio(Str_8 id, UInt_64 sampleRate, DataType dataType, UInt_8 channels, UInt_64 frames, const Byte* data);
@ -81,14 +79,10 @@ namespace ehs
UInt_64 GetSampleCount() const; UInt_64 GetSampleCount() const;
UInt_8 GetFrameSize() const;
UInt_64 GetSize() const; UInt_64 GetSize() const;
float GetLength() const; float GetLength() const;
Byte* GetFrame(UInt_64 frameIndex) const;
Array<Byte> FrameAsMono(UInt_64 frameIndex) const; Array<Byte> FrameAsMono(UInt_64 frameIndex) const;
Array<Byte> FrameAsStereo(UInt_64 frameIndex) const; Array<Byte> FrameAsStereo(UInt_64 frameIndex) const;
@ -129,7 +123,17 @@ namespace ehs
Audio GetAsChannels(UInt_8 newChannels) const; Audio GetAsChannels(UInt_8 newChannels) const;
bool Export(const Str_8& filePath) const; bool ToFile(const Str_8& filePath) const;
static Audio FromFile(const Str_8& filePath);
static Audio* FromFile_Heap(const Str_8& filePath);
static Audio FromFile(const Str_8& filePath, DataType required);
static Audio* FromFile_Heap(const Str_8& filePath, DataType required);
static Audio FromData(Str_8 id, const Str_8& ext, Serializer<UInt_64>& data);
private: private:
void ToMono(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const; void ToMono(UInt_64 newFrameCount, Byte* newData, UInt_64 frameOffset) const;
@ -197,10 +201,4 @@ namespace ehs
void SInt_32_to_SInt_64(Byte* newData, Byte* newPeak) const; void SInt_32_to_SInt_64(Byte* newData, Byte* newPeak) const;
}; };
bool EncodeEHA(const ehs::AudioCodec* codec, ehs::Serializer<ehs::UInt_64>& out, const ehs::Audio* in);
bool DecodeEHA(const ehs::AudioCodec* codec, ehs::Serializer<ehs::UInt_64>& in, ehs::Audio* out);
bool DecodeWAV(const ehs::AudioCodec* codec, ehs::Serializer<ehs::UInt_64>& in, ehs::Audio* out);
} }

View File

@ -8,7 +8,7 @@ namespace ehs
{ {
class Audio; class Audio;
class EHS_LIB_IO AudioCodec class AudioCodec
{ {
private: private:
Str_8 id; Str_8 id;

View File

@ -5,5 +5,5 @@
#if defined(EHS_OS_WINDOWS) #if defined(EHS_OS_WINDOWS)
#include "AudioDevice_W32.h" #include "AudioDevice_W32.h"
#elif defined(EHS_OS_LINUX) #elif defined(EHS_OS_LINUX)
#include "AudioDevice_PW.h" #include "AudioDevice_ALSA.h"
#endif #endif

View File

@ -0,0 +1,46 @@
#pragma once
#include "ehs/EHS.h"
#include "BaseAudioDevice.h"
#include <alsa/asoundlib.h>
namespace ehs
{
class AudioDevice : public BaseAudioDevice
{
private:
snd_pcm_t* hdl;
public:
~AudioDevice() override;
AudioDevice();
AudioDevice(AudioDevice&& device) noexcept;
AudioDevice(const AudioDevice& device);
AudioDevice& operator=(AudioDevice&& device) noexcept;
AudioDevice& operator=(const AudioDevice& device);
void Release() override;
void OpenStream() override;
void CloseStream() override;
UInt_64 GetAvailFrames() const override;
Byte* Map(UInt_64* offset, UInt_64* frames) override;
void UnMap(const UInt_64 offset, const UInt_64 frames) override;
bool IsValid() const override;
static AudioDevice GetDefault(const AudioDeviceType type);
static Array<AudioDevice> Get(const AudioDeviceType type, const AudioDeviceState state);
};
}

View File

@ -1,67 +0,0 @@
#pragma once
#include "ehs/EHS.h"
#include "BaseAudioDevice.h"
#include <pipewire/pipewire.h>
#include <pipewire/loop.h>
#include <pipewire/context.h>
#include <pipewire/stream.h>
#include <spa/param/audio/format-utils.h>
namespace ehs
{
class EHS_LIB_IO AudioDevice final : public BaseAudioDevice
{
private:
static Array<AudioDevice> devices;
static AudioDevice defOut;
static AudioDevice defIn;
UInt_32 id;
Str_8 name;
pw_loop *loop;
pw_context *context;
pw_core *core;
pw_stream *input;
pw_stream *output;
static void RegistryEventGlobal(void *data, UInt_32 id, UInt_32 permissions, const char *type, UInt_32 version, const spa_dict *props);
static void RegistryEventGlobalRemove(void *data, UInt_32 id);
static void OnParamChanged(void *data, UInt_32 id, const spa_pod *param);
public:
~AudioDevice() override;
AudioDevice();
AudioDevice(AudioDevice&& device) noexcept;
AudioDevice(const AudioDevice& device);
AudioDevice& operator=(AudioDevice&& device) noexcept;
AudioDevice& operator=(const AudioDevice& device);
void OpenStream() override;
void CloseStream() override;
UInt_64 SendStream(const void *data, UInt_64 size) override;
UInt_64 ReceiveStream(void *data, UInt_64 size) override;
bool IsStreaming() const override;
bool IsValid() const override;
static AudioDevice GetDefault(AudioDeviceType type);
static Array<AudioDevice> Get(AudioDeviceType type, AudioDeviceState state);
private:
Str_8 GetCategory() const;
};
}

View File

@ -12,7 +12,7 @@ struct IMMDevice;
namespace ehs namespace ehs
{ {
class EHS_LIB_IO AudioDevice final : public BaseAudioDevice class AudioDevice : public BaseAudioDevice
{ {
private: private:
IMMDevice* hdl; IMMDevice* hdl;
@ -33,13 +33,17 @@ namespace ehs
AudioDevice& operator=(const AudioDevice& device); AudioDevice& operator=(const AudioDevice& device);
void Release() override;
void OpenStream() override; void OpenStream() override;
void CloseStream() override; void CloseStream() override;
UInt_64 SendStream(const void *data, UInt_64 outFrameSize) override; UInt_64 GetAvailFrames() const override;
UInt_64 ReceiveStream(void *data, UInt_64 inFrameSize) override; Byte* Map(UInt_64* offset, UInt_64* frames) override;
void UnMap(const UInt_64 offset, const UInt_64 frames) override;
Str_32 GetInterfaceName_32() const; Str_32 GetInterfaceName_32() const;
@ -53,12 +57,10 @@ namespace ehs
Str_8 GetName_8() const; Str_8 GetName_8() const;
bool IsStreaming() const override;
bool IsValid() const override; bool IsValid() const override;
static AudioDevice GetDefault(AudioDeviceType type); static AudioDevice GetDefault(const AudioDeviceType type);
static Array<AudioDevice> Get(AudioDeviceType type, AudioDeviceState state); static Array<AudioDevice> Get(const AudioDeviceType type, const AudioDeviceState state);
}; };
} }

View File

@ -10,8 +10,8 @@ namespace ehs
{ {
enum class AudioDeviceType enum class AudioDeviceType
{ {
INPUT = 0x1,
OUTPUT = 0x0, OUTPUT = 0x0,
INPUT = 0x1,
ALL = 0x2 ALL = 0x2
}; };
@ -23,17 +23,18 @@ namespace ehs
UNPLUGGED = 0x8 UNPLUGGED = 0x8
}; };
class EHS_LIB_IO BaseAudioDevice class BaseAudioDevice
{ {
protected: protected:
AudioDeviceType type; AudioDeviceType type;
DataType dataType; DataType dataType;
UInt_16 byteDepth; UInt_16 bitDepth;
UInt_32 sampleRate; UInt_32 sampleRate;
UInt_32 channels; UInt_32 channels;
UInt_32 period; UInt_32 period;
UInt_32 latency; UInt_32 latency;
UInt_64 maxFrames; UInt_64 maxFrames;
bool streaming;
public: public:
virtual ~BaseAudioDevice() = default; virtual ~BaseAudioDevice() = default;
@ -44,21 +45,21 @@ namespace ehs
BaseAudioDevice& operator=(const BaseAudioDevice& device); BaseAudioDevice& operator=(const BaseAudioDevice& device);
virtual void Release();
virtual void OpenStream(); virtual void OpenStream();
virtual void CloseStream(); virtual void CloseStream();
virtual UInt_64 SendStream(const void *data, UInt_64 size); virtual UInt_64 GetAvailFrames() const;
virtual UInt_64 ReceiveStream(void *data, UInt_64 size); virtual Byte* Map(UInt_64* offset, UInt_64* frames);
void BridgeStreams(BaseAudioDevice *input, UInt_64 frameBufferSize); virtual void UnMap(const UInt_64 offset, const UInt_64 frames);
void BridgeStreams(UInt_64 frameBufferSize);
AudioDeviceType GetType() const; AudioDeviceType GetType() const;
void SetDataType(DataType newDataType); void SetDataType(const DataType newDataType);
DataType GetDataType() const; DataType GetDataType() const;
@ -66,39 +67,39 @@ namespace ehs
UInt_16 GetBitDepth() const; UInt_16 GetBitDepth() const;
void SetSampleRate(UInt_32 newSampleRate); void SetSampleRate(const UInt_32 newSampleRate);
UInt_32 GetSampleRate() const; UInt_32 GetSampleRate() const;
void SetChannels(UInt_32 newChannels); void SetChannels(const UInt_32 newChannels);
UInt_16 GetChannels() const; UInt_16 GetChannels() const;
UInt_32 GetFrameSize() const; UInt_32 GetFrameSize() const;
void SetPeriod(UInt_32 newPeriod); void SetPeriod(const UInt_32 newPeriod);
UInt_32 GetPeriod() const; UInt_32 GetPeriod() const;
void SetLatency(UInt_32 newLatency); void SetLatency(const UInt_32 newLatency);
UInt_32 GetLatency() const; UInt_32 GetLatency() const;
UInt_64 GetMaxFrames() const; UInt_64 GetMaxFrames() const;
virtual bool IsStreaming() const; bool IsStreaming() const;
virtual bool IsValid() const; virtual bool IsValid() const;
/// Retrieves the default audio input/output device. /// Retrieves the default audio input/output device.
/// @param [in] type The audio device type to retrieve. /// @param [in] type The audio device type to retrieve.
/// @param [out] device The default audio device. /// @param [out] device The default audio device.
static BaseAudioDevice GetDefault(AudioDeviceType type); static BaseAudioDevice GetDefault(const AudioDeviceType type);
/// Retrieves a list of audio input/output devices. /// Retrieves a list of audio input/output devices.
/// @param [in] type The audio device type to retrieve. /// @param [in] type The audio device type to retrieve.
/// @param [in] state The audio device state to retrieve. /// @param [in] state The audio device state to retrieve.
/// @param [out] devices The list of audio devices. /// @param [out] devices The list of audio devices.
static Array<BaseAudioDevice> Get(AudioDeviceType type, AudioDeviceState state); static Array<BaseAudioDevice> Get(const AudioDeviceType type, const AudioDeviceState state);
}; };
} }

View File

@ -5,33 +5,27 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Button class Button
{ {
private: private:
UInt_32 hash;
Str_8 name; Str_8 name;
UInt_32 hash;
public: public:
Button(); Button();
Button(Str_8 name); Button(const Str_8& name);
Button(Button &&key) noexcept; Button(const Button& key);
Button(const Button &key); Button& operator=(const Button& key);
Button &operator=(Button &&key) noexcept; bool operator==(const Button& key) const;
Button &operator=(const Button &key); bool operator!=(const Button& key) const;
bool operator==(const Button &key) const;
bool operator!=(const Button &key) const;
UInt_32 GetHash() const;
Str_8 GetName() const; Str_8 GetName() const;
bool IsValid() const; UInt_32 GetHash() const;
}; };
} }

View File

@ -13,7 +13,7 @@ namespace ehs
TOUCHED TOUCHED
}; };
class EHS_LIB_IO ButtonState class ButtonState
{ {
private: private:
Button button; Button button;

View File

@ -7,7 +7,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO HID class HID
{ {
protected: protected:
UInt_8 type; UInt_8 type;
@ -15,15 +15,11 @@ namespace ehs
Str_8 name; Str_8 name;
UInt_64 id; UInt_64 id;
Array<ButtonState> states; Array<ButtonState> states;
Button lastState;
float heldTime;
float activateTime;
bool active;
public: public:
HID(); HID();
HID(UInt_8 type, Str_8 name, UInt_64 id); HID(const UInt_8 type, Str_8 name, const UInt_64 id);
HID(HID&& hid) noexcept; HID(HID&& hid) noexcept;
@ -37,11 +33,11 @@ namespace ehs
bool operator!=(const HID& other) const; bool operator!=(const HID& other) const;
bool operator==(UInt_64 otherId) const; bool operator==(const UInt_64 otherId) const;
bool operator!=(UInt_64 otherId) const; bool operator!=(const UInt_64 otherId) const;
virtual void Poll(float delta); virtual void Poll();
UInt_8 GetType() const; UInt_8 GetType() const;
@ -75,10 +71,6 @@ namespace ehs
const ButtonState* IsUp() const; const ButtonState* IsUp() const;
const ButtonState *IsPressed(const Button &button);
const ButtonState *GetPressed();
void ButtonDown(const Button& button); void ButtonDown(const Button& button);
void ButtonUp(const Button& button); void ButtonUp(const Button& button);
@ -95,11 +87,5 @@ namespace ehs
bool AddState(const ButtonState& state); bool AddState(const ButtonState& state);
ButtonState* GetState(const Button& button); ButtonState* GetState(const Button& button);
bool TickHoldTime(float delta);
void ResetTime();
void TickActivateTime(float delta);
}; };
} }

View File

@ -6,7 +6,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Input class Input
{ {
private: private:
Array<InputHandler*> handlers; Array<InputHandler*> handlers;

View File

@ -5,13 +5,11 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO InputHandler class InputHandler
{ {
private: private:
UInt_64 hashId; UInt_64 hashId;
Str_8 id; Str_8 id;
UInt_64 start;
UInt_64 delta;
protected: protected:
Array<HID*> devices; Array<HID*> devices;
@ -31,9 +29,9 @@ namespace ehs
InputHandler& operator=(const InputHandler& ih); InputHandler& operator=(const InputHandler& ih);
bool operator==(const UInt_64 otherHashId) const; bool operator==(const UInt_64 otherHashId);
bool operator!=(const UInt_64 otherHashId) const; bool operator!=(const UInt_64 otherHashId);
virtual bool Initialize(); virtual bool Initialize();

View File

@ -8,7 +8,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Keyboard : public HID class Keyboard : public HID
{ {
public: public:
Keyboard(); Keyboard();
@ -23,7 +23,7 @@ namespace ehs
Keyboard& operator=(const Keyboard& hid); Keyboard& operator=(const Keyboard& hid);
void Poll(float delta) override; void Poll() override;
Keyboard* Clone() const override; Keyboard* Clone() const override;

View File

@ -9,7 +9,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Mouse : public HID class Mouse : public HID
{ {
private: private:
friend class Input; friend class Input;
@ -19,7 +19,7 @@ namespace ehs
public: public:
Mouse(); Mouse();
Mouse(Str_8 name, UInt_64 id); Mouse(Str_8 name, const UInt_64 id);
Mouse(Mouse&& hid) noexcept = default; Mouse(Mouse&& hid) noexcept = default;
@ -29,7 +29,7 @@ namespace ehs
Mouse& operator=(const Mouse& hid); Mouse& operator=(const Mouse& hid);
void Poll(float delta) override; void Poll() override;
void SetDelta(const Vec2_s32& newDelta); void SetDelta(const Vec2_s32& newDelta);

View File

@ -13,7 +13,7 @@ namespace ehs
NEAREST_NEIGHBOR NEAREST_NEIGHBOR
}; };
class EHS_LIB_IO Img : public BaseObj class Img : public BaseObj
{ {
private: private:
static Array<ImgCodec> codecs; static Array<ImgCodec> codecs;
@ -42,7 +42,7 @@ namespace ehs
Img(); Img();
Img(const Str_8& filePath); Img(Str_8 id);
Img(Str_8 id, UInt_8 byteDepth, UInt_8 channels, const Vec2_u64& resolution, const Byte* data); Img(Str_8 id, UInt_8 byteDepth, UInt_8 channels, const Vec2_u64& resolution, const Byte* data);
@ -124,7 +124,13 @@ namespace ehs
bool IsValid() const; bool IsValid() const;
bool Export(const Str_8& filePath) const; bool ToFile(const Str_8& filePath) const;
static Img FromFile(const Str_8& filePath);
static Img* FromFile_Heap(const Str_8& filePath);
static Img FromData(Str_8 id, const Str_8& ext, Serializer<UInt_64>& data);
private: private:
Img GetNearestNeighbor(const Vec2_u64& newResolution) const; Img GetNearestNeighbor(const Vec2_u64& newResolution) const;
@ -179,10 +185,4 @@ namespace ehs
void BD16_to_BD8(UInt_64 newSize, Byte* buffer) const; void BD16_to_BD8(UInt_64 newSize, Byte* buffer) const;
}; };
bool EncodeQOI(const ehs::ImgCodec* codec, ehs::Serializer<ehs::UInt_64>& out, const ehs::Img* in);
bool DecodeQOI(const ehs::ImgCodec* codec, ehs::Serializer<ehs::UInt_64>& in, ehs::Img* out);
bool DecodePNG(const ehs::ImgCodec* codec, ehs::Serializer<ehs::UInt_64>& in, ehs::Img* out);
} }

View File

@ -7,25 +7,23 @@
namespace ehs namespace ehs
{ {
class Img; class Img;
class ImgCodec;
typedef bool (*EncodeImgCb)(const ImgCodec* const, Serializer<UInt_64>&, const Img*); class ImgCodec
typedef bool (*DecodeImgCb)(const ImgCodec* const, Serializer<UInt_64>&, Img*);
class EHS_LIB_IO ImgCodec
{ {
private: private:
Str_8 id; Str_8 id;
UInt_64 hashExt; UInt_64 hashExt;
Str_8 ext; Str_8 ext;
Endianness endianness; Endianness endianness;
EncodeImgCb encoder; bool (*encodeCb)(const ImgCodec* const, Serializer<UInt_64>&, const Img*);
DecodeImgCb decoder; bool (*decodeCb)(const ImgCodec* const, Serializer<UInt_64>&, Img*);
public: public:
ImgCodec(); ImgCodec();
ImgCodec(Str_8 id, Str_8 ext, Endianness end, EncodeImgCb encoder, DecodeImgCb decoder); ImgCodec(Str_8 id, Str_8 ext, const Endianness end,
bool (*encodeCb)(const ImgCodec* const, Serializer<UInt_64>&, const Img*),
bool (*decodeCb)(const ImgCodec* const, Serializer<UInt_64>&, Img*));
ImgCodec(ImgCodec&& codec) noexcept; ImgCodec(ImgCodec&& codec) noexcept;

View File

@ -7,7 +7,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO PNG class PNG
{ {
private: private:
Str_8 id; Str_8 id;

View File

@ -6,7 +6,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO PNG_Chunk class PNG_Chunk
{ {
private: private:
Str_8 id; Str_8 id;

View File

@ -1,93 +0,0 @@
#pragma once
#include "ehs/EHS.h"
#include "ehs/Array.h"
#include "ehs/io/File.h"
#include "MdlCodec.h"
#include "Mesh.h"
#include "Bone.h"
#include "Animation.h"
namespace ehs
{
enum class ModelEncoding : UInt_8
{
EHM
};
class EHS_LIB_IO Mdl : public BaseObj
{
private:
static Array<MdlCodec> codecs;
protected:
UInt_64 hashId;
Str_8 id;
Array<Mesh> meshes;
Bone skeleton;
Array<Animation> animations;
public:
static bool HasCodec(UInt_64 hashExt);
static bool HasCodec(const Str_8& ext);
static bool AddCodec(MdlCodec codec);
static const MdlCodec* GetCodec(UInt_64 hashExt);
static const MdlCodec* GetCodec(const Str_8& ext);
Mdl();
Mdl(const Str_8& filePath);
Mdl(Str_8 id, Array<Mesh> meshes, Bone skeleton, Array<Animation> animations);
Mdl(Str_8 id, Array<Mesh> meshes, Bone skeleton);
Mdl(Str_8 id, Array<Mesh> meshes);
Mdl(Mdl&& model) noexcept;
Mdl(const Mdl& model) = default;
Mdl& operator=(Mdl&& model) noexcept;
Mdl& operator=(const Mdl& model) = default;
void Release();
UInt_64 GetHashId() const;
void SetId(Str_8 newId);
Str_8 GetId() const;
const Array<Mesh>& GetMeshes() const;
Array<Mesh>& GetMeshes();
Mesh* GetMesh(UInt_64 inHashId);
Mesh* GetMesh(const Str_8& inId);
const Bone& GetSkeleton() const;
Bone& GetSkeleton();
Animation* GetAnimation(UInt_64 inHashId);
const Array<Animation>& GetAnimations() const;
Array<Animation>& GetAnimations();
void Calculate();
bool Export(const Str_8& filePath) const;
};
bool EncodeEHM(const MdlCodec* codec, Serializer<UInt_64>& data, const Mdl* mdl);
bool DecodeEHM(const MdlCodec* codec, Serializer<UInt_64>& data, Mdl* mdl);
}

View File

@ -1,50 +0,0 @@
#pragma once
#include "ehs/Str.h"
#include "ehs/Serializer.h"
#include "ehs/system/CPU.h"
namespace ehs
{
class Mdl;
class MdlCodec;
typedef bool (*EnocdeMdlCb)(const MdlCodec*, Serializer<UInt_64>&, const Mdl*);
typedef bool (*DecodeMdlCb)(const MdlCodec*, Serializer<UInt_64>&, Mdl*);
class EHS_LIB_IO MdlCodec
{
private:
Str_8 id;
UInt_64 hashExt;
Str_8 ext;
Endianness endianness;
EnocdeMdlCb encoder;
DecodeMdlCb decoder;
public:
MdlCodec();
MdlCodec(Str_8 id, Str_8 ext, Endianness end, EnocdeMdlCb encoder, DecodeMdlCb decoder);
MdlCodec(MdlCodec&& codec) noexcept;
MdlCodec(const MdlCodec& codec);
MdlCodec& operator=(MdlCodec&& codec) noexcept;
MdlCodec& operator=(const MdlCodec& codec);
Str_8 GetId() const;
UInt_64 GetHashExt() const;
Str_8 GetExt() const;
Endianness GetEndianness() const;
bool Encode(Serializer<UInt_64>& out, const Mdl* in) const;
bool Decode(Serializer<UInt_64>& in, Mdl* out) const;
};
}

View File

@ -6,7 +6,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO AnimBone class AnimBone
{ {
private: private:
UInt_8 boneId; UInt_8 boneId;

View File

@ -7,7 +7,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Animation class Animation
{ {
private: private:
UInt_64 hashId; UInt_64 hashId;

View File

@ -6,7 +6,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Bone class Bone
{ {
private: private:
UInt_64 hashName; UInt_64 hashName;

View File

@ -9,7 +9,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO KeyFrame class KeyFrame
{ {
private: private:
float num; float num;

View File

@ -7,7 +7,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Mesh final : public BaseObj class Mesh final : public BaseObj
{ {
protected: protected:
UInt_64 hashId; UInt_64 hashId;

View File

@ -0,0 +1,80 @@
#pragma once
#include "ehs/EHS.h"
#include "ehs/Array.h"
#include "ehs/io/File.h"
#include "Mesh.h"
#include "Bone.h"
#include "Animation.h"
namespace ehs
{
enum class ModelEncoding : UInt_8
{
EHM
};
class Model : public BaseObj
{
protected:
UInt_64 hashId;
Str_8 id;
Array<Mesh> meshes;
Bone skeleton;
Array<Animation> animations;
public:
Model();
Model(const Str_8& filePath);
Model(Str_8 id, Array<Mesh> meshes, Bone skeleton, Array<Animation> animations);
Model(Str_8 id, Array<Mesh> meshes, Bone skeleton);
Model(Str_8 id, Array<Mesh> meshes);
Model(Model&& model) noexcept;
Model(const Model& model) = default;
Model& operator=(Model&& model) noexcept;
Model& operator=(const Model& model) = default;
void Release();
UInt_64 GetHashId() const;
void SetId(Str_8 newId);
Str_8 GetId() const;
const Array<Mesh>& GetMeshes() const;
Array<Mesh>& GetMeshes();
Mesh* GetMesh(UInt_64 inHashId);
Mesh* GetMesh(const Str_8& inId);
const Bone& GetSkeleton() const;
Bone& GetSkeleton();
Animation* GetAnimation(UInt_64 inHashId);
const Array<Animation>& GetAnimations() const;
Array<Animation>& GetAnimations();
void Calculate();
void Export(const Str_8& filePath, ModelEncoding encoding);
private:
void ToEHM(File& file);
void FromEHM(File& file);
};
}

View File

@ -19,7 +19,7 @@ namespace ehs
INVALID INVALID
}; };
class EHS_LIB_IO PropertyChange class PropertyChange
{ {
public: public:
ChangeType type; ChangeType type;

View File

@ -1,18 +0,0 @@
#pragma once
#include "Socket.h"
#include "ehs/Str.h"
namespace ehs
{
class EHS_LIB_IO BaseDNS
{
public:
static Str_8 Resolve(AddrType type, const Str_8 &hostname);
/// Resolves a hostname to an ip address.
/// @param [in] hostname The given hostname to resolve.
/// @returns The resulting ip address.
static Str_8 Resolve(const Str_8 &hostname);
};
}

View File

@ -9,7 +9,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO BaseTCP class BaseTCP
{ {
protected: protected:
AddrType addrType; AddrType addrType;
@ -146,10 +146,6 @@ namespace ehs
/// @returns The result. /// @returns The result.
virtual bool IsBlocking() const = 0; virtual bool IsBlocking() const = 0;
virtual void SetIPv6Only(bool value) = 0;
virtual bool IsIPv6Only() const = 0;
/// Retrieves whether or not this socket was initialized. /// Retrieves whether or not this socket was initialized.
/// @returns The result. /// @returns The result.
virtual bool IsValid() const = 0; virtual bool IsValid() const = 0;

View File

@ -6,7 +6,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO BaseUDP class BaseUDP
{ {
protected: protected:
AddrType type; AddrType type;
@ -69,10 +69,6 @@ namespace ehs
/// @returns The result. /// @returns The result.
virtual bool IsBlocking() const = 0; virtual bool IsBlocking() const = 0;
virtual void SetIPv6Only(bool value) = 0;
virtual bool IsIPv6Only() const = 0;
/// Retrieves the bound ip version. /// Retrieves the bound ip version.
/// @returns The result. /// @returns The result.
AddrType GetLocalAddressType() const; AddrType GetLocalAddressType() const;

View File

@ -1,9 +1,17 @@
#pragma once #pragma once
#include "ehs/system/OS.h" #include "ehs/EHS.h"
#include "ehs/Str.h"
#include "Socket.h"
#if defined(EHS_OS_WINDOWS) namespace ehs
#include "DNS_W32.h" {
#elif defined(EHS_OS_LINUX) class DNS
#include "DNS_LNX.h" {
#endif public:
/// Resolves a hostname to an ip address.
/// @param [in] hostname The given hostname to resolve.
/// @returns The resulting ip address.
static Str_8 Resolve(const Str_8& hostname);
};
}

View File

@ -1,17 +0,0 @@
#pragma once
#include "BaseDNS.h"
#include "ehs/EHS.h"
#include "ehs/Str.h"
#include "Socket.h"
namespace ehs
{
class EHS_LIB_IO DNS final : public BaseDNS
{
public:
static Str_8 Resolve(AddrType type, const Str_8 &hostname);
static Str_8 Resolve(const Str_8 &hostname);
};
}

View File

@ -1,14 +0,0 @@
#pragma once
#include "BaseDNS.h"
namespace ehs
{
class EHS_LIB_IO DNS final : public BaseDNS
{
public:
static Str_8 Resolve(AddrType type, const Str_8 &hostname);
static Str_8 Resolve(const Str_8 &hostname);
};
}

View File

@ -1,228 +0,0 @@
#pragma once
#include "ehs/io/socket/ehc/NetUtils.h"
#include "ehs/io/socket/ehc/NetEnc.h"
#include "ehs/Serializer.h"
#include "ehs/Vector.h"
#include "ehs/Array.h"
#include "Socket.h"
#include "UDP.h"
namespace ehs
{
class NetSys;
class NetEnd;
class EHC;
typedef bool (*ConnectCb)(EHC *, NetEnd **, Serializer<UInt_64>);
typedef void (*ConnectedCb)(EHC *, NetEnd *);
typedef void (*ActiveCb)(EHC *, NetEnd *);
typedef void (*DisconnectCb)(EHC *, NetEnd *, Serializer<UInt_64>);
typedef void (*DisconnectedCb)(EHC *, NetEnd *);
typedef void (*TimeoutCb)(EHC *, NetEnd *);
class EHC
{
private:
friend class NetEnc;
friend class NetEnd;
static const Version version;
static const UInt_64 internalSys;
static const UInt_64 connectOp;
static const UInt_64 connectedOp;
static const UInt_64 rejectedOp;
static const UInt_64 disconnectOp;
static const UInt_64 disconnectedOp;
static const UInt_64 statusUpdateOp;
static const UInt_64 pingOp;
static const UInt_64 pongOp;
static const UInt_64 latencyOp;
static const UInt_64 receivedOp;
UDP udp;
Version appVer;
EndDisp disposition;
UInt_64 hashName;
Str_8 name;
bool dropPackets;
Byte* buffer;
UInt_32 bufferSize;
Array<NetEnc *> encryptions;
Array<NetSys *> systems;
UInt_32 maxEndpoints;
UInt_64 lastTSC;
float delta;
float maxTimeout;
float resendRate;
ConnectCb connectCb;
ConnectedCb connectedCb;
ActiveCb activeCb;
DisconnectCb disconnectCb;
DisconnectedCb disconnectedCb;
TimeoutCb timeoutCb;
protected:
Vector<NetEnd*> endpoints;
public:
~EHC();
EHC();
EHC(const Version &ver, Str_8 name, UInt_64 maxEndpoints);
EHC(const Version &ver, Str_8 name);
EHC(EHC &&sock) noexcept;
EHC(const EHC &sock);
EHC &operator=(EHC&& sock) noexcept;
EHC &operator=(const EHC &sock);
void Initialize();
void Release();
void Bind(AddrType newType, const Str_8& newAddress, UInt_16 newPort);
void Connect(AddrType rType, const Str_8& rAddress, UInt_16 rPort, Serializer<UInt_64> data);
bool Disconnect(EndDisp endDisp, const Char_8 token[64], const Str_8& msg);
void Broadcast(EndDisp endDisp, Status endStatus, bool deltaLocked, UInt_64 encHashId,
bool ensure, UInt_64 sysHashId, UInt_64 opHashId,
const Serializer<UInt_64> &payload);
void Broadcast(EndDisp endDisp, Status endStatus, bool deltaLocked, const Str_8 &encId,
bool ensure, const Str_8 &sysId, const Str_8 &opId,
const Serializer<UInt_64> &payload);
void Poll();
bool IsInitialized() const;
AddrType GetLocalAddressType() const;
Str_8 GetLocalAddress() const;
UInt_16 GetLocalPort() const;
bool IsBound() const;
static Version GetVersion();
Version GetAppVersion() const;
EndDisp GetDisposition() const;
UInt_64 GetHashName() const;
Str_8 GetName() const;
void EnableDropPackets(bool enable);
bool IsDropPacketsEnabled() const;
bool HasEncryption(UInt_64 encHashId) const;
bool HasEncryption(const Str_8& encId) const;
bool AddEncryption(NetEnc *enc);
NetEnc* GetEncryption(UInt_64 encHashId) const;
NetEnc* GetEncryption(const Str_8& encId) const;
bool HasSystem(UInt_64 sysHashId) const;
bool HasSystem(const Str_8& sysId) const;
bool AddSystem(NetSys *sys);
NetSys* GetSystem(UInt_64 sysHashId) const;
NetSys* GetSystem(const Str_8& sysId) const;
bool HasEndpoint(EndDisp endDisp, Status endStatus, const Char_8 token[64]) const;
bool HasEndpoint(EndDisp endDisp, Status endStatus, UInt_64 hashId) const;
bool HasEndpoint(EndDisp endDisp, Status endStatus, const Str_8 &id) const;
bool HasEndpoint(EndDisp endDisp, const Char_8 token[64]) const;
bool HasEndpoint(EndDisp endDisp, UInt_64 hashId) const;
bool HasEndpoint(EndDisp endDisp, const Str_8 &id) const;
bool HasEndpoint(const Char_8 token[64]) const;
bool HasEndpoint(UInt_64 hashId) const;
bool HasEndpoint(const Str_8 &id) const;
bool HasEndpoint(const Str_8& rAddress, UInt_16 rPort) const;
NetEnd *GetEndpoint(EndDisp endDisp, Status endStatus, const Char_8 token[64]) const;
NetEnd *GetEndpoint(EndDisp endDisp, Status endStatus, UInt_64 hashId) const;
NetEnd *GetEndpoint(EndDisp endDisp, Status endStatus, const Str_8 &id) const;
NetEnd *GetEndpoint(EndDisp endDisp, const Char_8 token[64]) const;
NetEnd *GetEndpoint(EndDisp endDisp, UInt_64 hashId) const;
NetEnd *GetEndpoint(EndDisp endDisp, const Str_8 &id) const;
NetEnd *GetEndpoint(const Str_8& rAddress, UInt_16 rPort) const;
Array<NetEnd *> GetEndpoints(EndDisp endDisp, Status endStatus);
Array<NetEnd *> GetEndpoints(EndDisp endDisp);
UInt_64 GetEndpointsCount(EndDisp endDisp, Status endStatus);
UInt_64 GetEndpointsCount(EndDisp endDisp);
UInt_64 GetMaxEndpoints() const;
void SetMaxTimeout(float seconds);
float GetMaxTimeout() const;
void SetResendRate(float seconds);
float GetResendRate() const;
void SetConnectCb(ConnectCb cb);
void SetConnectedCb(ConnectedCb cb);
void SetActiveCb(ActiveCb cb);
void SetDisconnectCb(DisconnectCb cb);
void SetDisconnectedCb(DisconnectedCb cb);
void SetTimeoutCb(TimeoutCb cb);
private:
void GenerateToken(Char_8 in[64]);
void UpdateQueue(UInt_64 active);
void UpdateQueue();
bool RemoveEndpoint(EndDisp disposition, const Char_8 token[64]);
bool RemoveEndpoint(const Str_8& address, UInt_16 port);
bool RemoveEndpoint(const NetEnd* end);
void PollEndpoints();
};
}

View File

@ -16,7 +16,7 @@ namespace ehs
DEL DEL
}; };
class EHS_LIB_IO Request class Request
{ {
private: private:
Verb verb; Verb verb;

View File

@ -8,7 +8,7 @@
namespace ehs namespace ehs
{ {
class EHS_LIB_IO Response class Response
{ {
private: private:
UInt_32 code; UInt_32 code;

Some files were not shown because too many files have changed in this diff Show More