100 Commits

Author SHA1 Message Date
d60d4c27ab Fixed Button dll input/output. 2025-10-09 07:43:03 -07:00
7db8486f1e Fixed Button dll input/output. 2025-08-13 21:31:57 -07:00
46184df89c Fixed the logger. 2025-07-27 23:50:13 -07:00
73f7ec1a8d Optimized Request and Response classes. 2025-06-01 22:16:32 -07:00
135f855309 Merge remote-tracking branch 'origin/NetChannels' into NetChannels
# Conflicts:
#	src/io/socket/SSL.cpp
2025-05-22 23:56:22 -07:00
159428ea76 Backup. 2025-05-22 23:56:00 -07:00
c23cbc275f Backup. 2025-05-22 17:34:09 -07:00
fbd8464043 Fixed SSL and TCP Bind. 2025-05-22 07:05:11 -07:00
f52afe9c92 Fixed audio destruction and construction. 2025-05-18 23:40:09 -07:00
61fb586f86 Added frequency counter to AARCH64.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Has been cancelled
Build & Release / Linux-AARCH64-Build (push) Has been cancelled
Build & Release / Windows-AMD64-Build (push) Has been cancelled
2025-05-17 17:37:12 -07:00
c19c6269aa Fixed CI/CD for Raspberry Pi.
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 4m17s
Build & Release / Linux-AMD64-Build (push) Successful in 7m12s
Build & Release / Linux-AARCH64-Build (push) Successful in 20m56s
2025-05-16 21:44:24 -07:00
0b1a0c9689 Fixed CI/CD.
Some checks failed
Build & Release / Linux-AARCH64-Build (push) Failing after 7s
Build & Release / Windows-AMD64-Build (push) Successful in 4m15s
Build & Release / Linux-AMD64-Build (push) Successful in 7m14s
2025-05-16 21:35:27 -07:00
83bb62456a Updated README.
Some checks failed
Build & Release / Linux-AARCH64-Build (push) Failing after 2s
Build & Release / Windows-AMD64-Build (push) Successful in 4m25s
Build & Release / Linux-AMD64-Build (push) Successful in 7m31s
2025-05-16 21:20:00 -07:00
f1d1a1cbb1 Updated README.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Failing after 8s
Build & Release / Linux-AARCH64-Build (push) Failing after 14s
Build & Release / Windows-AMD64-Build (push) Successful in 5m9s
2025-05-16 21:18:34 -07:00
8bf4f6336f Fixed CMAKE to remove ALSA dependency. 2025-05-17 03:51:20 +01:00
25e40560b7 Updated README. 2025-05-11 19:46:25 -07:00
bce48fe121 Fixed "System::OpenURI". Added SHA256. Added URI safe Base64 methods.
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 6m9s
Build & Release / Linux-AMD64-Build (push) Successful in 15m26s
Build & Release / Linux-AARCH64-Build (push) Successful in 45m54s
2025-05-11 19:43:50 -07:00
2cb01a7c65 Fixed Windows CI/CD and fixed AVX on AARCH64 again.
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 5m35s
Build & Release / Linux-AMD64-Build (push) Successful in 15m24s
Build & Release / Linux-AARCH64-Build (push) Successful in 45m55s
2025-05-09 19:43:05 -07:00
3025b76bec Fixed AVX undefined symbols on AARCH64 and removed AVX from ehs::Util::Compare.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 31s
Build & Release / Linux-AMD64-Build (push) Successful in 15m25s
Build & Release / Linux-AARCH64-Build (push) Failing after 22m49s
2025-05-09 19:17:09 -07:00
0cec9789b1 Cached CPU features, added AVX2, and AVX512.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 4m42s
Build & Release / Linux-AMD64-Build (push) Successful in 15m40s
Build & Release / Linux-AARCH64-Build (push) Failing after 45m49s
2025-05-08 22:41:05 -07:00
63eba0d2db Fixed Str constructor not to check for a null-terminator if given a size of zero. 2025-05-02 07:01:40 -07:00
c5b281d73c Added String<T, N>.ParseArgs(). 2025-04-14 13:40:00 -07:00
8d28f3547c Merge remote-tracking branch 'origin/NetChannels' into NetChannels 2025-04-14 00:27:26 -07:00
a7f09382fd Fixed vector. 2025-04-14 00:22:10 -07:00
c437a39e1d Added missing dependency on Windows.
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 4m45s
Build & Release / Linux-AMD64-Build (push) Successful in 14m40s
Build & Release / Linux-AARCH64-Build (push) Successful in 43m39s
2025-03-28 21:47:47 -07:00
8b53b6e4d1 Implemented ICMPv6 on Windows.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 3m34s
Build & Release / Linux-AMD64-Build (push) Successful in 14m39s
Build & Release / Linux-AARCH64-Build (push) Successful in 43m40s
2025-03-28 21:24:13 -07:00
ff42dfd3a4 Added ICMPv6 support to Linux.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 3m31s
Build & Release / Linux-AMD64-Build (push) Successful in 14m40s
Build & Release / Linux-AARCH64-Build (push) Successful in 43m42s
2025-03-28 20:53:48 -07:00
d8c5327180 Added ICMPv6 support to Windows.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Has been cancelled
Build & Release / Linux-AARCH64-Build (push) Has been cancelled
Build & Release / Windows-AMD64-Build (push) Has been cancelled
2025-03-28 20:47:46 -07:00
42b26045a6 Added ICMPv6 support to Linux. 2025-03-27 00:15:02 -07:00
d41f71f17d Added IPv4 ICMP support to Windows.
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 5m1s
Build & Release / Linux-AMD64-Build (push) Successful in 14m41s
Build & Release / Linux-AARCH64-Build (push) Successful in 43m40s
2025-03-26 11:45:54 -07:00
c19c0bc80b Renamed member variables and parameters.
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 4m10s
Build & Release / Linux-AMD64-Build (push) Successful in 14m40s
Build & Release / Linux-AARCH64-Build (push) Successful in 43m37s
2025-03-26 10:42:29 -07:00
86149d246a Renamed member variables and parameters.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Failing after 10s
Build & Release / Linux-AARCH64-Build (push) Failing after 14s
Build & Release / Windows-AMD64-Build (push) Successful in 4m16s
2025-03-26 10:29:20 -07:00
1e55b11eed Fixed CMakeLists.
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 4m23s
Build & Release / Linux-AMD64-Build (push) Successful in 14m40s
Build & Release / Linux-AARCH64-Build (push) Successful in 43m36s
2025-03-25 19:43:42 -07:00
ce225b2888 Fixed CMakeLists and BaseICMP.cpp.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Has been cancelled
Build & Release / Linux-AARCH64-Build (push) Has been cancelled
Build & Release / Windows-AMD64-Build (push) Has been cancelled
2025-03-25 19:42:40 -07:00
eb3d345c5a Fixed gitea workflow.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 9m49s
Build & Release / Linux-AMD64-Build (push) Successful in 14m41s
Build & Release / Linux-AARCH64-Build (push) Successful in 43m37s
2025-03-25 19:26:10 -07:00
6cf4977a6c Fixed gitea workflow.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Has been cancelled
Build & Release / Linux-AARCH64-Build (push) Has been cancelled
Build & Release / Windows-AMD64-Build (push) Has been cancelled
2025-03-25 19:22:08 -07:00
ae226c9a84 Fixed gitea workflow.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 15s
Build & Release / Linux-AMD64-Build (push) Successful in 14m41s
Build & Release / Linux-AARCH64-Build (push) Successful in 43m37s
2025-03-25 19:20:24 -07:00
bf3b063e96 Fixed gitea workflow.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 19s
Build & Release / Linux-AMD64-Build (push) Successful in 14m39s
Build & Release / Linux-AARCH64-Build (push) Successful in 43m36s
2025-03-25 19:17:53 -07:00
e071877045 Fixed gitea workflow.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 14s
Build & Release / Linux-AMD64-Build (push) Successful in 14m40s
Build & Release / Linux-AARCH64-Build (push) Successful in 43m37s
2025-03-25 19:15:32 -07:00
af90f90156 Fixed gitea workflow.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 14s
Build & Release / Linux-AMD64-Build (push) Successful in 14m39s
Build & Release / Linux-AARCH64-Build (push) Successful in 43m37s
2025-03-25 18:49:14 -07:00
16ef5bbb74 Fixed gitea workflow.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Successful in 14m41s
Build & Release / Windows-AMD64-Build (push) Failing after 23s
Build & Release / Linux-AARCH64-Build (push) Successful in 43m36s
2025-03-25 18:42:56 -07:00
6cba7d6698 Fixed gitea workflow. 2025-03-25 18:35:52 -07:00
9ab62d0545 Added CPU::GetCacheLineSize() definition for Windows.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 25s
Build & Release / Linux-AMD64-Build (push) Failing after 13m28s
Build & Release / Linux-AARCH64-Build (push) Failing after 1m0s
2025-03-25 16:45:18 -07:00
b44e55a92c Merge pull request 'NetChannels' (#15) from NetChannels into main
Reviewed-on: EventHorizonStudio/EHS#15
2025-03-23 03:22:41 -07:00
53d86eb539 Merge remote-tracking branch 'origin/NetChannels' into NetChannels
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 9m34s
Build & Release / Linux-AMD64-Build (push) Failing after 1m58s
Build & Release / Linux-AARCH64-Build (push) Failing after 5m21s
2025-03-23 03:11:24 -07:00
352b4d612f First commit for ICMP capabilities, added CPU::GetCacheLineSize(), and removed BaseObj from containers. 2025-03-23 03:10:35 -07:00
89925fe820 Renamed member variables and parameters. 2025-01-30 13:01:01 -08:00
16b56a7084 Made NetChannel methods public in EHC. 2025-01-30 12:32:52 -08:00
62f8a662a0 Backup. 2025-01-29 16:21:11 -08:00
39bbcd0d56 Added missing constructor for NetChannel in NetServerCh. 2025-01-28 04:28:55 -08:00
981b40d3b1 Finished implementing, now for the testing phase. 2025-01-26 21:43:17 -08:00
7bc4b9977d Merge pull request 'Added the capability for custom encryption's to be added to EHC.' (#14) from fix into main
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 6m24s
Build & Release / Linux-AMD64-Build (push) Successful in 13m7s
Build & Release / Linux-AARCH64-Build (push) Successful in 39m52s
Reviewed-on: EventHorizonStudio/EHS#14
2024-10-06 23:20:53 -07:00
79860c7d39 Added the capability for custom encryption's to be added to EHC.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Waiting to run
Build & Release / Linux-AARCH64-Build (push) Has been cancelled
Build & Release / Linux-AMD64-Build (push) Has been cancelled
2024-10-06 23:19:42 -07:00
99bab4a6ef Merge pull request 'New Audio and EHC PR' (#13) from audio into main
Some checks failed
Build & Release / Linux-AMD64-Build (push) Failing after 3m34s
Build & Release / Windows-AMD64-Build (push) Successful in 6m44s
Build & Release / Linux-AARCH64-Build (push) Has been cancelled
Reviewed-on: EventHorizonStudio/EHS#13
2024-10-06 23:00:31 -07:00
8b01ee3c46 Added the capability for custom encryption's to be added to EHC. 2024-10-06 22:54:29 -07:00
1feff0a25c Moved the Event Horizon Communications to this project. 2024-10-06 20:08:22 -07:00
9b42ad6d74 Simplified audio playback & capturing significantly. 2024-10-06 17:24:32 -07:00
9639329df3 Updated readme. 2024-10-06 01:16:04 -07:00
6cd686a17e Updated readme. 2024-10-06 01:14:14 -07:00
3343f8ca28 Fixed workflow.
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 7m5s
Build & Release / Linux-AMD64-Build (push) Successful in 12m7s
Build & Release / Linux-AARCH64-Build (push) Successful in 37m1s
2024-10-05 19:05:30 -07:00
3b8159b75f Fixed workflow.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 6m8s
Build & Release / Linux-AMD64-Build (push) Failing after 17m38s
Build & Release / Linux-AARCH64-Build (push) Failing after 36m37s
2024-10-01 21:27:31 -07:00
62e7580d3a Added install dependency for pipewire.
Some checks failed
Build & Release / Linux-AARCH64-Build (push) Failing after 7s
Build & Release / Windows-AMD64-Build (push) Failing after 5m13s
Build & Release / Linux-AMD64-Build (push) Failing after 17m37s
2024-10-01 21:00:00 -07:00
11170006e9 Fixed workflow for Windows.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Failing after 8s
Build & Release / Linux-AARCH64-Build (push) Failing after 14s
Build & Release / Windows-AMD64-Build (push) Failing after 5m15s
2024-10-01 20:19:38 -07:00
37e3ca9360 Fixed workflow for Windows.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Failing after 8s
Build & Release / Linux-AARCH64-Build (push) Failing after 14s
Build & Release / Windows-AMD64-Build (push) Failing after 5m19s
2024-10-01 19:58:35 -07:00
daca00603a Fixed workflow for Windows.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Failing after 8s
Build & Release / Linux-AARCH64-Build (push) Failing after 14s
Build & Release / Windows-AMD64-Build (push) Failing after 6m8s
2024-10-01 19:50:21 -07:00
1f5299ad1b Fixed Win32 audio.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Failing after 8s
Build & Release / Linux-AARCH64-Build (push) Failing after 14s
Build & Release / Windows-AMD64-Build (push) Failing after 5m56s
2024-10-01 18:58:15 -07:00
dfa260b87c Backup. 2024-09-30 20:24:25 -07:00
fc8b771026 Added vcpkg.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Failing after 8s
Build & Release / Linux-AARCH64-Build (push) Failing after 14s
Build & Release / Windows-AMD64-Build (push) Failing after 3m52s
2024-09-30 19:55:44 -07:00
0b77c074cf Added vcpkg.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Failing after 8s
Build & Release / Linux-AARCH64-Build (push) Failing after 13s
Build & Release / Windows-AMD64-Build (push) Failing after 30s
2024-09-30 19:48:07 -07:00
5007a1047a Added vcpkg.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Failing after 7s
Build & Release / Linux-AARCH64-Build (push) Failing after 14s
Build & Release / Windows-AMD64-Build (push) Failing after 30s
2024-09-30 19:22:22 -07:00
25860dc32a Added vcpkg. 2024-09-29 21:07:30 -07:00
d870599a60 Added vcpkg. 2024-09-29 21:06:30 -07:00
9bd3e1cd8d Added vcpkg. 2024-09-29 20:41:37 -07:00
681c0d09be Fixed Mat and CMakeLists 2024-09-16 16:18:49 -07:00
25762b0c29 Backup. 2024-09-03 05:37:23 -07:00
6afa08df82 Updated README.md again. 2024-08-15 19:41:05 -07:00
0a995a3f2c Updated README.md 2024-08-15 19:40:31 -07:00
c607b20bad Cleaned up and fixed some errors in the Json Parser. 2024-08-15 19:28:30 -07:00
2e705627ac Fixed CMakeLists.txt and System_LNX.cpp. 2024-08-15 17:33:04 -07:00
86a35fd668 Added System::GetDirDialog. 2024-08-04 02:09:10 -07:00
8d4420528a Optimized Button class. Added IsPressed and GetPressed methods. 2024-08-04 00:47:38 -07:00
3970b8d402 Fixed Mat and CMakeLists 2024-07-27 18:51:19 -07:00
6522994a1f Fixed Win32 keyboard input. 2024-07-27 10:12:10 -07:00
01a21032a5 Simplified Windows build again. 2024-07-24 15:37:45 -07:00
4d7e7596b6 Simplified Windows build. 2024-07-24 14:58:36 -07:00
97b5300e48 Merge pull request 'dynamic' (#10) from dynamic into main
Reviewed-on: EventHorizonStudio/EHS#10
2024-07-24 01:39:29 -07:00
8e7cc39000 Added shared library support. 2024-07-24 01:36:20 -07:00
1b70383448 Started dynamic library support. 2024-07-21 10:45:06 -07:00
64e1555d56 Fixed DNS, TCP and UDP on Windows.
All checks were successful
Build & Release / Linux-AMD64-Build (push) Successful in 1m5s
Build & Release / Windows-AMD64-Build (push) Successful in 3m43s
Build & Release / Linux-AARCH64-Build (push) Successful in 3m31s
2024-07-10 02:36:21 -07:00
a65c8d64b5 Fixed constructor to use move constructors.
Some checks failed
Build & Release / Linux-AMD64-Build (push) Successful in 1m44s
Build & Release / Linux-AARCH64-Build (push) Successful in 3m46s
Build & Release / Windows-AMD64-Build (push) Failing after 7h1m29s
2024-07-09 19:23:24 -07:00
fa2b801690 Fixed Spotify.Play and fixed TCP.Connect. 2024-07-09 17:39:01 -07:00
4e887b1ac2 Added new DNS::Resolve static method and organized it per OS. 2024-07-09 16:41:43 -07:00
126fc92fae Fixed Wayland window resizing and closing. 2024-07-08 21:17:09 -07:00
2ef28273b0 Fixed Wayland window decoration. 2024-07-05 13:15:34 -07:00
04bf7d43ff Added second wl_display_roundtrip before wl_surface_commit. 2024-07-04 12:12:19 -07:00
fb86dca332 Added features to readme. 2024-07-03 19:49:18 -07:00
7e380efd7d Added features to readme. 2024-07-01 22:15:49 -07:00
b5e05864b6 Removed const arguments from GC header. 2024-07-01 20:23:17 -07:00
e2e5a1b8db Fixed FileMonitor, Window, Thread, and Audio on Windows.
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 1m25s
Build & Release / Linux-AMD64-Build (push) Successful in 1m38s
Build & Release / Linux-AARCH64-Build (push) Successful in 3m36s
2024-07-01 19:16:45 -07:00
2a2296685e Fixed Directory for Windows.
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 1m41s
Build & Release / Linux-AMD64-Build (push) Successful in 1m56s
Build & Release / Linux-AARCH64-Build (push) Successful in 3m48s
2024-06-29 23:38:27 -07:00
231 changed files with 10551 additions and 2671 deletions

View File

@@ -8,6 +8,9 @@ on:
jobs:
Windows-AMD64-Build:
runs-on: windows-x86_64
defaults:
run:
shell: powershell
steps:
- name: Check out repository code
uses: actions/checkout@v3
@@ -19,8 +22,9 @@ jobs:
- name: Building/Compiling/Installing Project
run: |
cd ${{ gitea.workspace }}
cmake -A x64 -DCMAKE_BUILD_TYPE=Release --preset=default .
mkdir build
cd build
cmake -A x64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake" ..
cmake --build . --config Release
cmake --install .
@@ -28,10 +32,14 @@ jobs:
run: |
cd ${{ gitea.workspace }}
mkdir bin
mv build/Release/EHS_Dyn.dll bin
mv build/Release/StrToHash.exe bin
mv build/Release/zlib1.dll bin
mv build/Release/libcrypto-3-x64.dll bin
mv build/Release/libssl-3-x64.dll bin
mkdir lib
mv build/Release/EHS.lib lib
mv build/Release/EHS_Stc.lib lib
mv build/Release/EHS_Dyn.lib lib
- name: Zipping Binaries
run: |
@@ -49,6 +57,7 @@ jobs:
files: |-
ehs-windows-amd64.zip
api_key: '${{secrets.RELEASE_TOKEN}}'
pre_release: false
Linux-AMD64-Build:
runs-on: linux-x86_64
@@ -58,7 +67,7 @@ jobs:
- name: Installing Dependencies
run: |
sudo pacman -S --noconfirm doxygen zip alsa-lib libxcb xcb-util-cursor
sudo pacman -S --noconfirm doxygen ninja zip libxcb xcb-util-cursor pipewire
- name: Generating Documentation
run: |
@@ -67,16 +76,18 @@ jobs:
- name: Building/Compiling/Installing Project
run: |
cd ${{ gitea.workspace }}
cmake -DCMAKE_BUILD_TYPE=Release -DLINUX_WINDOW_SYSTEM:STRING=XCB .
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLINUX_WINDOW_SYSTEM:STRING=XCB .
cmake --build . --config Release
cmake --install .
- name: Creating Appropriate Directories
run: |
cd ${{ gitea.workspace }}
mkdir bin
mv libEHS_Dyn.so bin
mv StrToHash bin
mkdir lib
mv libEHS.a lib
mv libEHS_Stc.a lib
- name: Zipping Binaries
run: zip -r ehs-linux-amd64.zip include bin lib docs LICENSE RADME.md
@@ -92,6 +103,7 @@ jobs:
files: |-
ehs-linux-amd64.zip
api_key: '${{secrets.RELEASE_TOKEN}}'
pre_release: false
Linux-AARCH64-Build:
runs-on: linux-aarch64
@@ -100,7 +112,7 @@ jobs:
uses: actions/checkout@v3
- name: Installing Dependencies
run: sudo apt install -y doxygen zip libasound2-dev libxcb1-dev libxcb-xinput-dev libxcb-cursor-dev
run: sudo apt install -y doxygen ninja-build zip libxcb1-dev libxcb-xinput-dev libxcb-cursor-dev libpipewire-0.3-dev
- name: Generating Documentation
run: |
@@ -109,16 +121,18 @@ jobs:
- name: Building/Compiling/Installing Project
run: |
cd ${{ gitea.workspace }}
cmake -DCMAKE_BUILD_TYPE=Release -DLINUX_WINDOW_SYSTEM:STRING=XCB .
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLINUX_WINDOW_SYSTEM:STRING=XCB .
cmake --build . --config Release
cmake --install .
- name: Creating Appropriate Directories
run: |
cd ${{ gitea.workspace }}
mkdir bin
mv libEHS_Dyn.so bin
mv StrToHash bin
mkdir lib
mv libEHS.a lib
mv libEHS_Stc.a lib
- name: Zipping Binaries
run: zip -r ehs-linux-aarch64.zip include bin lib docs LICENSE README.md
@@ -134,3 +148,4 @@ jobs:
files: |-
ehs-linux-aarch64.zip
api_key: '${{secrets.RELEASE_TOKEN}}'
pre_release: false

26
Assembly.def Normal file
View File

@@ -0,0 +1,26 @@
LIBRARY EHS_Dyn
EXPORTS
?GenerateSeed_u64@HRNG@ehs@@SA_KXZ
?Generate_u64@HRNG@ehs@@SA_K_K0@Z
?Generate_u64@HRNG@ehs@@SA_KXZ
?GenerateSeed_s64@HRNG@ehs@@SA_JXZ
?Generate_s64@HRNG@ehs@@SA_J_J0@Z
?Generate_s64@HRNG@ehs@@SA_JXZ
?GenerateSeed_u32@HRNG@ehs@@SAIXZ
?Generate_u32@HRNG@ehs@@SAIII@Z
?Generate_u32@HRNG@ehs@@SAIXZ
?GenerateSeed_s32@HRNG@ehs@@SAHXZ
?Generate_s32@HRNG@ehs@@SAHHH@Z
?Generate_s32@HRNG@ehs@@SAHXZ
?GenerateSeed_u16@HRNG@ehs@@SAIXZ
?Generate_u16@HRNG@ehs@@SAGGG@Z
?Generate_u16@HRNG@ehs@@SAGXZ
?GenerateSeed_s16@HRNG@ehs@@SAFXZ
?Generate_s16@HRNG@ehs@@SAFFF@Z
?Generate_s16@HRNG@ehs@@SAFXZ
?GenerateSeed_u8@HRNG@ehs@@SAEXZ
?Generate_u8@HRNG@ehs@@SAEEE@Z
?Generate_u8@HRNG@ehs@@SAEXZ
?GenerateSeed_s8@HRNG@ehs@@SACXZ
?Generate_s8@HRNG@ehs@@SACCC@Z
?Generate_s8@HRNG@ehs@@SACXZ

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.25.1)
cmake_minimum_required(VERSION 3.30.4)
set(IS_OS_WINDOWS FALSE)
set(IS_OS_LINUX FALSE)
@@ -11,9 +11,12 @@ set(IS_ARCH_ARM FALSE)
project(EHS CXX C)
set(CMAKE_VERBOSE_MAKEFILE ON)
if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
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.")
elseif (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Linux")
set(IS_OS_LINUX TRUE)
@@ -39,184 +42,216 @@ endif ()
set(CMAKE_CXX_STANDARD 20)
set(EHS_SOURCES
src/EHS.cpp include/ehs/EHS.h
src/Type.cpp include/ehs/Type.h
src/BaseObj.cpp include/ehs/BaseObj.h
src/GC.cpp include/ehs/GC.h
src/Log.cpp include/ehs/Log.h
src/URI.cpp include/ehs/URI.h
src/Math.cpp include/ehs/Math.h
src/Color4.cpp include/ehs/Color4.h
src/Color3.cpp include/ehs/Color3.h
src/Version.cpp include/ehs/Version.h
src/Base64.cpp include/ehs/Base64.h
src/Data.cpp include/ehs/Data.h
src/Range.cpp include/ehs/Range.h
src/Util.cpp include/ehs/Util.h
src/Task.cpp include/ehs/Task.h
src/DataType.cpp include/ehs/DataType.h
include/ehs/Anchor.h
include/ehs/Dock.h
include/ehs/HashMap.h
include/ehs/HRNG.h
include/ehs/Link.h
include/ehs/LinkedList.h
include/ehs/Mat2.h
include/ehs/Mat3.h
include/ehs/Mat4.h
include/ehs/PRNG.h
include/ehs/Quat.h
include/ehs/Rect.h
include/ehs/Str.h
include/ehs/Types.h
include/ehs/UTF.h
include/ehs/Vec2.h
include/ehs/Vec3.h
include/ehs/Vec4.h
include/ehs/Serializer.h
include/ehs/Array.h
include/ehs/Vector.h
include/ehs/SArray.h
src/PtrData.cpp include/ehs/PtrData.h
include/ehs/UniPtr.h
include/ehs/ShdPtr.h
include/ehs/WkPtr.h
src/EHS.cpp include/ehs/EHS.h
src/Type.cpp include/ehs/Type.h
src/BaseObj.cpp include/ehs/BaseObj.h
src/GC.cpp include/ehs/GC.h
src/Log.cpp include/ehs/Log.h
src/URI.cpp include/ehs/URI.h
src/Math.cpp include/ehs/Math.h
src/Color4.cpp include/ehs/Color4.h
src/Color3.cpp include/ehs/Color3.h
src/Version.cpp include/ehs/Version.h
src/Base64.cpp include/ehs/Base64.h
src/SHA256.cpp include/ehs/SHA256.h
src/Data.cpp include/ehs/Data.h
src/Range.cpp include/ehs/Range.h
src/Util.cpp include/ehs/Util.h
src/Task.cpp include/ehs/Task.h
src/DataType.cpp include/ehs/DataType.h
include/ehs/Anchor.h
include/ehs/Dock.h
include/ehs/HashMap.h
include/ehs/HRNG.h
include/ehs/Link.h
include/ehs/LinkedList.h
include/ehs/Mat2.h
include/ehs/Mat3.h
include/ehs/Mat4.h
include/ehs/PRNG.h
include/ehs/Quat.h
include/ehs/Rect.h
include/ehs/Str.h
include/ehs/Types.h
include/ehs/UTF.h
include/ehs/Vec2.h
include/ehs/Vec3.h
include/ehs/Vec4.h
include/ehs/Serializer.h
include/ehs/Array.h
include/ehs/Vector.h
include/ehs/SArray.h
src/PtrData.cpp include/ehs/PtrData.h
include/ehs/UniPtr.h
include/ehs/ShdPtr.h
include/ehs/WkPtr.h
src/db/DbVarTmpl.cpp include/ehs/db/DbVarTmpl.h
src/db/DbVarTmpl.cpp include/ehs/db/DbVarTmpl.h
src/system/CPU.cpp include/ehs/system/CPU.h
src/system/Thread.cpp include/ehs/system/Thread.h
src/system/BaseMutex.cpp include/ehs/system/BaseMutex.h
src/system/BaseSemaphore.cpp include/ehs/system/BaseSemaphore.h
src/system/BaseSystem.cpp include/ehs/system/BaseSystem.h
src/system/BaseOpen.cpp include/ehs/system/BaseOpen.h
include/ehs/system/Architecture.h
include/ehs/system/Mutex.h
include/ehs/system/Open.h
include/ehs/system/OS.h
include/ehs/system/Semaphore.h
include/ehs/system/System.h
src/system/CPU.cpp include/ehs/system/CPU.h
src/system/Thread.cpp include/ehs/system/Thread.h
src/system/BaseMutex.cpp include/ehs/system/BaseMutex.h
src/system/BaseSemaphore.cpp include/ehs/system/BaseSemaphore.h
src/system/BaseSystem.cpp include/ehs/system/BaseSystem.h
src/system/BaseOpen.cpp include/ehs/system/BaseOpen.h
include/ehs/system/Architecture.h
include/ehs/system/Mutex.h
include/ehs/system/Open.h
include/ehs/system/OS.h
include/ehs/system/Semaphore.h
include/ehs/system/System.h
include/ehs/system/AVX2.h
include/ehs/system/AVX512.h
src/json/Json.cpp include/ehs/json/Json.h
src/json/JsonBase.cpp include/ehs/json/JsonBase.h
src/json/JsonNum.cpp include/ehs/json/JsonNum.h
src/json/JsonBool.cpp include/ehs/json/JsonBool.h
src/json/JsonStr.cpp include/ehs/json/JsonStr.h
src/json/JsonObj.cpp include/ehs/json/JsonObj.h
src/json/JsonArray.cpp include/ehs/json/JsonArray.h
src/json/JsonVar.cpp include/ehs/json/JsonVar.h
src/json/Json.cpp include/ehs/json/Json.h
src/json/JsonBase.cpp include/ehs/json/JsonBase.h
src/json/JsonNum.cpp include/ehs/json/JsonNum.h
src/json/JsonBool.cpp include/ehs/json/JsonBool.h
src/json/JsonStr.cpp include/ehs/json/JsonStr.h
src/json/JsonObj.cpp include/ehs/json/JsonObj.h
src/json/JsonArray.cpp include/ehs/json/JsonArray.h
src/json/JsonVar.cpp include/ehs/json/JsonVar.h
src/io/Resource.cpp include/ehs/io/Resource.h
src/io/Console.cpp include/ehs/io/Console.h
src/io/RIFF_Chunk.cpp include/ehs/io/RIFF_Chunk.h
src/io/RIFF.cpp include/ehs/io/RIFF.h
src/io/BaseWindow.cpp include/ehs/io/BaseWindow.h
src/io/BaseFile.cpp include/ehs/io/BaseFile.h
src/io/Glyph.cpp include/ehs/io/Glyph.h
src/io/FontAtlas.cpp include/ehs/io/FontAtlas.h
src/io/BaseFileMonitor.cpp include/ehs/io/BaseFileMonitor.h
include/ehs/io/COM.h
include/ehs/io/File.h
include/ehs/io/FileMonitor.h
include/ehs/io/Window.h
src/io/Resource.cpp include/ehs/io/Resource.h
src/io/Console.cpp include/ehs/io/Console.h
src/io/RIFF_Chunk.cpp include/ehs/io/RIFF_Chunk.h
src/io/RIFF.cpp include/ehs/io/RIFF.h
src/io/BaseWindow.cpp include/ehs/io/BaseWindow.h
src/io/BaseFile.cpp include/ehs/io/BaseFile.h
src/io/Glyph.cpp include/ehs/io/Glyph.h
src/io/FontAtlas.cpp include/ehs/io/FontAtlas.h
src/io/BaseFileMonitor.cpp include/ehs/io/BaseFileMonitor.h
include/ehs/io/COM.h
include/ehs/io/File.h
include/ehs/io/FileMonitor.h
include/ehs/io/Window.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/DNS.cpp include/ehs/io/socket/DNS.h
src/io/socket/BaseUDP.cpp include/ehs/io/socket/BaseUDP.h
src/io/socket/BaseTCP.cpp include/ehs/io/socket/BaseTCP.h
src/io/socket/SSL.cpp include/ehs/io/socket/SSL.h
include/ehs/io/socket/Socket.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/BaseDNS.cpp include/ehs/io/socket/BaseDNS.h
include/ehs/io/socket/DNS.h
src/io/socket/BaseUDP.cpp include/ehs/io/socket/BaseUDP.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
src/io/socket/rest/Twitch.cpp include/ehs/io/socket/rest/Twitch.h
src/io/socket/rest/TwitchChat.cpp include/ehs/io/socket/rest/TwitchChat.h
src/io/socket/rest/Spotify.cpp include/ehs/io/socket/rest/Spotify.h
include/ehs/io/socket/Socket.h
include/ehs/io/socket/TCP.h
include/ehs/io/socket/UDP.h
include/ehs/io/socket/ehc/NetUtils.h
src/io/socket/EHC.cpp include/ehs/io/socket/EHC.h
src/io/socket/ehc/NetFrag.cpp include/ehs/io/socket/ehc/NetFrag.h
src/io/socket/ehc/NetEnd.cpp include/ehs/io/socket/ehc/NetEnd.h
src/io/socket/ehc/NetSys.cpp include/ehs/io/socket/ehc/NetSys.h
src/io/socket/ehc/NetOp.cpp include/ehs/io/socket/ehc/NetOp.h
src/io/audio/Audio.cpp include/ehs/io/audio/Audio.h
src/io/audio/BaseAudioDevice.cpp include/ehs/io/audio/BaseAudioDevice.h
src/io/audio/AudioCodec.cpp include/ehs/io/audio/AudioCodec.h
include/ehs/io/audio/AudioDevice.h
src/io/socket/rest/Twitch.cpp include/ehs/io/socket/rest/Twitch.h
src/io/socket/rest/TwitchChat.cpp include/ehs/io/socket/rest/TwitchChat.h
src/io/socket/rest/Spotify.cpp include/ehs/io/socket/rest/Spotify.h
src/io/img/PNG.cpp include/ehs/io/img/PNG.h
src/io/img/Img.cpp include/ehs/io/img/Img.h
src/io/img/PNG_Chunk.cpp include/ehs/io/img/PNG_Chunk.h
src/io/img/ImgCodec.cpp include/ehs/io/img/ImgCodec.h
src/io/audio/Audio.cpp include/ehs/io/audio/Audio.h
src/io/audio/BaseAudioDevice.cpp include/ehs/io/audio/BaseAudioDevice.h
src/io/audio/AudioCodec.cpp include/ehs/io/audio/AudioCodec.h
include/ehs/io/audio/AudioDevice.h
include/ehs/io/mdl/Vertex.h
src/io/model/Mesh.cpp include/ehs/io/mdl/Mesh.h
src/io/model/Bone.cpp include/ehs/io/mdl/Bone.h
src/io/model/Mdl.cpp include/ehs/io/mdl/Mdl.h
src/io/model/Animation.cpp include/ehs/io/mdl/Animation.h
src/io/model/AnimBone.cpp include/ehs/io/mdl/AnimBone.h
src/io/model/KeyFrame.cpp include/ehs/io/mdl/KeyFrame.h
src/io/model/PropertyChange.cpp include/ehs/io/mdl/PropertyChange.h
src/io/img/PNG.cpp include/ehs/io/img/PNG.h
src/io/img/Img.cpp include/ehs/io/img/Img.h
src/io/img/PNG_Chunk.cpp include/ehs/io/img/PNG_Chunk.h
src/io/img/ImgCodec.cpp include/ehs/io/img/ImgCodec.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/io/Usb_LNX.h
src/io/Usb_LNX.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_LNX.h
src/io/Directory_LNX.cpp
include/ehs/io/Directory.h
include/ehs/io/mdl/Vertex.h
src/io/model/Mesh.cpp include/ehs/io/mdl/Mesh.h
src/io/model/Bone.cpp include/ehs/io/mdl/Bone.h
src/io/model/Mdl.cpp include/ehs/io/mdl/Mdl.h
src/io/model/Animation.cpp include/ehs/io/mdl/Animation.h
src/io/model/AnimBone.cpp include/ehs/io/mdl/AnimBone.h
src/io/model/KeyFrame.cpp include/ehs/io/mdl/KeyFrame.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
include/ehs/io/socket/ehc/NetChannel.h
src/io/socket/ehc/NetChannel.cpp
include/ehs/io/socket/ehc/NetServerCh.h
include/ehs/io/socket/ehc/NetClientCh.h
src/io/socket/ehc/NetClientCh.cpp
src/io/socket/ehc/NetServerCh.cpp
src/io/socket/ehc/NetUtils.cpp
include/ehs/io/socket/BaseICMP.h src/io/socket/BaseICMP.cpp
include/ehs/io/socket/ICMP.h
src/io/socket/QueryVar.cpp include/ehs/io/socket/QueryVar.h
src/io/socket/HeaderVar.cpp include/ehs/io/socket/HeaderVar.h
)
if (IS_OS_WINDOWS)
list(APPEND EHS_SOURCES
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/system/Semaphore_W32.cpp include/ehs/system/Semaphore_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/Open_W32.cpp include/ehs/system/Open_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/FileMonitor_W32.cpp include/ehs/io/FileMonitor_W32.h
src/io/Window_W32.cpp include/ehs/io/Window_W32.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
)
elseif (IS_OS_LINUX)
list(APPEND EHS_SOURCES
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/system/Semaphore_P.cpp include/ehs/system/Semaphore_P.h
src/system/System_LNX.cpp include/ehs/system/System_LNX.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/FileMonitor_UNX.cpp include/ehs/io/FileMonitor_UNX.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/system/FileSystem.cpp include/ehs/system/FileSystem.h
src/system/User.cpp include/ehs/system/User.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/DNS_W32.cpp include/ehs/io/socket/DNS_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/Mutex_W32.cpp include/ehs/system/Mutex_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/File_W32.cpp include/ehs/io/File_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/COM.cpp include/ehs/io/COM.h
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
include/ehs/io/socket/ICMP_W32.h src/io/socket/ICMP_W32.cpp
src/system/AVX2_MSVC_AMD64.asm src/system/AVX512_MSVC_AMD64.asm
)
set(LINUX_WINDOW_SYSTEM "Wayland" CACHE STRING "Linux Window System")
elseif (IS_OS_LINUX)
list(APPEND EHS_SOURCES
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/DNS_LNX.cpp include/ehs/io/socket/DNS_LNX.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/Open_UNX.cpp include/ehs/system/Open_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/system/Mutex_PT.cpp include/ehs/system/Mutex_PT.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/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
include/ehs/io/socket/ICMP_LNX.h src/io/socket/ICMP_LNX.cpp
)
set(LINUX_WINDOW_SYSTEM "XCB" CACHE STRING "Linux Window System")
if (LINUX_WINDOW_SYSTEM STREQUAL "Wayland")
add_compile_definitions(EHS_WS_WAYLAND)
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)
list(APPEND EHS_SOURCES
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.")
elseif (LINUX_WINDOW_SYSTEM STREQUAL "XCB")
add_compile_definitions(EHS_WS_XCB)
@@ -225,32 +260,43 @@ elseif (IS_OS_LINUX)
endif ()
if (IS_ARCH_AMD64)
list(APPEND EHS_SOURCES src/system/CPU_GCC_AMD64.asm src/HRNG_GCC.asm src/Math_GCC_AMD64.asm)
list(APPEND EHS_SOURCES src/system/CPU_GCC_AMD64.asm src/HRNG_GCC.asm src/Math_GCC_AMD64.asm src/system/AVX2_GCC_AMD64.asm src/system/AVX512_GCC_AMD64.asm)
elseif (IS_ARCH_ARM64)
list(APPEND EHS_SOURCES src/system/CPU_ARM64.cpp src/HRNG_ARM64.cpp src/Math_GCC_ARM64.s)
list(APPEND EHS_SOURCES src/system/CPU_ARM64.cpp src/system/CPU_GCC_AARCH64.s src/HRNG_ARM64.cpp src/Math_GCC_ARM64.s src/system/AVX2_AARCH64.cpp src/system/AVX512_AARCH64.cpp)
endif ()
endif()
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
#message("${CMAKE_CXX_FLAGS}")
add_library(EHS ${EHS_SOURCES})
add_library(EHS_Stc STATIC ${EHS_SOURCES})
add_library(EHS_Dyn SHARED ${EHS_SOURCES} Assembly.def)
add_executable(StrToHash src/StrToHash.cpp)
target_include_directories(EHS PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_compile_definitions(EHS_Dyn PRIVATE EHS_LIB_EXPORT)
target_include_directories(EHS_Stc PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_include_directories(EHS_Dyn PUBLIC ${PROJECT_SOURCE_DIR}/include)
if (IS_OS_LINUX)
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)
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 ()
install(TARGETS EHS DESTINATION lib)
install(TARGETS EHS_Stc DESTINATION "lib")
install(TARGETS StrToHash DESTINATION "bin")
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include)
install(TARGETS StrToHash DESTINATION bin)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/" DESTINATION "include")
find_package(ZLIB REQUIRED)
if (ZLIB_FOUND)
@@ -266,16 +312,22 @@ else ()
message(STATUS "OpenSSL was not found.")
endif ()
target_link_libraries(EHS OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB)
target_link_libraries(EHS_Stc 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)
target_link_libraries(StrToHash ws2_32 avrt EHS)
target_link_libraries(EHS_Dyn avrt ws2_32 IPHLPAPI)
target_link_libraries(StrToHash ws2_32 avrt EHS_Stc)
elseif (IS_OS_LINUX)
if (LINUX_WINDOW_SYSTEM STREQUAL "Wayland")
target_link_libraries(EHS_Dyn wayland-client)
target_link_libraries(StrToHash wayland-client)
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)
endif ()
target_link_libraries(StrToHash z asound EHS)
target_link_libraries(EHS_Dyn z pipewire-0.3)
target_link_libraries(StrToHash z EHS_Stc)
endif ()

View File

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

View File

@@ -8,6 +8,7 @@ This project does not fully follow the C++ standard.
### Features
- Audio IO/Processing/Manipulation
- Image Processing/Manipulation
- Databases
- 3D Model & Mesh Processing/Manipulation
- File IO
- Basic File Monitoring
@@ -20,7 +21,8 @@ This project does not fully follow the C++ standard.
- Mutexes
- Semaphores
- CPU information and features at runtime
- HTTP(S) Sockets
- HTTP(S) Socket Layer
- ICMP & ICMPv6 Socket
- TCP Socket
- UDP Socket
- COM (Serial) IO
@@ -29,12 +31,15 @@ This project does not fully follow the C++ standard.
- Twitch Integration
- Json Parsing/Writing
- User Friendly HID Input
- Basic Garbage Collector
- Heap Garbage Collector
- Linked List
- Array
- Vector
- Asynchronous Task System
- URI Parsing
- USB (WIP)
- Base64
- SHA256
### Supported Architectures
- AMD64
@@ -71,8 +76,10 @@ Wayland Window System. Wayland support is currently not fully supported yet, use
- [CMake](https://cmake.org/)
- [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
`cmake -A x64 -DCMAKE_BUILD_TYPE=Release --preset=default /path/to/source`
`cmake -A x64 -DCMAKE_BUILD_TYPE=Release /path/to/source`
### Compiling
`cmake --build /path/to/build --config Release`
@@ -87,12 +94,10 @@ This will require the terminal to be running in administrator mode.
#include <ehs/EHS.h>
#include <ehs/io/Console.h>
ehs::Int_32 Main(ehs::Str_8* appName, ehs::Str_8* appVerId, ehs::Version* appVer)
int main()
{
// Simple identifying meta-data for the logger.
*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::Initialize("Simple Example App", "Release", {1, 0, 0});
ehs::Console::Write_8("How old are you?"); // Write to the console in UTF_8 character encoding.
@@ -101,13 +106,15 @@ ehs::Int_32 Main(ehs::Str_8* appName, ehs::Str_8* appVerId, ehs::Version* appVer
if (!response.IsNum())
{
ehs::Console::Clear(); // Clear the console's buffer.
return Main(appName, appVerId, appVer); // Repeat process if given response is not a number.
return main(); // 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::Console::Write("Your age is " + ehs::Str_8::FromNum(age) + "."); // Write the console with the age converted back to string.
ehs::Uninitialize();
return 0;
}
```

View File

@@ -12,7 +12,7 @@ namespace ehs
/// @tparam T Array data type to use.
/// @tparam N Number data type to use.
template<typename T, typename N = UInt_64>
class Array : public BaseObj
class Array
{
protected:
T* data;
@@ -20,7 +20,7 @@ namespace ehs
public:
/// Frees any data created on the heap.
~Array() override
~Array()
{
delete[] data;
}
@@ -29,7 +29,6 @@ namespace ehs
Array()
: data(nullptr), size(0)
{
AddType("Array");
}
/// Initializes an empty array with the given size.
@@ -37,7 +36,6 @@ namespace ehs
explicit Array(const N size)
: data(new T[size]), size(size)
{
AddType("Array");
}
/// Initializes this array with an initializer list object.
@@ -45,8 +43,6 @@ namespace ehs
Array(std::initializer_list<T> list)
: data(new T[list.size()]), size(list.size())
{
AddType("Array");
N i = 0;
for (auto v = list.begin(); v != list.end(); ++v)
data[i++] = std::move(*v);
@@ -58,14 +54,12 @@ namespace ehs
Array(const T* const data, const N size)
: data(new T[size]), size(size)
{
AddType("Array");
for (N i = 0; i < size; ++i)
this->data[i] = data[i];
}
Array(Array&& array) noexcept
: BaseObj(array), data(array.data), size(array.size)
: data(array.data), size(array.size)
{
array.data = nullptr;
array.size = 0;
@@ -74,7 +68,7 @@ namespace ehs
/// Copies all members from the given array object.
/// @param [in] array The array object to copy from.
Array(const Array& array)
: BaseObj((BaseObj&&)array), data(new T[array.size]), size(array.size)
: data(new T[array.size]), size(array.size)
{
for (N i = 0; i < size; ++i)
data[i] = array.data[i];
@@ -85,8 +79,6 @@ namespace ehs
if (this == &array)
return *this;
BaseObj::operator=((BaseObj&&)array);
delete[] data;
data = array.data;
size = array.size;
@@ -105,8 +97,6 @@ namespace ehs
if (this == &array)
return *this;
BaseObj::operator=(array);
delete[] data;
data = new T[array.size];
for (N i = 0; i < array.size; ++i)

View File

@@ -5,20 +5,29 @@
namespace ehs
{
class Base64
class EHS_LIB_IO Base64
{
private:
static const char ascii[];
static constexpr UInt_8 asciiUrl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
static constexpr UInt_8 ascii[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
public:
static Str_8 Encode(const Str_8 input);
static Str_8 EncodeURL(const Str_8 &input);
static Str_8 Decode(const Str_8 input);
static Str_8 Encode(const Str_8 &input);
static Str_8 DecodeURL(const Str_8 &input);
static Str_8 Decode(const Str_8 &input);
private:
static char Find(const char c);
static UInt_8 FindURL(const UInt_8 &c);
static bool IsBase64(const char c);
static UInt_8 Find(const UInt_8 &c);
static bool IsBase64URL(const UInt_8 &c);
static bool IsBase64(const UInt_8 &c);
};
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,7 @@ namespace ehs
{
typedef bool (*GcLogic)(BaseObj*);
class GC
class EHS_LIB_IO GC
{
private:
static Array<GcLogic> logic;
@@ -36,7 +36,7 @@ namespace ehs
/// Sets the maximum amount of garbage to delete per poll.
/// @param[in] newMax The new maximum.
static void SetMax(const UInt_64 newMax);
static void SetMax(UInt_64 newMax);
/// Gets the maximum amount of garbage to delete per poll.
/// @returns The maximum.
@@ -44,7 +44,7 @@ namespace ehs
/// Sets a new amount for memory pre-allocation to save on memory operations.
/// @param[in] newStride The stride to pre-allocate.
static void SetStride(const UInt_64 newStride);
static void SetStride(UInt_64 newStride);
/// The amount of data pre-allocated to save on memory operations.
/// @returns The stride.

View File

@@ -25,7 +25,7 @@ namespace ehs
/// A helper class for holding error information and handling them.
/// @tparam T The character data type to use.
/// @tparam N The number data type to use.
class Log
class EHS_LIB_IO Log
{
private:
static void DefaultRaisedCb(const Log &log);
@@ -63,7 +63,7 @@ namespace ehs
/// @param [in] tags The tags to associate this log with.
/// @param [in] code The unique code to use.
/// @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(LogType type, const Str_8 &tags, UInt_64 code, Str_8 msg);
/// Initializes members with the given information.
/// @param [in] tags The tags to associate this log with.
@@ -134,20 +134,20 @@ namespace ehs
#ifndef EHS_LOG_INT
#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) ehs::Log::Raise(ehs::Log(type, ehs::Str_8(ehs::GetAcronym_8()) + ", " + EHS_FILE + ", " + EHS_FUNC + ", " + ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE), code, msg))
#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) ehs::Log::Raise(ehs::Log(type, ehs::Str_8(ehs::GetAcronym_8()) + ", " + EHS_FUNC, code, msg))
#endif
#endif
#ifndef EHS_LOG
#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(ehs::Log(type, ehs::Str_8(ehs::GetAppName_8()) + ", " + EHS_FILE + ", " + EHS_FUNC + ", " + ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE), code, msg))
#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(ehs::Log(type, ehs::Str_8(ehs::GetAppName_8()) + ", " + EHS_FUNC, code, msg))
#endif
#endif
#ifndef EHS_LOG_SUCCESS
#define EHS_LOG_SUCCESS() ehs::Log::Raise({})
#define EHS_LOG_SUCCESS() ehs::Log::Raise({})
#endif

View File

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

View File

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

View File

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

View File

@@ -6,7 +6,7 @@
namespace ehs
{
class Math
class EHS_LIB_IO Math
{
private:
static float Sqrt_AVX(const float from);
@@ -26,22 +26,22 @@ namespace ehs
constexpr static double dblEpsilon = 1e-16;
/// Absolute tolerance comparison for single precision floats.
static bool AbsCmp(const float a, const float b);
static bool AbsCmp(float a, float b);
/// Absolute tolerance comparison for double precision floats.
static bool AbsCmp(const double a, const double b);
static bool AbsCmp(double a, double b);
/// Relative tolerance comparison for single precision floats.
static bool RelCmp(const float a, const float b);
static bool RelCmp(float a, float b);
/// Relative tolerance comparison for double precision floats.
static bool RelCmp(const double a, const double b);
static bool RelCmp(double a, double b);
/// Combined absolute and relative tolerance comparison for single precision floats.
static bool ComCmp(const float a, const float b);
static bool ComCmp(float a, float b);
/// Combined absolute and relative tolerance comparison for double precision floats.
static bool ComCmp(const double a, const double b);
static bool ComCmp(double a, double b);
template<typename T = float>
static T Max(const T a, const T b)

View File

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

59
include/ehs/SHA256.h Normal file
View File

@@ -0,0 +1,59 @@
#pragma once
#include "Types.h"
namespace ehs
{
class EHS_LIB_IO SHA256
{
private:
static UInt_32 ROTR(UInt_32 x, UInt_32 n);
static UInt_32 CH(UInt_32 x, UInt_32 y, UInt_32 z);
static UInt_32 MAJ(UInt_32 x, UInt_32 y, UInt_32 z);
static UInt_32 EP0(UInt_32 x);
static UInt_32 EP1(UInt_32 x);
static UInt_32 SIG0(UInt_32 x);
static UInt_32 SIG1(UInt_32 x);
static constexpr UInt_32 k[64] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
};
UInt_32 state[8];
UInt_64 bitLen;
Byte data[64];
UInt_64 dataLen;
public:
SHA256();
SHA256(SHA256 &&other) noexcept;
SHA256(const SHA256 &other);
SHA256 &operator=(SHA256 &&other) noexcept;
SHA256 &operator=(const SHA256 &other);
void Update(const Byte *data, UInt_64 len);
void Final(Byte hash[32]);
void Hash(const Byte *data, UInt_64 len, Byte hash[32]);
private:
void Transform(const Byte data[64]);
};
}

View File

@@ -21,7 +21,7 @@
namespace ehs
{
template<typename N = UInt_64>
class Serializer : public BaseObj
class Serializer
{
private:
Endianness endianness;
@@ -30,7 +30,7 @@ namespace ehs
N offset;
public:
~Serializer() override
~Serializer()
{
delete[] data;
}
@@ -38,32 +38,27 @@ namespace ehs
Serializer()
: endianness(Endianness::BE), data(nullptr), size(0), offset(0)
{
AddType("Serializer");
}
Serializer(const Endianness endianness)
: endianness(endianness), data(nullptr), size(0), offset(0)
{
AddType("Serializer");
}
Serializer(const Endianness endianness, const N size)
: endianness(endianness), data(new Byte[size]), size(size), offset(0)
{
AddType("Serializer");
}
Serializer(const Endianness endianness, const Byte* const data, const N size, const N offset = 0)
: endianness(endianness), data(new Byte[size]), size(size), offset(offset)
{
AddType("Serializer");
for (N i = 0; i < size; ++i)
this->data[i] = data[i];
}
Serializer(Serializer&& serializer) noexcept
: BaseObj((BaseObj&&)serializer), endianness(serializer.endianness), data(serializer.data),
: endianness(serializer.endianness), data(serializer.data),
size(serializer.size), offset(serializer.offset)
{
serializer.data = nullptr;
@@ -72,7 +67,7 @@ namespace ehs
}
Serializer(const Serializer& serializer)
: BaseObj(serializer), endianness(serializer.endianness), data(new Byte[serializer.size]),
: endianness(serializer.endianness), data(new Byte[serializer.size]),
size(serializer.size), offset(serializer.offset)
{
for (N i = 0; i < serializer.size; ++i)
@@ -84,8 +79,6 @@ namespace ehs
if (this == &serializer)
return *this;
BaseObj::operator=((Serializer&&)serializer);
endianness = serializer.endianness;
delete[] data;
data = serializer.data;
@@ -104,8 +97,6 @@ namespace ehs
if (this == &serializer)
return *this;
BaseObj::operator=(serializer);
endianness = serializer.endianness;
delete[] data;
@@ -1228,7 +1219,7 @@ namespace ehs
void Resize(const N newSize)
{
Byte* result = new Byte[newSize];
Util::Copy(result, data, size);
Util::Copy(result, data, newSize >= size ? size : newSize);
delete[] data;
data = result;
size = newSize;

View File

@@ -25,7 +25,7 @@ namespace ehs
/// @tparam T The character's data type to use.
/// @tparam N The number data type to use.
template<typename T = Char_8, typename N = UInt_64>
class Str : public BaseObj
class Str
{
private:
N size;
@@ -33,7 +33,7 @@ namespace ehs
public:
/// Frees any data created on the heap.
~Str() override
~Str()
{
delete[] data;
}
@@ -42,22 +42,22 @@ namespace ehs
Str()
: size(0), data(nullptr)
{
AddType("Str");
}
/// Initializes members with given C-style string.
/// @param [in] str The C-style string.
/// @param [in] size The size of the given C-style string.
Str(const T* const str, const N size)
: size((size) ? size : Len(str)), data(nullptr)
: size(size), data(nullptr)
{
if (!size)
return;
data = new T[this->size + 1];
Util::Copy(data, str, Size(true));
data[this->size] = 0;
AddType("Str");
}
/// Initializes members with given C-style string.
@@ -70,8 +70,6 @@ namespace ehs
Util::Copy(data, str, Size(true));
data[size] = 0;
AddType("Str");
}
/// Initializes string with the given size.
@@ -80,13 +78,11 @@ namespace ehs
: size(size), data(new T[size + 1])
{
data[size] = 0;
AddType("Str");
}
/// A move constructor.
Str(Str&& str) noexcept
: BaseObj((BaseObj&&)str), size(str.size), data(str.data)
: size(str.size), data(str.data)
{
str.size = 0;
str.data = nullptr;
@@ -95,7 +91,7 @@ namespace ehs
/// Copies all members from the given string object.
/// @param [in] str The string object to copy from.
Str(const Str& str)
: BaseObj(str), size(str.size), data(new T[size + 1])
: size(str.size), data(new T[size + 1])
{
Util::Copy(data, str.data, Size(true));
@@ -107,8 +103,6 @@ namespace ehs
if (this == &str)
return *this;
BaseObj::operator=((BaseObj&&)str);
size = str.size;
delete[] data;
data = str.data;
@@ -127,8 +121,6 @@ namespace ehs
if (&str == this)
return *this;
BaseObj::operator=(str);
size = str.size;
delete[] data;
@@ -564,7 +556,7 @@ namespace ehs
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.
@@ -580,7 +572,7 @@ namespace ehs
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.
@@ -595,7 +587,7 @@ namespace ehs
return;
}
Util::Copy(data[dstOffset], src, srcSize * sizeof(T));
Util::Copy(&data[dstOffset], src, srcSize * sizeof(T));
}
/// Inserts a string at a specified index.
@@ -747,7 +739,7 @@ namespace ehs
T* result = new T[size + inSize + 1];
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;
@@ -925,10 +917,10 @@ namespace ehs
}
/// Splits a string into a Vector with the given separator.
/// @param [in] ide The given string as the separator.
/// @param [in] delimeter The given string as the separator.
/// @param [in] max The max amount of times to split the string.
/// @returns The resulting string object.
Vector<Str<T, N>, N> Split(const Str<T, N>& ide, const N max = 0) const
Vector<Str<T, N>, N> Split(const Str<T, N>& delimeter, const N max = 0) const
{
Vector<Str<T, N>, N> result(0, 5);
@@ -936,9 +928,9 @@ namespace ehs
for (N i = 0, c = 0; i < size; ++i)
{
if (data[i] == ide[c])
if (data[i] == delimeter[c])
{
if (++c == ide.Size())
if (++c == delimeter.Size())
{
N r = i - (c - 1) - b;
if (!r)
@@ -966,17 +958,17 @@ namespace ehs
}
/// Removes all instances of the ide.
/// @param [in] ide The string to look for.
/// @param [in] delimeter The string to look for.
/// @returns The resulting string object.
Str<T, N> RemoveAll(const Str<T, N>& ide) const
Str<T, N> RemoveAll(const Str<T, N>& delimeter) const
{
Str<T, N> result(size);
for (N i = 0, b = 0, c = 0; i < size; ++i)
{
if (data[i] == ide[c])
if (data[i] == delimeter[c])
{
if (++c == ide.Size())
if (++c == delimeter.Size())
c = 0;
}
else
@@ -995,18 +987,18 @@ namespace ehs
}
/// Replaces all instances of ide with the replacer.
/// @param [in] ide The string to look for.
/// @param [in] delimeter The string to look for.
/// @param [in] replacer The string placed.
/// @returns The resulting string object.
Str ReplaceAll(const Str& ide, const Str& replacer) const
Str ReplaceAll(const Str& delimeter, const Str& replacer) const
{
Str<T, N> result;
for (N i = 0, b = 0; i < size; ++i)
{
if (data[i] == ide[b])
if (data[i] == delimeter[b])
{
if (++b == ide.Size())
if (++b == delimeter.Size())
{
result.Push(replacer);
b = 0;
@@ -1022,20 +1014,20 @@ namespace ehs
}
/// Finds the first instance of the given string object.
/// @param [in] ide The string to look for.
/// @param [in] delimeter The string to look for.
/// @param [out] index The index of the string found. Can be a nullptr.
/// @param [in] pattern The search pattern for optimization.
/// @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.
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> &delimeter, N* const index = nullptr, const SearchPattern pattern = SearchPattern::LEFT_RIGHT, const IndexResult result = IndexResult::BEGINNING) const
{
if (pattern == SearchPattern::LEFT_RIGHT)
{
for (N i = 0, c = 0; i < size; ++i)
{
if (data[i] == ide[c])
if (data[i] == delimeter[c])
{
if (++c == ide.Size())
if (++c == delimeter.Size())
{
if (result == IndexResult::BEGINNING)
{
@@ -1057,16 +1049,16 @@ namespace ehs
}
else if (pattern == SearchPattern::RIGHT_LEFT)
{
for (N i = size, c = ide.Size(); i > 0; --i)
for (N i = size, c = delimeter.Size(); i > 0; --i)
{
if (data[i - 1] == ide[c - 1])
if (data[i - 1] == delimeter[c - 1])
{
if (--c == 0)
{
if (result == IndexResult::BEGINNING)
{
if (index)
*index = i - (ide.Size() - 1);
*index = i - (delimeter.Size() - 1);
return true;
}
@@ -1086,18 +1078,18 @@ namespace ehs
}
/// Checks if the current string contains the given ide.
/// @param [in] ide The given ide to check for.
/// @param [in] delimeter The given ide to check for.
/// @param [in] pattern The search pattern to use.
/// @returns True if the current string does contain the ide.
bool Contains(const Str<T, N>& ide, const SearchPattern pattern = SearchPattern::LEFT_RIGHT) const
bool Contains(const Str<T, N>& delimeter, const SearchPattern pattern = SearchPattern::LEFT_RIGHT) const
{
if (pattern == SearchPattern::LEFT_RIGHT)
{
for (N i = 0, c = 0; i < size; ++i)
{
if (data[i] == ide[c])
if (data[i] == delimeter[c])
{
if (++c == ide.Size())
if (++c == delimeter.Size())
{
return true;
}
@@ -1106,9 +1098,9 @@ namespace ehs
}
else if (pattern == SearchPattern::RIGHT_LEFT)
{
for (N i = size, c = ide.Size(); i > 0; --i)
for (N i = size, c = delimeter.Size(); i > 0; --i)
{
if (data[i - 1] == ide[c - 1])
if (data[i - 1] == delimeter[c - 1])
{
if (--c == 0)
{
@@ -1121,6 +1113,54 @@ namespace ehs
return false;
}
Vector<Str> ParseArgs() const
{
Vector<Str> args;
T *quoteStart = nullptr;
T *spaceStart = nullptr;
for (T *i = data; i <= data + size; ++i)
{
if (*i == '\"' && !spaceStart)
{
if (quoteStart)
{
args.Push(Str(quoteStart, i - quoteStart));
quoteStart = nullptr;
}
else
{
if (i + 1 < &data[size - 1])
quoteStart = i + 1;
else
args.Push({});
}
}
else if (*i == ' ' && !quoteStart)
{
if (spaceStart)
{
args.Push(Str(spaceStart, i - spaceStart));
spaceStart = i + 1;
}
else
{
if (i + 1 < &data[size - 1])
spaceStart = i + 1;
else
args.Push({});
}
}
}
if (quoteStart)
args.Push(Str(quoteStart, &data[size - 1] - (quoteStart - 1)));
else if (spaceStart)
args.Push(Str(spaceStart, &data[size - 1] - (spaceStart - 1)));
return args;
}
/// Checks if the string represents a number. Must not have any alphabetical characters.
/// @returns The result.
bool IsNum() const
@@ -1271,8 +1311,11 @@ namespace ehs
/// @note Use "IsNum" before this if the string object is not guaranteed to be a number.
float ToFloat() const
{
Str<T, N> ide;
ide.Push(46);
N decPoint = size;
Find(".", &decPoint);
Find(ide, &decPoint);
float result = 0.0f;
float fraction = 0.0f;
@@ -1297,8 +1340,11 @@ namespace ehs
/// @note Use "IsNum" before this if the string object is not guaranteed to be a number.
double ToDouble() const
{
Str<T, N> ide;
ide.Push(46);
N decPoint = size;
Find(".", &decPoint);
Find(ide, &decPoint);
double result = 0.0f;
double fraction = 0.0f;
@@ -1323,8 +1369,11 @@ namespace ehs
/// @note Use "IsNum" before this if the string object is not guaranteed to be a number.
long double ToLDouble() const
{
Str<T, N> ide;
ide.Push(46);
N decPoint = size;
Find(".", &decPoint);
Find(ide, &decPoint);
long double result = 0.0f;
long double fraction = 0.0f;
@@ -1679,7 +1728,7 @@ namespace ehs
Str<T, N> result;
if (whole < 0)
result += "-";
result.Push(45);
result += Str<T, N>::FromNum(whole);
@@ -1691,7 +1740,7 @@ namespace ehs
if (!fraction)
return result;
result += ".";
result.Push(46);
Str<T, N> fResult(maxDecimals);
N i = 0;
@@ -1721,7 +1770,7 @@ namespace ehs
Str<T, N> result;
if (whole < 0)
result += "-";
result.Push(45);
result += Str<T, N>::FromNum(whole);
@@ -1733,7 +1782,7 @@ namespace ehs
if (!fraction)
return result;
result += ".";
result.Push(46);
Str<T, N> fResult(maxDecimals);
N i = 0;
@@ -1763,7 +1812,7 @@ namespace ehs
Str<T, N> result;
if (whole < 0)
result += "-";
result.Push(45);
result += Str<T, N>::FromNum(whole);
@@ -1775,7 +1824,7 @@ namespace ehs
if (!fraction)
return result;
result += ".";
result.Push(46);
Str<T, N> fResult(maxDecimals);
N i = 0;
@@ -1870,6 +1919,9 @@ namespace ehs
/// @returns The character count.
static N Len(const T* const str)
{
if (!str)
return 0;
N count = 0;
while (str[count])
++count;
@@ -1888,14 +1940,14 @@ namespace ehs
if (aSize != bSize)
return false;
for (UInt_64 i = 0; i < aSize; ++i)
if (a[i] != b[i])
return false;
return true;
return Util::Compare(a, b, aSize);
}
};
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_16, UInt_64> Str_16;
typedef Str<Char_8, UInt_64> Str_8;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -14,7 +14,7 @@ namespace ehs
/// @tparam N Number data type to use.
/// @note If extra memory is set to five then each time that memory is filled it will add five extra.
template<typename T, typename N = UInt_64>
class Vector : public BaseObj
class Vector
{
protected:
N rawSize;
@@ -24,7 +24,7 @@ namespace ehs
public:
/// Frees any data created on the heap.
~Vector() override
~Vector()
{
delete[] data;
}
@@ -33,7 +33,6 @@ namespace ehs
Vector()
: rawSize(0), size(0), stride(5), data(nullptr)
{
AddType("Vector");
}
/// Initializes members for pre-allocated memory to write to later.
@@ -42,7 +41,6 @@ namespace ehs
Vector(const N size, const N stride)
: rawSize(size + stride), size(size), stride(stride), data(new T[rawSize])
{
AddType("Vector");
}
/// Initializes this vector with an initializer list object.
@@ -51,8 +49,6 @@ namespace ehs
Vector(std::initializer_list<T> list, const N stride = 5)
: rawSize(0), size(list.size()), stride(stride), data(nullptr)
{
AddType("Vector");
if (stride)
{
rawSize = list.size() / stride * stride;
@@ -78,8 +74,6 @@ namespace ehs
Vector(const T* data, const N size, const N stride)
: rawSize(0), size(size), stride(stride), data(nullptr)
{
AddType("Vector");
if (stride)
{
rawSize = size / stride * stride;
@@ -100,14 +94,14 @@ namespace ehs
/// Copies all members from the given vector object.
/// @param [in] vec The vector object to copy from.
Vector(const Vector& vec)
: BaseObj(vec), rawSize(vec.rawSize), size(vec.size), stride(vec.stride), data(new T[rawSize])
: rawSize(vec.rawSize), size(vec.size), stride(vec.stride), data(new T[rawSize])
{
for (N i = 0; i < size; ++i)
data[i] = vec.data[i];
}
Vector(Vector&& vec) noexcept
: BaseObj((BaseObj&&)vec), rawSize(vec.rawSize), size(vec.size), stride(vec.stride), data(vec.data)
: rawSize(vec.rawSize), size(vec.size), stride(vec.stride), data(vec.data)
{
vec.rawSize = 0;
vec.size = 0;
@@ -123,8 +117,6 @@ namespace ehs
if (this == &vec)
return *this;
BaseObj::operator=(vec);
rawSize = vec.rawSize;
size = vec.size;
stride = vec.stride;
@@ -143,8 +135,6 @@ namespace ehs
if (this == &vec)
return *this;
BaseObj::operator=((BaseObj&&)vec);
rawSize = vec.rawSize;
size = vec.size;
stride = vec.stride;
@@ -402,7 +392,7 @@ namespace ehs
{
if (stride)
{
rawSize = (this->size + size()) / stride * stride;
rawSize = (this->size + size) / stride * stride;
if ((this->size + size) % stride)
rawSize += stride;
}
@@ -413,7 +403,7 @@ namespace ehs
T* result = new T[rawSize];
for (N i = 0; i < size; ++i)
for (N i = 0; i < this->size; ++i)
result[i] = std::move(data[i]);
delete[] data;

View File

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

View File

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

View File

@@ -7,7 +7,7 @@ namespace ehs
{
class DbTable;
class DbObject
class EHS_LIB_IO DbObject
{
private:
friend class DbTable;

View File

@@ -10,7 +10,7 @@ namespace ehs
{
class Database;
class DbTable
class EHS_LIB_IO DbTable
{
private:
friend class Database;

View File

@@ -8,7 +8,7 @@ namespace ehs
class DbVarTmpl;
class DbObject;
class DbVar
class EHS_LIB_IO DbVar
{
private:
friend class DbObject;

View File

@@ -8,7 +8,7 @@ namespace ehs
{
class DbVar;
class DbVarTmpl
class EHS_LIB_IO DbVarTmpl
{
private:
friend class DbTable;

View File

@@ -5,7 +5,7 @@
namespace ehs
{
class BaseDirectory
class EHS_LIB_IO BaseDirectory
{
public:
static Array<Str_8> GetAllFiles(const Str_8 &dir);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,7 +3,7 @@
#include "ehs/system/OS.h"
#if defined(EHS_OS_WINDOWS)
#include "Directory_W32.h"
#include "Directory_W32.h"
#elif defined(EHS_OS_LINUX)
#include "Directory_LNX.h"
#include "Directory_LNX.h"
#endif

View File

@@ -4,7 +4,7 @@
namespace ehs
{
class Directory : public BaseDirectory
class EHS_LIB_IO Directory : public BaseDirectory
{
public:
static Array<Str_8> GetAllFiles(const Str_8 &dir);

View File

@@ -0,0 +1,16 @@
#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

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -7,7 +7,7 @@
namespace ehs
{
class Glyph
class EHS_LIB_IO Glyph
{
private:
Char_32 code;

View File

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

View File

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

View File

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

View File

@@ -4,7 +4,7 @@
namespace ehs
{
class UsbBase
class EHS_LIB_IO UsbBase
{
private:
UInt_32 bus;

View File

@@ -5,7 +5,7 @@
namespace ehs
{
class Usb final : public UsbBase
class EHS_LIB_IO Usb final : public UsbBase
{
private:
int hdl;

View File

@@ -14,7 +14,7 @@
namespace ehs
{
class Window : public BaseWindow
class EHS_LIB_IO Window : public BaseWindow
{
private:
UInt_32 owner;
@@ -71,13 +71,6 @@ namespace ehs
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.
/// @returns The window's native handle.
HWND GetHdl() const;

View File

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

View File

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

View File

@@ -11,7 +11,7 @@
namespace ehs
{
class Audio : public Resource
class EHS_LIB_IO Audio : public Resource
{
private:
static Array<AudioCodec> codecs;
@@ -81,10 +81,14 @@ namespace ehs
UInt_64 GetSampleCount() const;
UInt_8 GetFrameSize() const;
UInt_64 GetSize() const;
float GetLength() const;
Byte* GetFrame(UInt_64 frameIndex) const;
Array<Byte> FrameAsMono(UInt_64 frameIndex) const;
Array<Byte> FrameAsStereo(UInt_64 frameIndex) const;

View File

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

View File

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

View File

@@ -1,46 +0,0 @@
#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

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -6,11 +6,11 @@
namespace ehs
{
class Input
class EHS_LIB_IO Input
{
private:
Array<InputHandler*> handlers;
bool initalized;
bool initialized;
public:
~Input();
@@ -31,13 +31,13 @@ namespace ehs
void Poll();
bool HasHandler(const UInt_64 hashId) const;
bool HasHandler(UInt_64 hashId) const;
bool HasHandler(const Str_8& id) const;
bool AddHandler(InputHandler* handler);
const InputHandler* GetHandler(const UInt_64 hashId) const;
const InputHandler* GetHandler(UInt_64 hashId) const;
const InputHandler* GetHandler(const Str_8& id) const;

View File

@@ -5,11 +5,13 @@
namespace ehs
{
class InputHandler
class EHS_LIB_IO InputHandler
{
private:
UInt_64 hashId;
Str_8 id;
UInt_64 start;
UInt_64 delta;
protected:
Array<HID*> devices;
@@ -29,9 +31,9 @@ namespace ehs
InputHandler& operator=(const InputHandler& ih);
bool operator==(const UInt_64 otherHashId);
bool operator==(UInt_64 otherHashId) const;
bool operator!=(const UInt_64 otherHashId);
bool operator!=(UInt_64 otherHashId) const;
virtual bool Initialize();
@@ -45,13 +47,13 @@ namespace ehs
void ResetAllStates();
bool HasDevice(const UInt_64 id) const;
bool HasDevice(UInt_64 id) const;
bool AddDevice(HID* device);
HID* GetDevice(const UInt_64 id) const;
HID* GetDevice(UInt_64 id) const;
HID* GetDeviceByType(const UInt_8 type) const;
HID* GetDeviceByType(UInt_8 type) const;
virtual bool IsInitialized() const;
};

View File

@@ -8,7 +8,7 @@
namespace ehs
{
class Keyboard : public HID
class EHS_LIB_IO Keyboard : public HID
{
public:
Keyboard();
@@ -23,96 +23,96 @@ namespace ehs
Keyboard& operator=(const Keyboard& hid);
void Poll() override;
void Poll(float delta) override;
Keyboard* Clone() const override;
static const Button Unknown;
static const Button Escape;
static const Button Backspace;
static const Button Enter;
static const Button LShift;
static const Button RShift;
static const Button LAlt;
static const Button RAlt;
static const Button LCtrl;
static const Button RCtrl;
static const Button Space;
static const Button A;
static const Button B;
static const Button C;
static const Button D;
static const Button E;
static const Button F;
static const Button G;
static const Button H;
static const Button I;
static const Button J;
static const Button K;
static const Button L;
static const Button M;
static const Button N;
static const Button O;
static const Button P;
static const Button Q;
static const Button R;
static const Button S;
static const Button T;
static const Button U;
static const Button V;
static const Button W;
static const Button X;
static const Button Y;
static const Button Z;
static const Button One;
static const Button Two;
static const Button Three;
static const Button Four;
static const Button Five;
static const Button Six;
static const Button Seven;
static const Button Eight;
static const Button Nine;
static const Button Zero;
static const Button Minus;
static const Button Equals;
static const Button Tilde;
static const Button BackSlash;
static const Button LeftSquareBracket;
static const Button RightSquareBracket;
static const Button SemiColon;
static const Button Apostrophe;
static const Button Comma;
static const Button Period;
static const Button ForwardSlash;
static const Button F1;
static const Button F2;
static const Button F3;
static const Button F4;
static const Button F5;
static const Button F6;
static const Button F7;
static const Button F8;
static const Button F9;
static const Button F10;
static const Button F11;
static const Button F12;
static const Button F13;
static const Button F14;
static const Button F15;
static const Button F16;
static const Button F17;
static const Button F18;
static const Button F19;
static const Button F20;
static const Button F21;
static const Button F22;
static const Button F23;
static const Button F24;
static const Button Left;
static const Button Right;
static const Button Up;
static const Button Down;
static inline const Button Unknown = Button("Unknown");
static inline const Button Escape = Button("Escape Button");
static inline const Button Backspace = Button("Backspace Button");
static inline const Button Enter = Button("Enter Button");
static inline const Button LShift = Button("Left Shift Button");
static inline const Button RShift = Button("Right Shift Button");
static inline const Button LAlt = Button("Left Alt Button");
static inline const Button RAlt = Button("Right Alt Button");
static inline const Button LCtrl = Button("Left Control Button");
static inline const Button RCtrl = Button("Right Button");
static inline const Button Space = Button("Space Button");
static inline const Button A = Button("A Button");
static inline const Button B = Button("B Button");
static inline const Button C = Button("C Button");
static inline const Button D = Button("D Button");
static inline const Button E = Button("E Button");
static inline const Button F = Button("F Button");
static inline const Button G = Button("G Button");
static inline const Button H = Button("H Button");
static inline const Button I = Button("I Button");
static inline const Button J = Button("J Button");
static inline const Button K = Button("K Button");
static inline const Button L = Button("L Button");
static inline const Button M = Button("M Button");
static inline const Button N = Button("N Button");
static inline const Button O = Button("O Button");
static inline const Button P = Button("P Button");
static inline const Button Q = Button("Q Button");
static inline const Button R = Button("R Button");
static inline const Button S = Button("S Button");
static inline const Button T = Button("T Button");
static inline const Button U = Button("U Button");
static inline const Button V = Button("V Button");
static inline const Button W = Button("W Button");
static inline const Button X = Button("X Button");
static inline const Button Y = Button("Y Button");
static inline const Button Z = Button("Z Button");
static inline const Button One = Button("One Button");
static inline const Button Two = Button("Two Button");
static inline const Button Three = Button("Three Button");
static inline const Button Four = Button("Four Button");
static inline const Button Five = Button("Five Button");
static inline const Button Six = Button("Six Button");
static inline const Button Seven = Button("Seven Button");
static inline const Button Eight = Button("Eight Button");
static inline const Button Nine = Button("Nine Button");
static inline const Button Zero = Button("Zero Button");
static inline const Button Minus = Button("Minus Button");
static inline const Button Equals = Button("Equals Button");
static inline const Button Tilde = Button("Tilde Button");
static inline const Button BackSlash = Button("Back Slash Button");
static inline const Button LeftSquareBracket = Button("Left Square Bracket Button");
static inline const Button RightSquareBracket = Button("Right Square Bracket Button");
static inline const Button SemiColon = Button("Semi Colon Button");
static inline const Button Apostrophe = Button("Apostrophe Button");
static inline const Button Comma = Button("Comma Button");
static inline const Button Period = Button("Period Button");
static inline const Button ForwardSlash = Button("Forward Slash Button");
static inline const Button F1 = Button("Function One Button");
static inline const Button F2 = Button("Function Two Button");
static inline const Button F3 = Button("Function Three Button");
static inline const Button F4 = Button("Function Four Button");
static inline const Button F5 = Button("Function Five Button");
static inline const Button F6 = Button("Function Six Button");
static inline const Button F7 = Button("Function Seven Button");
static inline const Button F8 = Button("Function Eight Button");
static inline const Button F9 = Button("Function Nine Button");
static inline const Button F10 = Button("Function Ten Button");
static inline const Button F11 = Button("Function Eleven Button");
static inline const Button F12 = Button("Function Twelve Button");
static inline const Button F13 = Button("Function Thirteen Button");
static inline const Button F14 = Button("Function Fourteen Button");
static inline const Button F15 = Button("Function Fifteen Button");
static inline const Button F16 = Button("Function Sixteen Button");
static inline const Button F17 = Button("Function Seventeen Button");
static inline const Button F18 = Button("Function Eighteen Button");
static inline const Button F19 = Button("Function Nineteen Button");
static inline const Button F20 = Button("Function Twenty Button");
static inline const Button F21 = Button("Function Twenty One Button");
static inline const Button F22 = Button("Function Twenty Two Button");
static inline const Button F23 = Button("Function Twenty Three Button");
static inline const Button F24 = Button("Function Twenty Four Button");
static inline const Button Left = Button("Left Button");
static inline const Button Right = Button("Right Button");
static inline const Button Up = Button("Up Button");
static inline const Button Down = Button("Down Button");
static Button TranslateScanCode(UInt_32 code);

View File

@@ -9,7 +9,7 @@
namespace ehs
{
class Mouse : public HID
class EHS_LIB_IO Mouse : public HID
{
private:
friend class Input;
@@ -19,7 +19,7 @@ namespace ehs
public:
Mouse();
Mouse(Str_8 name, const UInt_64 id);
Mouse(Str_8 name, UInt_64 id);
Mouse(Mouse&& hid) noexcept = default;
@@ -29,7 +29,7 @@ namespace ehs
Mouse& operator=(const Mouse& hid);
void Poll() override;
void Poll(float delta) override;
void SetDelta(const Vec2_s32& newDelta);
@@ -37,18 +37,18 @@ namespace ehs
Mouse* Clone() const override;
static const Button Unknown;
static const Button LMB;
static const Button MMB;
static const Button RMB;
static const Button Four;
static const Button Five;
static const Button ScrollUp;
static const Button ScrollDown;
static const Button ScrollLeft;
static const Button ScrollRight;
static const Button Back;
static const Button Forward;
static inline const Button Unknown = Button("Unknown Button");
static inline const Button LMB = Button("Left Mouse Button");
static inline const Button MMB = Button("Middle Mouse Button");
static inline const Button RMB = Button("Right Mouse Button");
static inline const Button Four = Button("Four Button");
static inline const Button Five = Button("Five Button");
static inline const Button ScrollUp = Button("Scroll Up Button");
static inline const Button ScrollDown = Button("Scroll Down Button");
static inline const Button ScrollLeft = Button("Scroll Left Button");
static inline const Button ScrollRight = Button("Scroll Right Button");
static inline const Button Back = Button("Back Button");
static inline const Button Forward = Button("Forward Button");
static Button TranslateXCB(const UInt_32 code);
};

View File

@@ -13,7 +13,7 @@ namespace ehs
NEAREST_NEIGHBOR
};
class Img : public BaseObj
class EHS_LIB_IO Img : public BaseObj
{
private:
static Array<ImgCodec> codecs;

View File

@@ -12,7 +12,7 @@ namespace ehs
typedef bool (*EncodeImgCb)(const ImgCodec* const, Serializer<UInt_64>&, const Img*);
typedef bool (*DecodeImgCb)(const ImgCodec* const, Serializer<UInt_64>&, Img*);
class ImgCodec
class EHS_LIB_IO ImgCodec
{
private:
Str_8 id;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -15,7 +15,7 @@ namespace ehs
EHM
};
class Mdl : public BaseObj
class EHS_LIB_IO Mdl : public BaseObj
{
private:
static Array<MdlCodec> codecs;

View File

@@ -12,7 +12,7 @@ namespace ehs
typedef bool (*EnocdeMdlCb)(const MdlCodec*, Serializer<UInt_64>&, const Mdl*);
typedef bool (*DecodeMdlCb)(const MdlCodec*, Serializer<UInt_64>&, Mdl*);
class MdlCodec
class EHS_LIB_IO MdlCodec
{
private:
Str_8 id;

View File

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

View File

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

View File

@@ -0,0 +1,18 @@
#pragma once
#include "Socket.h"
#include "ehs/Str.h"
namespace ehs
{
class EHS_LIB_IO BaseDNS
{
public:
static Str_8 Resolve(IP 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

@@ -0,0 +1,68 @@
#pragma once
#include "ehs/Serializer.h"
#include "ehs/Types.h"
#include "ehs/io/socket/Socket.h"
namespace ehs
{
struct ICMP_Header
{
UInt_8 type;
UInt_8 code;
UInt_16 checksum;
};
struct ICMP_EchoRequest
{
UInt_16 id;
UInt_16 sequence;
};
class BaseICMP
{
private:
IP version;
public:
virtual ~BaseICMP() = default;
BaseICMP();
BaseICMP(IP version);
BaseICMP(BaseICMP &&icmp) noexcept;
BaseICMP(const BaseICMP &icmp);
BaseICMP &operator=(BaseICMP &&icmp) noexcept;
BaseICMP &operator=(const BaseICMP &icmp);
virtual void Release();
UInt_64 Send(const Str_8 &address, ICMP_Header header, const Byte *data, UInt_64 size);
UInt_64 Receive(Str_8 &address, ICMP_Header &header, Serializer<UInt_64> &data);
void SendEchoRequest(const Str_8 &address, ICMP_EchoRequest er, const Byte *data, UInt_64 size);
virtual void SetReceiveTimeout(UInt_64 timeout);
IP GetVersion() const;
virtual bool IsValid() const;
protected:
static UInt_16 ComputeChecksumV4(UInt_16 *buffer, Size length);
private:
virtual UInt_64 SendV6(const Str_8 &address, ICMP_Header header, const Byte *data, UInt_64 size);
virtual UInt_64 SendV4(const Str_8 &address, ICMP_Header header, const Byte *data, UInt_64 size);
virtual UInt_64 ReceiveV6(Str_8 &address, ICMP_Header &header, Serializer<UInt_64> &data) const;
virtual UInt_64 ReceiveV4(Str_8 &address, ICMP_Header &header, Serializer<UInt_64> &data) const;
};
}

View File

@@ -9,10 +9,10 @@
namespace ehs
{
class BaseTCP
class EHS_LIB_IO BaseTCP
{
protected:
AddrType addrType;
IP ip;
Str_8 localAddr;
UInt_16 localPort;
Str_8 remoteHostName;
@@ -24,9 +24,9 @@ namespace ehs
bool connected;
public:
static const UInt_16 HTTPS_Port = 443;
static const UInt_16 HTTP_Port = 80;
static const UInt_16 MaxHeaderSize = 8192;
static constexpr UInt_16 HTTPS_Port = 443;
static constexpr UInt_16 HTTP_Port = 80;
static constexpr UInt_16 MaxHeaderSize = 8192;
virtual ~BaseTCP() = default;
@@ -35,7 +35,7 @@ namespace ehs
/// Properly initializes the socket.
/// @param [in] type The ip version to initialize the socket with.
BaseTCP(AddrType addrType);
BaseTCP(IP ip);
BaseTCP(BaseTCP&& tcp) noexcept;
@@ -55,7 +55,7 @@ namespace ehs
/// @param [in] address The ip address to bind to.
/// @param [in] port The port to bind to.
/// @note Used for servers.
virtual void Bind(const Str_8& address, UInt_16 port) = 0;
virtual void Bind(Str_8 address, const UInt_16 &port) = 0;
/// Listens for new incoming connections.
/// @note Used for servers.
@@ -63,13 +63,13 @@ namespace ehs
/// Accepts the new incoming connection.
/// @note Used for servers.
virtual BaseTCP* Accept() = 0;
virtual BaseTCP *Accept() = 0;
/// Connects to a server at the specified address and port.
/// @param [in] address The ip address to connect to.
/// @param [in] port The port to connect to.
/// @note Used for clients.
virtual void Connect(const Str_8& address, UInt_16 port) = 0;
virtual void Connect(Str_8 address, const UInt_16 &port) = 0;
/// Sends data to the connected endpoint.
/// @param [in] buffer The data to send to the endpoint.
@@ -104,7 +104,7 @@ namespace ehs
/// Retrieves the sockets ip version.
/// @returns The ip version.
AddrType GetAddressType() const;
IP GetAddressType() const;
/// Retrieves the bound ip address.
/// @returns The ip address.
@@ -146,6 +146,12 @@ namespace ehs
/// @returns The result.
virtual bool IsBlocking() const = 0;
virtual void SetIPv6Only(bool value) = 0;
virtual bool IsIPv6Only() const = 0;
virtual void SetReuse(const bool &enabled) = 0;
/// Retrieves whether or not this socket was initialized.
/// @returns The result.
virtual bool IsValid() const = 0;

View File

@@ -6,12 +6,10 @@
namespace ehs
{
class BaseUDP
class EHS_LIB_IO BaseUDP
{
protected:
AddrType type;
Str_8 address;
UInt_16 port;
Endpoint localEndpoint;
bool bound;
public:
@@ -22,7 +20,7 @@ namespace ehs
/// Properly initializes the socket.
/// @param [in] type The ip version to initialize the socket with.
BaseUDP(AddrType type);
BaseUDP(IP version);
BaseUDP(BaseUDP&& udp) noexcept;
@@ -40,13 +38,13 @@ namespace ehs
/// @param [in] address The ip address to bind to.
/// @param [in] port The port to bind to.
/// @note Used for servers.
virtual void Bind(AddrType type, const Str_8& address, UInt_16 port) = 0;
virtual void Bind(const Endpoint &endpoint) = 0;
/// Sends data to the endpoint.
/// @param [in] type The ip version of the endpoint.
/// @param [in] address The ip address of the endpoint.
/// @param [in] port The port of the endpoint is bound to.
virtual UInt_64 Send(AddrType type, const Str_8& address, UInt_16 port, const Byte* data, UInt_64 size) = 0;
virtual UInt_64 Send(const Endpoint &endpoint, const Byte *data, UInt_64 size) = 0;
/// Receives data from the endpoint.
/// @param [out] type The ip version of the endpoint.
@@ -55,7 +53,7 @@ namespace ehs
/// @param [out] data The incoming data from the endpoint.
/// @param [in] size The max size of the buffer in bytes to store the data.
/// @returns The size of the incoming data in bytes.
virtual UInt_64 Receive(AddrType* type, Str_8* address, UInt_16* port, Byte* data, UInt_64 size) = 0;
virtual UInt_64 Receive(Endpoint *endpoint, Byte *data, UInt_64 size) = 0;
/// Retrieves whether or not this socket is bound to an ip address and port.
/// @returns The result.
@@ -69,17 +67,11 @@ namespace ehs
/// @returns The result.
virtual bool IsBlocking() const = 0;
/// Retrieves the bound ip version.
/// @returns The result.
AddrType GetLocalAddressType() const;
virtual void SetIPv6Only(bool value) = 0;
/// Retrieves the bound ip address.
/// @returns The bound ip address.
Str_8 GetLocalAddress() const;
virtual bool IsIPv6Only() const = 0;
/// Retrieves the bound port.
/// @returns The bound port.
UInt_16 GetLocalPort() const;
Endpoint GetLocalEndpoint() const;
/// Retrieves whether or not this socket was initialized.
/// @returns The result.

View File

@@ -1,17 +1,9 @@
#pragma once
#include "ehs/EHS.h"
#include "ehs/Str.h"
#include "Socket.h"
#include "ehs/system/OS.h"
namespace ehs
{
class DNS
{
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);
};
}
#if defined(EHS_OS_WINDOWS)
#include "DNS_W32.h"
#elif defined(EHS_OS_LINUX)
#include "DNS_LNX.h"
#endif

View File

@@ -0,0 +1,17 @@
#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(IP type, const Str_8 &hostname);
static Str_8 Resolve(const Str_8 &hostname);
};
}

View File

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

View File

@@ -0,0 +1,95 @@
#pragma once
#include "ehs/io/socket/ehc/NetEnc.h"
#include "ehs/Array.h"
#include "Socket.h"
#include "UDP.h"
namespace ehs
{
class NetServerCh;
class NetClientCh;
class NetEnd;
class EHC;
class EHC
{
private:
friend class NetEnc;
friend class NetChannel;
friend class NetServerCh;
friend class NetClientCh;
friend class NetEnd;
static const Version version;
UDP udp;
Byte* buffer;
UInt_32 bufferSize;
UInt_64 lastTSC;
float delta;
Array<NetEnc *> encryptions;
Array<NetServerCh *> servers;
Array<NetClientCh *> clients;
public:
~EHC();
EHC(IP version = IP::V6);
EHC(EHC &&sock) noexcept;
EHC(const EHC &sock);
EHC &operator=(EHC&& sock) noexcept;
EHC &operator=(const EHC &sock);
void Initialize();
void Release();
void Bind(const Endpoint &endpoint);
void Poll();
bool IsInitialized() const;
Endpoint GetLocalEndpoint() const;
bool IsBound() const;
static Version GetVersion();
bool AddEncryption(NetEnc *enc);
bool HasServer(UInt_64 serverId) const;
bool HasServer(const Str_8& serverName) const;
bool AddServer(NetServerCh *server);
NetServerCh *GetServer(UInt_64 serverId) const;
NetServerCh *GetServer(const Str_8& serverName) const;
bool HasClient(UInt_64 clientId) const;
bool HasClient(const Str_8& clientName) const;
bool AddClient(NetClientCh *channel);
NetClientCh *GetClient(UInt_64 clientId) const;
NetClientCh *GetClient(const Str_8& clientName) const;
private:
bool HasEncryption(UInt_64 encId) const;
bool HasEncryption(const Str_8& encName) const;
NetEnc* GetEncryption(UInt_64 encId) const;
NetEnc* GetEncryption(const Str_8& encName) const;
};
}

View File

@@ -0,0 +1,45 @@
#pragma once
#include "ehs/Str.h"
namespace ehs
{
class HeaderVar
{
private:
UInt_64 id;
Str_8 name;
Str_8 value;
public:
HeaderVar();
HeaderVar(Str_8 name, Str_8 value);
HeaderVar(HeaderVar &&other) noexcept;
HeaderVar(const HeaderVar &other);
HeaderVar &operator=(HeaderVar &&other) noexcept;
HeaderVar &operator=(const HeaderVar &other);
bool operator==(const HeaderVar &other) const;
bool operator!=(const HeaderVar &other) const;
bool operator==(const UInt_64 &otherId) const;
bool operator!=(const UInt_64 &otherId) const;
UInt_64 GetId() const;
Str_8 GetName() const;
Str_8 GetValue() const;
void SetValue(Str_8 value);
Str_8 ToStr() const;
};
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include "ehs/system/OS.h"
#ifdef EHS_OS_WINDOWS
#include "ICMP_W32.h"
#else
#include "ICMP_LNX.h"
#endif

View File

@@ -0,0 +1,60 @@
#pragma once
#include "BaseICMP.h"
#include <netinet/in.h>
namespace ehs
{
struct PseudoICMPv6_Header
{
sockaddr_in6 src;
sockaddr_in6 dst;
UInt_32 length;
};
class ICMP final : public BaseICMP
{
private:
Int_32 hdl;
sockaddr_in6 src;
public:
~ICMP() override;
ICMP();
ICMP(IP version);
ICMP(ICMP &&icmp) noexcept;
ICMP(const ICMP &icmp);
ICMP &operator=(ICMP &&icmp) noexcept;
ICMP &operator=(const ICMP &icmp);
void Release() override;
void SetReceiveTimeout(UInt_64 timeout) override;
bool IsValid() const override;
private:
static bool IsLinkLocal(const in6_addr &addr);
static sockaddr_in6 RetrieveSrcAddress();
static UInt_32 CalculatePseudoHeaderChecksum(const PseudoICMPv6_Header &header);
UInt_16 ComputeChecksumV6(UInt_16* buffer, Size length, const sockaddr_in6& dst);
UInt_64 SendV6(const Str_8 &address, ICMP_Header header, const Byte *data, UInt_64 size) override;
UInt_64 SendV4(const Str_8 &address, ICMP_Header header, const Byte *data, UInt_64 size) override;
UInt_64 ReceiveV6(Str_8 &address, ICMP_Header &header, Serializer<UInt_64> &data) const override;
UInt_64 ReceiveV4(Str_8 &address, ICMP_Header &header, Serializer<UInt_64> &data) const override;
};
}

View File

@@ -0,0 +1,63 @@
#pragma once
#include "BaseICMP.h"
#include "ehs/System/OS.h"
#include <winsock2.h>
#include <WS2tcpip.h>
#include <iphlpapi.h>
namespace ehs
{
struct PseudoICMPv6_Header
{
sockaddr_in6 src;
sockaddr_in6 dst;
UInt_32 length;
};
class ICMP : public BaseICMP
{
private:
Socket hdl;
sockaddr_in6 src;
public:
~ICMP() override;
ICMP();
ICMP(IP version);
ICMP(ICMP &&icmp) noexcept;
ICMP(const ICMP &icmp);
ICMP &operator=(ICMP &&icmp) noexcept;
ICMP &operator=(const ICMP &icmp);
void Release() override;
void SetReceiveTimeout(UInt_64 timeout) override;
bool IsValid() const override;
private:
static bool IsLinkLocal(const in6_addr &addr);
static sockaddr_in6 RetrieveSrcAddress();
static UInt_32 CalculatePseudoHeaderChecksum(const PseudoICMPv6_Header &header);
UInt_16 ComputeChecksumV6(UInt_16* buffer, Size length, const sockaddr_in6& dst);
UInt_64 SendV6(const Str_8 &address, ICMP_Header header, const Byte *data, UInt_64 size) override;
UInt_64 SendV4(const Str_8 &address, ICMP_Header header, const Byte *data, UInt_64 size) override;
UInt_64 ReceiveV6(Str_8 &address, ICMP_Header &header, Serializer<UInt_64> &data) const override;
UInt_64 ReceiveV4(Str_8 &address, ICMP_Header &header, Serializer<UInt_64> &data) const override;
};
}

View File

@@ -0,0 +1,45 @@
#pragma once
#include "ehs/Str.h"
namespace ehs
{
class QueryVar
{
private:
UInt_64 id;
Str_8 name;
Str_8 value;
public:
QueryVar();
QueryVar(Str_8 name, Str_8 value);
QueryVar(QueryVar &&other) noexcept;
QueryVar(const QueryVar &other);
QueryVar &operator=(QueryVar &&other) noexcept;
QueryVar &operator=(const QueryVar &other);
bool operator==(const QueryVar &other) const;
bool operator!=(const QueryVar &other) const;
bool operator==(const UInt_64 &otherId) const;
bool operator!=(const UInt_64 &otherId) const;
UInt_64 GetId() const;
Str_8 GetName() const;
Str_8 GetValue() const;
void SetValue(Str_8 value);
Str_8 ToStr() const;
};
}

View File

@@ -5,6 +5,8 @@
#include "ehs/Str.h"
#include "ehs/json/Json.h"
#include "Socket.h"
#include "QueryVar.h"
#include "HeaderVar.h"
namespace ehs
{
@@ -16,13 +18,13 @@ namespace ehs
DEL
};
class Request
class EHS_LIB_IO Request
{
private:
Verb verb;
Str_8 rsrc;
Vector<Str_8> queries;
Vector<Str_8> header;
Vector<QueryVar> queries;
Vector<HeaderVar> header;
ContentType cType;
Str_8 body;
@@ -33,25 +35,34 @@ namespace ehs
/// Initializes this request with a given verb and URI resource.
/// @param [in] verb The type of request to make.
/// @param [in] rsrc The URI endpoint to make the request at.
Request(const Verb verb, const Str_8& rsrc);
Request(const Verb &verb, Str_8 rsrc);
/// Initializes this request with the raw request data.
/// @param [in] data The C-style string of the request.
/// @param [in] size The size of the given C-style string.
Request(const char* data, const UInt_64 size);
Request(const char *data, const UInt_64 &size);
/// Initializes this request with the raw request data.
/// @param [in] data The string of the request.
Request(const Str_8& data);
Request(const Str_8 &data);
/// Moves members from another object of the same type.
/// @param [in] other The object to move from.
Request(Request &&other) noexcept;
/// Copies members from another object of the same type.
/// @param [in] req The object to copy from.
Request(const Request& req) = default;
/// @param [in] other The object to copy from.
Request(const Request &other);
/// Moves members from another object of the same type.
/// @param [in] other The object to move from.
/// @returns The request that has been assigned to.
Request& operator=(Request &&other) noexcept;
/// Copies members from another object of the same type.
/// @param [in] req The object to copy from.
/// @param [in] other The object to copy from.
/// @returns The request that has been assigned to.
Request& operator=(const Request& req);
Request& operator=(const Request &other);
/// Retrieves the verb for the request.
/// @returns The result.
@@ -59,7 +70,7 @@ namespace ehs
/// Sets the content type for the body.
/// @param [in] cType The content type to use.
void SetContentType(const ContentType cType);
void SetContentType(const ContentType &cType);
/// Retrieves the content type for the body.
/// @returns The result.
@@ -67,75 +78,145 @@ namespace ehs
/// Sets the URI resource.
/// @param [in] rsrc The resource.
void SetResource(const Str_8& rsrc);
void SetResource(Str_8 rsrc);
/// Retrieves the URI resource.
/// @returns The result.
Str_8 GetResource() const;
/// Adds a query variable to the URI.
/// @param [in] var The variable identifier.
/// @param [in] value The value of the variable.
void AddQuery(const Str_8& var, const Str_8& value);
/// Checks whether a header variable exists using the id.
/// @param [in] id The variable id to look for.
/// @returns True if the variable exists. False otherwise.
bool HasQueryVar(const UInt_64 &id) const;
/// Retrieves a query variable from the URI.
/// @param [in] var The variable identifier to look for.
/// @returns The value of the query variable. Empty if it was not found.
Str_8 GetQuery(const Str_8& var);
/// Checks whether a header variable exists using the name.
/// @param [in] name The variable name to look for.
/// @returns True if the variable exists. False otherwise.
bool HasQueryVar(const Str_8 &name) const;
/// Adds a header variable.
/// @param [in] var The variable to add to the header.
/// @returns False if the given variable name already exists. True otherwise.
bool AddQueryVar(QueryVar var);
/// Removes a header variable using the id.
/// @param [in] id The variable id to look for.
/// @returns True if the variable was found. False otherwise.
bool RemoveQueryVar(const UInt_64 &id);
/// Removes a header variable using the name.
/// @param [in] name The variable name to look for.
/// @returns True if the variable was found. False otherwise.
bool RemoveQueryVar(const Str_8 &name);
/// Retrieves a header variable using the id.
/// @param [in] id The variable id to look for.
/// @returns The variable object if found. Nullptr otherwise.
QueryVar *GetQueryVar(const UInt_64 &id) const;
/// Retrieves a header variable using the name.
/// @param [in] name The variable name to look for.
/// @returns The variable object if found. Nullptr otherwise.
QueryVar *GetQueryVar(const Str_8& name) const;
/// Retrieves a header variable value using the id.
/// @param [in] id The variable id to look for.
/// @returns The variable's value if found. Empty otherwise.
Str_8 GetQueryValue(const UInt_64 &id) const;
/// Retrieves a header variable value using the name.
/// @param [in] name The variable name to look for.
/// @returns The variable's value if found. Empty otherwise.
Str_8 GetQueryValue(const Str_8& name) const;
/// Retrieves all the query variables from the URI in a vector object.
/// @returns The result.
Vector<Str_8> GetQueries() const;
Vector<QueryVar> GetQueries() const;
/// A helper method to automatically add the required header variables for basic authentication.
/// @param [in] id The username or id.
/// @param [in] secret The secret given by an API.
void BasicAuth(const Str_8& id, const Str_8& secret);
void BasicAuth(const Str_8 &id, const Str_8 &secret);
/// A helper method to automatically add the required header variables for bearer authentication.
/// @param [in] token The token given by an API.
void BearerAuth(const Str_8& token);
void BearerAuth(const Str_8 &token);
/// A helper method to automatically add the required header variables for bearer authentication.
/// @param [in] token The token given by an API.
/// @param [in] clientId The client id given by an API.
void BearerAuth(const Str_8& token, const Str_8& clientId);
void BearerAuth(const Str_8 &token, const Str_8 &clientId);
/// A helper method to automatically add the required header variables for bot authentication.
/// @param [in] token The token given by an API.
void BotAuth(const Str_8& token);
void BotAuth(const Str_8 &token);
/// Checks whether a header variable exists using the id.
/// @param [in] id The variable id to look for.
/// @returns True if the variable exists. False otherwise.
bool HasHeaderVar(const UInt_64 &id) const;
/// Checks whether a header variable exists using the name.
/// @param [in] name The variable name to look for.
/// @returns True if the variable exists. False otherwise.
bool HasHeaderVar(const Str_8 &name) const;
/// Adds a header variable.
/// @param [in] var The variable identifier.
/// @param [in] value The value of the variable.
void AddToHeader(const Str_8& var, const Str_8& value);
/// @param [in] var The variable to add to the header.
/// @returns False if the given variable name already exists. True otherwise.
bool AddHeaderVar(HeaderVar var);
/// Retrieves a header variable.
/// @param [in] var The variable identifier to look for.
/// @returns The value of the header variable. Empty if it was not found.
Str_8 GetHeader(const Str_8& var) const;
/// Removes a header variable using the id.
/// @param [in] id The variable id to look for.
/// @returns True if the variable was found. False otherwise.
bool RemoveHeaderVar(const UInt_64 &id);
/// Removes a header variable using the name.
/// @param [in] name The variable name to look for.
/// @returns True if the variable was found. False otherwise.
bool RemoveHeaderVar(const Str_8 &name);
/// Retrieves a header variable using the id.
/// @param [in] id The variable id to look for.
/// @returns The variable object if found. Nullptr otherwise.
HeaderVar *GetHeaderVar(const UInt_64 &id) const;
/// Retrieves a header variable using the name.
/// @param [in] name The variable name to look for.
/// @returns The variable object if found. Nullptr otherwise.
HeaderVar *GetHeaderVar(const Str_8& name) const;
/// Retrieves a header variable value using the id.
/// @param [in] id The variable id to look for.
/// @returns The variable's value if found. Empty otherwise.
Str_8 GetHeaderValue(const UInt_64 &id) const;
/// Retrieves a header variable value using the name.
/// @param [in] name The variable name to look for.
/// @returns The variable's value if found. Empty otherwise.
Str_8 GetHeaderValue(const Str_8& name) const;
/// Retrieves all the header variables in a vector object.
/// @returns The result.
Vector<Str_8> GetHeader() const;
Vector<HeaderVar> GetHeader() const;
/// Adds a body variable.
/// @param [in] var The variable identifier.
/// @param [in] value The value of the variable.
void AddToBody(const Str_8& var, const Str_8& value);
void AddToBody(const Str_8 &var, const Str_8 &value);
/// Adds a value to the body.
/// @param [in] data The value to add.
void AddToBody(const Str_8& data);
void AddToBody(const Str_8 &data);
/// Sets the entire body.
/// @param [in] body The body to use.
void SetBody(const Str_8& body);
void SetBody(const Str_8 &body);
/// Retrieves a body variable.
/// @param [in] var The variable identifier to look for.
/// @returns The value of the body variable. Empty if it was not found.
Str_8 GetVar(const Str_8& var) const;
Str_8 GetVar(const Str_8 &var) const;
/// Retrieves the entire body.
/// @returns The result.
@@ -152,13 +233,13 @@ namespace ehs
bool IsValid() const;
private:
static Str_8 VerbToStr(const Verb verb);
static Str_8 VerbToStr(const Verb &verb);
static Str_8 ContentTypeToStr(const ContentType cType);
static Str_8 ContentTypeToStr(const ContentType &cType);
static ContentType StrToContentType(const Str_8& value);
static ContentType StrToContentType(const Str_8 &value);
void ReadData(const Str_8& data);
void ReadData(const Str_8 &data);
};
}

View File

@@ -5,16 +5,17 @@
#include "ehs/Str.h"
#include "ehs/json/Json.h"
#include "Socket.h"
#include "HeaderVar.h"
namespace ehs
{
class Response
class EHS_LIB_IO Response
{
private:
UInt_32 code;
Str_8 server;
ContentType cType;
Vector<Str_8> header;
Vector<HeaderVar> header;
Str_8 body;
public:
@@ -24,29 +25,38 @@ namespace ehs
/// Initializes this response with a given code and server identifier.
/// @param [in] code The code to give.
/// @param [in] server The server identifier.
Response(const UInt_32 code, const Str_8& server);
Response(const UInt_32 &code, Str_8 server);
/// Initializes this response with the raw response data.
/// @param [in] data The C-style string of the response.
/// @param [in] size The size of the given C-style string.
Response(const char* data, const UInt_64 size);
Response(const char *data, const UInt_64 &size);
/// Initializes this response with the raw response data.
/// @param [in] data The string of the response.
Response(const Str_8& data);
Response(const Str_8 &data);
/// Moves members from another object of the same type.
/// @param [in] other The object to move from.
Response(Response &&other) noexcept;
/// Copies members from another object of the same type.
/// @param [in] res The object to copy from.
Response(const Response& res) = default;
/// @param [in] other The object to copy from.
Response(const Response &other);
/// Moves members from another object of the same type.
/// @param [in] other The object to move from.
/// @returns The response that has been assigned to.
Response &operator=(Response &&other) noexcept;
/// Copies members from another object of the same type.
/// @param [in] res The object to copy from.
/// @returns The response that has been assigned to.
Response& operator=(const Response& res);
Response& operator=(const Response &other);
/// Sets the response code to send to the endpoint.
/// @param [in] code The code for success, error or info.
void SetCode(const UInt_32 code);
void SetCode(const UInt_32 &code);
/// Retrieves the response code.
/// @returns The result.
@@ -54,7 +64,7 @@ namespace ehs
/// Sets the server identifier.
/// @param [in] server The server identifier to use.
void SetServer(const Str_8& server);
void SetServer(Str_8 server);
/// Retrieves the server identifier.
/// @returns The result.
@@ -62,25 +72,60 @@ namespace ehs
/// Sets the content type for the body.
/// @param [in] cType The content type to use.
void SetContentType(const ContentType cType);
void SetContentType(const ContentType &cType);
/// Retrieves the content type for the body.
/// @returns The result.
ContentType GetContentType() const;
/// Adds a header variable.
/// @param [in] var The variable identifier.
/// @param [in] value The value of the variable.
void AddToHeader(const Str_8& var, const Str_8& value);
/// Checks whether a header variable exists using the id.
/// @param [in] id The variable id to look for.
/// @returns True if the variable exists. False otherwise.
bool HasHeaderVar(const UInt_64 &id) const;
/// Retrieves a header variable.
/// @param [in] var The variable identifier to look for.
/// @returns The value of the header variable. Empty if it was not found.
Str_8 GetHeader(const Str_8& var) const;
/// Checks whether a header variable exists using the name.
/// @param [in] name The variable name to look for.
/// @returns True if the variable exists. False otherwise.
bool HasHeaderVar(const Str_8 &name) const;
/// Adds a header variable.
/// @param [in] var The variable to add to the header.
/// @returns False if the given variable name already exists. True otherwise.
bool AddHeaderVar(HeaderVar var);
/// Removes a header variable using the id.
/// @param [in] id The variable id to look for.
/// @returns True if the variable was found. False otherwise.
bool RemoveHeaderVar(const UInt_64 &id);
/// Removes a header variable using the name.
/// @param [in] name The variable name to look for.
/// @returns True if the variable was found. False otherwise.
bool RemoveHeaderVar(const Str_8 &name);
/// Retrieves a header variable using the id.
/// @param [in] id The variable id to look for.
/// @returns The variable object if found. Nullptr otherwise.
HeaderVar *GetHeaderVar(const UInt_64 &id) const;
/// Retrieves a header variable using the name.
/// @param [in] name The variable name to look for.
/// @returns The variable object if found. Nullptr otherwise.
HeaderVar *GetHeaderVar(const Str_8& name) const;
/// Retrieves a header variable value using the id.
/// @param [in] id The variable id to look for.
/// @returns The variable's value if found. Empty otherwise.
Str_8 GetHeaderValue(const UInt_64 &id) const;
/// Retrieves a header variable value using the name.
/// @param [in] name The variable name to look for.
/// @returns The variable's value if found. Empty otherwise.
Str_8 GetHeaderValue(const Str_8& name) const;
/// Retrieves all the header variables in a vector object.
/// @returns The result.
Vector<Str_8> GetHeader() const;
Vector<HeaderVar> GetHeader() const;
/// Adds a body variable.
/// @param [in] var The variable identifier.
@@ -115,13 +160,13 @@ namespace ehs
bool IsValid() const;
private:
static Str_8 CodeToStr(const UInt_32 code);
static Str_8 CodeToStr(const UInt_32 &code);
static Str_8 ContentTypeToStr(const ContentType cType);
static Str_8 ContentTypeToStr(const ContentType &cType);
static ContentType StrToContentType(const Str_8& value);
static ContentType StrToContentType(const Str_8 &value);
void ReadData(const Str_8& data);
void ReadData(const Str_8 &data);
};
}

View File

@@ -1,5 +1,7 @@
#pragma once
#include <openssl/types.h>
#include "ehs/EHS.h"
#include "ehs/Str.h"
#include "TCP.h"
@@ -12,18 +14,21 @@ typedef struct ssl_st SSL;
namespace ehs
{
/// A class for handling the HTTP(S) TCP socket layer.
class SSL : public TCP
class EHS_LIB_IO SSL : public TCP
{
private:
bool server;
SSL_CTX* ctx;
::SSL* sslHdl;
X509 *cert;
EVP_PKEY* pkey;
public:
~SSL() override;
SSL();
SSL(const AddrType type);
SSL(const IP &type, const bool &server);
SSL(TCP&& tcp) noexcept;
@@ -37,19 +42,19 @@ namespace ehs
void Release() override;
void Bind(const Str_8& address, unsigned short port) override;
void Listen() override;
SSL* Accept() override;
void Connect(const Str_8& address, const UInt_16 port) override;
void Connect(Str_8 address, const UInt_16 &port) override;
UInt_64 Send(const Byte* const buffer, const UInt_32 size) override;
UInt_64 Send(const Byte* buffer, const UInt_32 size) override;
UInt_64 Receive(Byte* const buffer, const UInt_32 size) override;
UInt_64 Receive(Byte* buffer, const UInt_32 size) override;
void UseCertificate(const Byte* data, const UInt_64 size);
void UseCertificate(const Char_8* data, const UInt_32 &size);
void UsePrivateKey(const Byte* data, const UInt_64 size);
void UsePrivateKey(const Char_8* data, const UInt_32 &size);
bool IsValid();
};

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