web-framework-api 3.1.2__tar.gz → 3.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. web_framework_api-3.2.0/CMakeLists.txt +113 -0
  2. {web_framework_api-3.1.2 → web_framework_api-3.2.0}/PKG-INFO +20 -50
  3. {web_framework_api-3.1.2 → web_framework_api-3.2.0}/README.md +15 -44
  4. web_framework_api-3.2.0/cxx/include/Config.hpp +402 -0
  5. web_framework_api-3.2.0/cxx/include/DLLHandler.hpp +249 -0
  6. web_framework_api-3.2.0/cxx/include/DatabaseInterfaces/IDatabase.hpp +22 -0
  7. web_framework_api-3.2.0/cxx/include/DatabaseInterfaces/ISQLResult.hpp +16 -0
  8. web_framework_api-3.2.0/cxx/include/DatabaseInterfaces/ISQLValue.hpp +48 -0
  9. web_framework_api-3.2.0/cxx/include/DatabaseInterfaces/ITable.hpp +18 -0
  10. web_framework_api-3.2.0/cxx/include/Databases/Database.hpp +99 -0
  11. web_framework_api-3.2.0/cxx/include/Databases/SqlResult.hpp +155 -0
  12. web_framework_api-3.2.0/cxx/include/Databases/SqlValue.hpp +112 -0
  13. web_framework_api-3.2.0/cxx/include/Databases/Table.hpp +202 -0
  14. web_framework_api-3.2.0/cxx/include/Exceptions/NotImplementedDoMethodException.hpp +22 -0
  15. web_framework_api-3.2.0/cxx/include/Exceptions/WebFrameworkAPIException.hpp +43 -0
  16. web_framework_api-3.2.0/cxx/include/Exceptions/WebFrameworkException.hpp +47 -0
  17. web_framework_api-3.2.0/cxx/include/Executors/Executor.hpp +457 -0
  18. web_framework_api-3.2.0/cxx/include/Executors/HeavyOperationStatefulExecutor.hpp +31 -0
  19. web_framework_api-3.2.0/cxx/include/Executors/HeavyOperationStatelessExecutor.hpp +31 -0
  20. web_framework_api-3.2.0/cxx/include/Executors/StatefulExecutor.hpp +31 -0
  21. web_framework_api-3.2.0/cxx/include/Executors/StatelessExecutor.hpp +31 -0
  22. web_framework_api-3.2.0/cxx/include/HttpRequest.hpp +842 -0
  23. web_framework_api-3.2.0/cxx/include/HttpResponse.hpp +252 -0
  24. web_framework_api-3.2.0/cxx/include/JsonBuilder.hpp +325 -0
  25. web_framework_api-3.2.0/cxx/include/JsonObject.hpp +805 -0
  26. web_framework_api-3.2.0/cxx/include/JsonParser.hpp +449 -0
  27. web_framework_api-3.2.0/cxx/include/LoadBalancerHeuristic.hpp +145 -0
  28. web_framework_api-3.2.0/cxx/include/Utility/ChunkGenerator.hpp +16 -0
  29. web_framework_api-3.2.0/cxx/include/Utility/WebFrameworkLocalization.hpp +34 -0
  30. web_framework_api-3.2.0/cxx/include/Utility/WebFrameworkUtility.hpp +62 -0
  31. web_framework_api-3.2.0/cxx/include/WebFramework.hpp +198 -0
  32. web_framework_api-3.2.0/cxx/include/WebInterfaces/IHTTPRequest.hpp +183 -0
  33. web_framework_api-3.2.0/cxx/include/WebInterfaces/IHTTPResponse.hpp +32 -0
  34. web_framework_api-3.2.0/cxx/include/import.hpp +3 -0
  35. web_framework_api-3.2.0/dll/FileManager.dll +0 -0
  36. web_framework_api-3.2.0/dll/Localization.dll +0 -0
  37. web_framework_api-3.2.0/dll/Log.dll +0 -0
  38. web_framework_api-3.2.0/dll/WebFramework.dll +0 -0
  39. web_framework_api-3.2.0/dll/sqlite3.dll +0 -0
  40. {web_framework_api-3.1.2 → web_framework_api-3.2.0}/license/LICENSE +21 -21
  41. {web_framework_api-3.1.2 → web_framework_api-3.2.0}/pyproject.toml +13 -11
  42. web_framework_api-3.2.0/src/Executors/PyHeavyOperationStatefulExecutor.cpp +137 -0
  43. web_framework_api-3.2.0/src/Executors/PyHeavyOperationStatefulExecutor.h +37 -0
  44. web_framework_api-3.2.0/src/Executors/PyHeavyOperationStatelessExecutor.cpp +127 -0
  45. web_framework_api-3.2.0/src/Executors/PyHeavyOperationStatelessExecutor.h +35 -0
  46. web_framework_api-3.2.0/src/Executors/PyStatefulExecutor.cpp +137 -0
  47. web_framework_api-3.2.0/src/Executors/PyStatefulExecutor.h +36 -0
  48. web_framework_api-3.2.0/src/Executors/PyStatelessExecutor.cpp +127 -0
  49. web_framework_api-3.2.0/src/Executors/PyStatelessExecutor.h +34 -0
  50. web_framework_api-3.2.0/src/PyChunkGenerator.cpp +50 -0
  51. web_framework_api-3.2.0/src/PyChunkGenerator.h +46 -0
  52. web_framework_api-3.2.0/src/PyDynamicFunction.cpp +17 -0
  53. web_framework_api-3.2.0/src/PyDynamicFunction.h +29 -0
  54. web_framework_api-3.2.0/src/PyLoadBalancerHeuristic.cpp +44 -0
  55. web_framework_api-3.2.0/src/PyLoadBalancerHeuristic.h +20 -0
  56. web_framework_api-3.2.0/src/module.cpp +550 -0
  57. web_framework_api-3.1.2/CMakeLists.txt +0 -3
  58. web_framework_api-3.1.2/web_framework_api/WebFramework.py +0 -143
  59. web_framework_api-3.1.2/web_framework_api/__init__.py +0 -0
  60. web_framework_api-3.1.2/web_framework_api/exceptions/WebFrameworkException.py +0 -18
  61. web_framework_api-3.1.2/web_framework_api/utility/Config.py +0 -319
  62. web_framework_api-3.1.2/web_framework_api/utility/DLLHandler.py +0 -88
  63. web_framework_api-3.1.2/web_framework_api/utility/Utils.py +0 -88
  64. {web_framework_api-3.1.2 → web_framework_api-3.2.0}/license/BOOST_LICENSE.txt +0 -0
  65. {web_framework_api-3.1.2 → web_framework_api-3.2.0}/license/CMARK_GFM_LICENSE.txt +0 -0
  66. {web_framework_api-3.1.2 → web_framework_api-3.2.0}/license/OPEN_SSL_LICENSE.txt +0 -0
  67. {web_framework_api-3.1.2 → web_framework_api-3.2.0}/license/SQLITE3_LICENSE.txt +0 -0
