From b6f70527be97b3e8940d596c46c0fe183f5a973f Mon Sep 17 00:00:00 2001 From: Shaun Date: Thu, 16 Jan 2025 14:49:49 +0000 Subject: [PATCH 1/2] Added missing returns and removed some whitespace in c++ interface --- include/webui.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/webui.hpp b/include/webui.hpp index f83059090..4a07cf622 100644 --- a/include/webui.hpp +++ b/include/webui.hpp @@ -90,7 +90,7 @@ namespace webui { // ------ Event methods `e->xxx()` ------ // Get how many arguments there are in an event. - size_t get_count(size_t index = 0) { + size_t get_count(size_t index = 0) { return webui_get_count(this); } @@ -125,9 +125,9 @@ namespace webui { } // Run JavaScript without waiting for the response. Single client. - void script_client(const std::string_view script, unsigned int timeout, + bool script_client(const std::string_view script, unsigned int timeout, char* buffer, size_t buffer_length) { - webui_script_client(this, script.data(), timeout, buffer, buffer_length); + return webui_script_client(this, script.data(), timeout, buffer, buffer_length); } // Run JavaScript without waiting for the response. Single client. @@ -278,10 +278,10 @@ namespace webui { return webui_get_port(webui_window); } - // Set a custom web-server network port to be used by WebUI. This can be useful to determine the HTTP + // Set a custom web-server network port to be used by WebUI. This can be useful to determine the HTTP // link of `webui.js` in case you are trying to use WebUI with an external web-server like NGNIX - void set_port(size_t port) const { - webui_set_port(webui_window, port); + bool set_port(size_t port) const { + return webui_set_port(webui_window, port); } // Set window position @@ -346,7 +346,7 @@ namespace webui { webui_navigate(webui_window, url.data()); } - // Control if UI events coming from this window should be processed one at a time in a + // Control if UI events coming from this window should be processed one at a time in a // single blocking thread `True`, or process every event in a new non-blocking thread `False`. void set_event_blocking(bool status) const { webui_set_event_blocking(webui_window, status); @@ -373,7 +373,7 @@ namespace webui { } // Run a JavaScript, and get the response back (Make sure your local buffer can hold the response). - bool script(const std::string_view script, unsigned int timeout, + bool script(const std::string_view script, unsigned int timeout, char* buffer, size_t buffer_length) const { return webui_script(webui_window, script.data(), timeout, buffer, buffer_length); } @@ -443,9 +443,9 @@ namespace webui { // Set the SSL/TLS certificate and the private key content, both in PEM format. // This works only with `webui-2-secure` library. If set empty WebUI will generate a self-signed certificate. - inline void set_tls_certificate(const std::string_view certificate_pem, + inline bool set_tls_certificate(const std::string_view certificate_pem, const std::string_view private_key_pem) { - webui_set_tls_certificate(certificate_pem.data(), private_key_pem.data()); + return webui_set_tls_certificate(certificate_pem.data(), private_key_pem.data()); } // Safely free a buffer allocated by WebUI, for example when using webui_encode(). From 737ee76cbc9053f1c76951cceba94c25a1c41e4c Mon Sep 17 00:00:00 2001 From: Shaun Date: Thu, 16 Jan 2025 15:53:56 +0000 Subject: [PATCH 2/2] Upped CMakeLists.txt CXX version to c++17 for std::string_view --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 31735116e..eb4c9e1e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,8 @@ cmake_minimum_required(VERSION 3.10) project(WebUILibrary) # Set C++ standard -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) # Variables for library names, source files, etc. set(WEBUI_OUT_LIB_NAME "webui-2")