@@ -0,0 +1,113 @@
1
+ cmake_minimum_required(VERSION 3.27.0)
2
+
3
+ set(CMAKE_CXX_STANDARD 20)
4
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
5
+ set(PYBIND11_TAG v3.0.1)
6
+
7
+ if (UNIX)
8
+ set(PYTHON_EXECUTABLE /usr/bin/python3 CACHE STRING "Path to Python executable")
9
+ else()
10
+ set(PYBIND11_FINDPYTHON OFF)
11
+
12
+ find_package(Python REQUIRED)
13
+
14
+ set(PYTHON_EXECUTABLE ${Python_EXECUTABLE} CACHE STRING "Path to Python executable")
15
+ endif()
16
+
17
+ if (NOT DEFINED ${PYTHON_MINOR_VERSION})
18
+ execute_process(
19
+ COMMAND ${PYTHON_EXECUTABLE} --version
20
+ OUTPUT_VARIABLE PYTHON_FULL_VERSION
21
+ )
22
+
23
+ message(STATUS "Full Python version: ${PYTHON_FULL_VERSION}")
24
+
25
+ string(REGEX REPLACE "Python [0-9]+\\.([0-9]+).*" "\\1" PYTHON_MINOR_VERSION "${PYTHON_FULL_VERSION}")
26
+ endif()
27
+
28
+ message(STATUS "Python minor version: ${PYTHON_MINOR_VERSION}")
29
+
30
+ if (UNIX)
31
+ add_definitions(-D__LINUX__)
32
+ endif(UNIX)
33
+
34
+ project(web_framework_api VERSION 3.2.0)
35
+
36
+ if (UNIX)
37
+ add_definitions(-D__LINUX__)
38
+ endif()
39
+
40
+ set(WEB_FRAMEWORK_INCLUDE_PATH "${PROJECT_SOURCE_DIR}/../CXX_API/include" CACHE STRING "Path to include directory")
41
+
42
+ include(FetchContent)
43
+
44
+ FetchContent_Declare(
45
+ pybind11
46
+ GIT_REPOSITORY https://github.com/pybind/pybind11.git
47
+ GIT_TAG ${PYBIND11_TAG}
48
+ OVERRIDE_FIND_PACKAGE
49
+ )
50
+
51
+ FetchContent_MakeAvailable(pybind11)
52
+
53
+ find_package(pybind11 REQUIRED)
54
+
55
+ pybind11_add_module(
56
+ ${PROJECT_NAME}
57
+ src/module.cpp
58
+ src/Executors/PyStatelessExecutor.cpp
59
+ src/Executors/PyStatefulExecutor.cpp
60
+ src/Executors/PyHeavyOperationStatelessExecutor.cpp
61
+ src/Executors/PyHeavyOperationStatefulExecutor.cpp
62
+ src/PyChunkGenerator.cpp
63
+ src/PyLoadBalancerHeuristic.cpp
64
+ src/PyDynamicFunction.cpp
65
+ )
66
+
67
+ target_include_directories(
68
+ ${PROJECT_NAME} PRIVATE
69
+ include
70
+ cxx/include
71
+ ${WEB_FRAMEWORK_INCLUDE_PATH}
72
+ )
73
+
74
+ if (DEFINED CUSTOM_INSTALL_PATH)
75
+ install(TARGETS ${PROJECT_NAME} DESTINATION ${CUSTOM_INSTALL_PATH})
76
+ else()
77
+ if (UNIX)
78
+ add_custom_target(
79
+ generate_pyi ALL
80
+ DEPENDS ${PROJECT_NAME}
81
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
82
+
83
+ COMMAND ${PYTHON_EXECUTABLE} -m venv .venv
84
+ COMMAND .venv/bin/python -m pip install pybind11-stubgen
85
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/*.so ${CMAKE_BINARY_DIR}/.venv/lib/python3.${PYTHON_MINOR_VERSION}/site-packages
86
+ COMMAND ${CMAKE_BINARY_DIR}/.venv/bin/pybind11-stubgen -o ${CMAKE_BINARY_DIR} ${PROJECT_NAME}
87
+ COMMAND ${CMAKE_COMMAND} -E rm -rf .venv
88
+ )
89
+ else()
90
+ add_custom_target(
91
+ generate_pyi ALL
92
+ DEPENDS ${PROJECT_NAME}
93
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
94
+
95
+ COMMAND ${PYTHON_EXECUTABLE} -m venv .venv
96
+ COMMAND .venv/Scripts/python -m pip install pybind11-stubgen
97
+ COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${PROJECT_NAME}> ${CMAKE_BINARY_DIR}/.venv/Lib/site-packages
98
+ COMMAND ${CMAKE_BINARY_DIR}/.venv/Scripts/pybind11-stubgen -o ${CMAKE_BINARY_DIR} ${PROJECT_NAME}
99
+ COMMAND ${CMAKE_COMMAND} -E rm -rf .venv
100
+ )
101
+ endif()
102
+
103
+ install(TARGETS ${PROJECT_NAME} DESTINATION .)
104
+ install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pyi DESTINATION .)
105
+ endif()
106
+
107
+ if (EXISTS lib)
108
+ install(DIRECTORY lib/ DESTINATION .)
109
+ endif()
110
+
111
+ if (EXISTS dll)
112
+ install(DIRECTORY dll/ DESTINATION .)
113
+ endif()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: web_framework_api
3
- Version: 3.1.2
3
+ Version: 3.2.0
4
4
  Summary: Python API for WebFramework
5
5
  Keywords: Web
6
6
  Author-Email: LazyPanda07 <semengricenko@gmail.com>
@@ -27,14 +27,13 @@ License: MIT License
27
27
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
28
  SOFTWARE.
29
29
 
30
- Classifier: Programming Language :: Python :: 3
30
+ Classifier: Programming Language :: Python :: 3.14
31
31
  Classifier: License :: OSI Approved :: MIT License
32
- Classifier: Operating System :: OS Independent
32
+ Classifier: Operating System :: Microsoft :: Windows
33
+ Classifier: Operating System :: POSIX :: Linux
33
34
  Project-URL: Repository, http://github.com/LazyPanda07/WebFramework
34
35
  Project-URL: Wiki, http://github.com/LazyPanda07/WebFramework/wiki
35
- Requires-Dist: multipledispatch
36
- Requires-Dist: requests
37
- Requires-Dist: tqdm
36
+ Requires-Python: ==3.14.*
38
37
  Description-Content-Type: text/markdown
39
38
 
40
39
  C++ HTTP/HTTPS server with Python API
@@ -52,8 +51,6 @@ C++ HTTP/HTTPS server with Python API
52
51
  Server needs few files to run:
53
52
  * [web.json](#settings) with routes
54
53
  * [Executors](#executors)
55
- * [Windows](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_windows.zip)
56
- * [Linux](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_linux.zip)
57
54
  * [config.json](#config) with server settings
58
55
  All these files must be in the same directory as ```main.py```
59
56
 
@@ -87,7 +84,8 @@ if __name__ == '__main__':
87
84
  {
88
85
  "HelloExecutor": {
89
86
  "route": "",
90
- "loadType": "initialization"
87
+ "loadType": "initialization",
88
+ "api": "python"
91
89
  }
92
90
  }
93
91
  ```
@@ -109,6 +107,9 @@ if __name__ == '__main__':
109
107
  "loadSources": [
110
108
  "hello_executor"
111
109
  ],
110
+ "runtimes": [
111
+ "python"
112
+ ],
112
113
  "assetsPath": "assets",
113
114
  "templatesPath": "templates",
114
115
  "cachingSize": 536870912,
@@ -143,47 +144,16 @@ You will see response from server
143
144
 
144
145
 
145
146
  ## Executors
146
- Executors are C++ classes that responsible for giving responses for their route(url).
147
+ Executors are C++, C, Python or C# classes that responsible for giving responses for their route(url).
147
148
  Source code of HelloExecutor from example
148
- ```HelloExecutor.h```
149
- ```cpp
150
- #pragma once
151
-
152
- #include "Executors/BaseStatelessExecutor.h"
153
-
154
- namespace executors
155
- {
156
- class HelloExecutor : public framework::BaseStatelessExecutor
157
- {
158
- public:
159
- HelloExecutor() = default;
160
-
161
- void doGet(framework::HTTPRequest& request, framework::HTTPResponse& response) override;
162
-
163
- ~HelloExecutor() = default;
164
- };
165
- }
166
- ```
167
- ```HelloExecutor.cpp```
168
- ```cpp
169
- #include "HelloExecutor.h"
170
-
171
- #include "JSONBuilder.h"
172
-
173
- namespace executors
174
- {
175
- void HelloExecutor::doGet(framework::HTTPRequest& request, framework::HTTPResponse& response)
176
- {
177
- response.addBody(json::JSONBuilder(CP_UTF8).appendString("message", "Hello, World!"));
178
- }
149
+ ```hello_executor.py```
150
+ ```python
151
+ from web_framework_api import *
179
152
 
180
- DECLARE_EXECUTOR(HelloExecutor);
181
- }
153
+ class HelloExecutor(StatelessExecutor):
154
+ def do_get(self, request, response):
155
+ response.set_body({
156
+ "message": "Hello, World!"
157
+ })
182
158
  ```
183
- More information you can find in [wiki](https://github.com/LazyPanda07/WebFramework/wiki/Executors).
184
-
185
-
186
- ### Hello executor
187
- * Links
188
- * [Windows](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_windows.zip)
189
- * [Linux](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_linux.zip)
159
+ More information you can find in [wiki](https://github.com/LazyPanda07/WebFramework/wiki/Executors-API).
@@ -13,8 +13,6 @@ C++ HTTP/HTTPS server with Python API
13
13
  Server needs few files to run:
14
14
  * [web.json](#settings) with routes
15
15
  * [Executors](#executors)
16
- * [Windows](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_windows.zip)
17
- * [Linux](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_linux.zip)
18
16
  * [config.json](#config) with server settings
19
17
  All these files must be in the same directory as ```main.py```
20
18
 
@@ -48,7 +46,8 @@ if __name__ == '__main__':
48
46
  {
49
47
  "HelloExecutor": {
50
48
  "route": "",
51
- "loadType": "initialization"
49
+ "loadType": "initialization",
50
+ "api": "python"
52
51
  }
53
52
  }
54
53
  ```
@@ -70,6 +69,9 @@ if __name__ == '__main__':
70
69
  "loadSources": [
71
70
  "hello_executor"
72
71
  ],
72
+ "runtimes": [
73
+ "python"
74
+ ],
73
75
  "assetsPath": "assets",
74
76
  "templatesPath": "templates",
75
77
  "cachingSize": 536870912,
@@ -104,47 +106,16 @@ You will see response from server
104
106
 
105
107
 
106
108
  ## Executors
107
- Executors are C++ classes that responsible for giving responses for their route(url).
109
+ Executors are C++, C, Python or C# classes that responsible for giving responses for their route(url).
108
110
  Source code of HelloExecutor from example
109
- ```HelloExecutor.h```
110
- ```cpp
111
- #pragma once
112
-
113
- #include "Executors/BaseStatelessExecutor.h"
114
-
115
- namespace executors
116
- {
117
- class HelloExecutor : public framework::BaseStatelessExecutor
118
- {
119
- public:
120
- HelloExecutor() = default;
121
-
122
- void doGet(framework::HTTPRequest& request, framework::HTTPResponse& response) override;
123
-
124
- ~HelloExecutor() = default;
125
- };
126
- }
127
- ```
128
- ```HelloExecutor.cpp```
129
- ```cpp
130
- #include "HelloExecutor.h"
131
-
132
- #include "JSONBuilder.h"
133
-
134
- namespace executors
135
- {
136
- void HelloExecutor::doGet(framework::HTTPRequest& request, framework::HTTPResponse& response)
137
- {
138
- response.addBody(json::JSONBuilder(CP_UTF8).appendString("message", "Hello, World!"));
139
- }
111
+ ```hello_executor.py```
112
+ ```python
113
+ from web_framework_api import *
140
114
 
141
- DECLARE_EXECUTOR(HelloExecutor);
142
- }
115
+ class HelloExecutor(StatelessExecutor):
116
+ def do_get(self, request, response):
117
+ response.set_body({
118
+ "message": "Hello, World!"
119
+ })
143
120
  ```
144
- More information you can find in [wiki](https://github.com/LazyPanda07/WebFramework/wiki/Executors).
145
-
146
-
147
- ### Hello executor
148
- * Links
149
- * [Windows](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_windows.zip)
150
- * [Linux](https://github.com/LazyPanda07/WebFramework/releases/latest/download/hello_executor_linux.zip)
121
+ More information you can find in [wiki](https://github.com/LazyPanda07/WebFramework/wiki/Executors-API).
@@ -0,0 +1,402 @@
1
+ #pragma once
2
+
3
+ #include <concepts>
4
+
5
+ #include "DLLHandler.hpp"
6
+ #include "Exceptions/WebFrameworkException.hpp"
7
+
8
+ namespace framework::utility
9
+ {
10
+ /**
11
+ * @brief Config file representation
12
+ */
13
+ class Config
14
+ {
15
+ private:
16
+ void* implementation;
17
+ bool weak;
18
+
19
+ public:
20
+ /**
21
+ * @brief
22
+ * @param configPath Path to *.json config file
23
+ */
24
+ Config(const std::filesystem::path& configPath);
25
+
26
+ /**
27
+ * @brief
28
+ * @param serverConfiguration *.json config file content
29
+ * @param applicationDirectory Working directory
30
+ */
31
+ Config(std::string_view serverConfiguration, std::string_view applicationDirectory);
32
+
33
+ Config(const Config& other);
34
+
35
+ Config(Config&& other) noexcept = delete;
36
+
37
+ Config& operator = (const Config& other);
38
+
39
+ Config& operator = (Config&& other) noexcept = delete;
40
+
41
+ /**
42
+ * @brief Override string
43
+ * @tparam T
44
+ * @param key Json key
45
+ * @param value New string value
46
+ * @param recursive Recursive search for key
47
+ * @return Self
48
+ */
49
+ template<std::convertible_to<std::string_view> T>
50
+ Config& overrideConfiguration(std::string_view key, const T& value, bool recursive = true);
51
+
52
+ /**
53
+ * @brief Override integer
54
+ * @tparam T
55
+ * @param key Json key
56
+ * @param value New integer value
57
+ * @param recursive Recursive search for key
58
+ * @return Self
59
+ */
60
+ template<std::convertible_to<int64_t> T>
61
+ Config& overrideConfiguration(std::string_view key, const T& value, bool recursive = true);
62
+
63
+ /**
64
+ * @brief Override string array
65
+ * @param key Json key
66
+ * @param value New string array value
67
+ * @param recursive Recursive search for key
68
+ * @return Self
69
+ */
70
+ Config& overrideConfiguration(std::string_view key, const std::vector<std::string>& value, bool recursive = true);
71
+
72
+ /**
73
+ * @brief Override integer array
74
+ * @param key Json key
75
+ * @param value New integer array value
76
+ * @param recursive Recursive search for key
77
+ * @return Self
78
+ */
79
+ Config& overrideConfiguration(std::string_view key, const std::vector<int64_t>& value, bool recursive = true);
80
+
81
+ /**
82
+ * @brief Override config file directory
83
+ * @param basePath New base path
84
+ * @return Self
85
+ */
86
+ Config& overrideBasePath(std::string_view basePath);
87
+
88
+ /**
89
+ * @brief Get value from config
90
+ * @tparam T
91
+ * @param key Config key
92
+ * @param recursive Search recursively
93
+ * @return Config value
94
+ */
95
+ template<typename T>
96
+ T get(std::string_view key, bool recursive = true) const requires(std::same_as<T, std::string> || std::convertible_to<T, int64_t> || std::same_as<T, bool>);
97
+
98
+ /**
99
+ * @brief Get config file directory
100
+ * @return
101
+ */
102
+ std::string getBasePath() const;
103
+
104
+ /**
105
+ * @brief Get current config Json string data
106
+ * @return
107
+ */
108
+ std::string getConfiguration() const;
109
+
110
+ /**
111
+ * @brief Get raw config Json string data
112
+ * @return
113
+ */
114
+ std::string_view getRawConfiguration() const;
115
+
116
+ void* getImplementation() const;
117
+
118
+ ~Config();
119
+ };
120
+ }
121
+
122
+ namespace framework::utility
123
+ {
124
+ inline Config::Config(const std::filesystem::path& configPath) :
125
+ implementation(nullptr),
126
+ weak(false)
127
+ {
128
+ using createConfigFromPath = void* (*)(const char* configPath, void** exception);
129
+
130
+ if (!std::filesystem::exists(configPath))
131
+ {
132
+ throw std::runtime_error(std::format("Path {} doesn't exist", configPath.string()));
133
+ }
134
+
135
+ void* exception = nullptr;
136
+
137
+ implementation = DllHandler::getInstance().CALL_WEB_FRAMEWORK_FUNCTION(createConfigFromPath, configPath.string().data(), &exception);
138
+
139
+ if (exception) //-V547
140
+ {
141
+ throw exceptions::WebFrameworkException(exception);
142
+ }
143
+ }
144
+
145
+ inline Config::Config(std::string_view serverConfiguration, std::string_view applicationDirectory) :
146
+ implementation(nullptr),
147
+ weak(false)
148
+ {
149
+ using createConfigFromString = void* (*)(const char* serverConfiguration, const char* applicationDirectory, void** exception);
150
+ void* exception = nullptr;
151
+
152
+ implementation = DllHandler::getInstance().CALL_WEB_FRAMEWORK_FUNCTION(createConfigFromString, serverConfiguration.data(), applicationDirectory.data(), &exception);
153
+
154
+ if (exception) //-V547
155
+ {
156
+ throw exceptions::WebFrameworkException(exception);
157
+ }
158
+ }
159
+
160
+ inline Config::Config(const Config& other)
161
+ {
162
+ (*this) = other;
163
+ }
164
+
165
+ inline Config& Config::operator = (const Config& other)
166
+ {
167
+ implementation = other.implementation;
168
+ weak = true;
169
+
170
+ return *this;
171
+ }
172
+
173
+ template<std::convertible_to<std::string_view> T>
174
+ inline Config& Config::overrideConfiguration(std::string_view key, const T& value, bool recursive)
175
+ {
176
+ DEFINE_CLASS_MEMBER_FUNCTION(overrideConfigurationString, void, const char* key, const char* value, bool recursive, void** exception);
177
+ void* exception = nullptr;
178
+
179
+ DllHandler::getInstance().CALL_CLASS_MEMBER_WEB_FRAMEWORK_FUNCTION(overrideConfigurationString, key.data(), static_cast<std::string_view>(value).data(), recursive, &exception);
180
+
181
+ if (exception) //-V547
182
+ {
183
+ throw exceptions::WebFrameworkException(exception);
184
+ }
185
+
186
+ return *this;
187
+ }
188
+
189
+ template<std::convertible_to<int64_t> T>
190
+ inline Config& Config::overrideConfiguration(std::string_view key, const T& value, bool recursive)
191
+ {
192
+ DEFINE_CLASS_MEMBER_FUNCTION(overrideConfigurationInteger, void, const char* key, int64_t value, bool recursive, void** exception);
193
+ void* exception = nullptr;
194
+
195
+ DllHandler::getInstance().CALL_CLASS_MEMBER_WEB_FRAMEWORK_FUNCTION(overrideConfigurationInteger, key.data(), static_cast<int64_t>(value), recursive, &exception);
196
+
197
+ if (exception) //-V547
198
+ {
199
+ throw exceptions::WebFrameworkException(exception);
200
+ }
201
+
202
+ return *this;
203
+ }
204
+
205
+ template<>
206
+ inline Config& Config::overrideConfiguration<bool>(std::string_view key, const bool& value, bool recursive) //-V835
207
+ {
208
+ DEFINE_CLASS_MEMBER_FUNCTION(overrideConfigurationBoolean, void, const char* key, bool value, bool recursive, void** exception);
209
+ void* exception = nullptr;
210
+
211
+ DllHandler::getInstance().CALL_CLASS_MEMBER_WEB_FRAMEWORK_FUNCTION(overrideConfigurationBoolean, key.data(), value, recursive, &exception);
212
+
213
+ if (exception) //-V547
214
+ {
215
+ throw exceptions::WebFrameworkException(exception);
216
+ }
217
+
218
+ return *this;
219
+ }
220
+
221
+ inline Config& Config::overrideConfiguration(std::string_view key, const std::vector<std::string>& value, bool recursive)
222
+ {
223
+ DEFINE_CLASS_MEMBER_FUNCTION(overrideConfigurationStringArray, void, const char* key, const char** value, bool recursive, int64_t size, void** exception);
224
+ void* exception = nullptr;
225
+
226
+ const char** data = new const char* [value.size()];
227
+
228
+ #ifndef __LINUX__
229
+ #pragma warning(push)
230
+ #pragma warning(disable: 6386)
231
+ #endif
232
+
233
+ for (size_t i = 0; i < value.size(); i++)
234
+ {
235
+ data[i] = value[i].data();
236
+ }
237
+
238
+ #ifndef __LINUX__
239
+ #pragma warning(pop)
240
+ #endif
241
+
242
+ DllHandler::getInstance().CALL_CLASS_MEMBER_WEB_FRAMEWORK_FUNCTION(overrideConfigurationStringArray, key.data(), data, recursive, static_cast<int64_t>(value.size()), &exception);
243
+
244
+ delete[] data;
245
+
246
+ if (exception) //-V547
247
+ {
248
+ throw exceptions::WebFrameworkException(exception);
249
+ }
250
+
251
+ return *this;
252
+ }
253
+
254
+ inline Config& Config::overrideConfiguration(std::string_view key, const std::vector<int64_t>& value, bool recursive)
255
+ {
256
+ DEFINE_CLASS_MEMBER_FUNCTION(overrideConfigurationIntegerArray, void, const char* key, const int64_t * value, bool recursive, int64_t size, void** exception);
257
+ void* exception = nullptr;
258
+
259
+ int64_t* data = new int64_t[value.size()];
260
+
261
+ #ifndef __LINUX__
262
+ #pragma warning(push)
263
+ #pragma warning(disable: 6386)
264
+ #endif
265
+
266
+ for (size_t i = 0; i < value.size(); i++)
267
+ {
268
+ data[i] = value[i];
269
+ }
270
+
271
+ #ifndef __LINUX__
272
+ #pragma warning(pop)
273
+ #endif
274
+
275
+ DllHandler::getInstance().CALL_CLASS_MEMBER_WEB_FRAMEWORK_FUNCTION(overrideConfigurationIntegerArray, key.data(), data, recursive, static_cast<int64_t>(value.size()), &exception);
276
+
277
+ delete[] data;
278
+
279
+ if (exception) //-V547
280
+ {
281
+ throw exceptions::WebFrameworkException(exception);
282
+ }
283
+
284
+ return *this;
285
+ }
286
+
287
+ inline Config& Config::overrideBasePath(std::string_view basePath)
288
+ {
289
+ DEFINE_CLASS_MEMBER_FUNCTION(overrideBasePath, void, const char* basePath, void** exception);
290
+ void* exception = nullptr;
291
+
292
+ DllHandler::getInstance().CALL_CLASS_MEMBER_WEB_FRAMEWORK_FUNCTION(overrideBasePath, basePath.data(), &exception);
293
+
294
+ if (exception) //-V547
295
+ {
296
+ throw exceptions::WebFrameworkException(exception);
297
+ }
298
+
299
+ return *this;
300
+ }
301
+
302
+ template<typename T>
303
+ inline T Config::get(std::string_view key, bool recursive) const requires(std::same_as<T, std::string> || std::convertible_to<T, int64_t> || std::same_as<T, bool>)
304
+ {
305
+ void* exception = nullptr;
306
+ DllHandler& instance = DllHandler::getInstance();
307
+ T result;
308
+
309
+ if constexpr (std::is_same_v<T, bool>)
310
+ {
311
+ DEFINE_CLASS_MEMBER_FUNCTION(getConfigurationBoolean, bool, const char* key, bool recursive, void** exception);
312
+
313
+ result = instance.CALL_CLASS_MEMBER_WEB_FRAMEWORK_FUNCTION(getConfigurationBoolean, key.data(), recursive, &exception);
314
+ }
315
+ else if constexpr (std::is_convertible_v<T, int64_t>)
316
+ {
317
+ DEFINE_CLASS_MEMBER_FUNCTION(getConfigurationInteger, int64_t, const char* key, bool recursive, void** exception);
318
+
319
+ result = static_cast<T>(instance.CALL_CLASS_MEMBER_WEB_FRAMEWORK_FUNCTION(getConfigurationInteger, key.data(), recursive, &exception));
320
+ }
321
+ else if constexpr (std::is_same_v<T, std::string>)
322
+ {
323
+ DEFINE_CLASS_MEMBER_FUNCTION(getConfigurationString, void*, const char* key, bool recursive, void** exception);
324
+
325
+ void* temp = instance.CALL_CLASS_MEMBER_WEB_FRAMEWORK_FUNCTION(getConfigurationString, key.data(), recursive, &exception);
326
+
327
+ if (exception)
328
+ {
329
+ throw exceptions::WebFrameworkException(exception);
330
+ }
331
+
332
+ return instance.getString(temp);
333
+ }
334
+
335
+ if (exception)
336
+ {
337
+ throw exceptions::WebFrameworkException(exception);
338
+ }
339
+
340
+ return result;
341
+ }
342
+
343
+ inline std::string Config::getBasePath() const
344
+ {
345
+ DEFINE_CLASS_MEMBER_FUNCTION(getBasePath, void*, void** exception);
346
+ void* exception = nullptr;
347
+ DllHandler& handler = DllHandler::getInstance();
348
+
349
+ void* result = handler.CALL_CLASS_MEMBER_WEB_FRAMEWORK_FUNCTION(getBasePath, &exception);
350
+
351
+ if (exception)
352
+ {
353
+ throw exceptions::WebFrameworkException(exception);
354
+ }
355
+
356
+ return handler.getString(result);
357
+ }
358
+
359
+ inline std::string Config::getConfiguration() const
360
+ {
361
+ DEFINE_CLASS_MEMBER_FUNCTION(getConfiguration, void*, void** exception);
362
+ void* exception = nullptr;
363
+ DllHandler& handler = DllHandler::getInstance();
364
+
365
+ void* result = handler.CALL_CLASS_MEMBER_WEB_FRAMEWORK_FUNCTION(getConfiguration, &exception);
366
+
367
+ if (exception)
368
+ {
369
+ throw exceptions::WebFrameworkException(exception);
370
+ }
371
+
372
+ return handler.getString(result);
373
+ }
374
+
375
+ inline std::string_view Config::getRawConfiguration() const
376
+ {
377
+ DEFINE_CLASS_MEMBER_FUNCTION(getRawConfiguration, const char*, void** exception);
378
+ void* exception = nullptr;
379
+
380
+ const char* result = DllHandler::getInstance().CALL_CLASS_MEMBER_WEB_FRAMEWORK_FUNCTION(getRawConfiguration, &exception);
381
+
382
+ if (exception)
383
+ {
384
+ throw exceptions::WebFrameworkException(exception);
385
+ }
386
+
387
+ return std::string_view(result);
388
+ }
389
+
390
+ inline void* Config::getImplementation() const
391
+ {
392
+ return implementation;
393
+ }
394
+
395
+ inline Config::~Config()
396
+ {
397
+ if (!weak)
398
+ {
399
+ DllHandler::getInstance().deleteConfig(implementation);
400
+ }
401
+ }
402
+ }