Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Boost & Update Dependencies #146

Merged
merged 4 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Imports:
unigd
LinkingTo:
cpp11 (>= 0.2.4),
BH (>= 1.75.0),
AsioHeaders (>= 1.22.1),
unigd
Suggests:
testthat,
Expand Down
6,069 changes: 1,107 additions & 4,962 deletions client/package-lock.json

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@
"author": "",
"license": "ISC",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.1.0",
"@typescript-eslint/parser": "^5.1.0",
"css-loader": "^6.3.0",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"css-loader": "^6.9.1",
"ejs-compiled-loader": "^3.1.0",
"ejs-loader": "^0.5.0",
"eslint": "^8.1.0",
"html-loader": "^4.1.0",
"html-webpack-plugin": "^5.3.2",
"mini-css-extract-plugin": "^2.3.0",
"sass": "^1.43.3",
"sass-loader": "^13.0.2",
"style-loader": "^3.3.0",
"eslint": "^8.56.0",
"html-loader": "^5.0.0",
"html-webpack-plugin": "^5.6.0",
"mini-css-extract-plugin": "^2.7.7",
"sass": "^1.70.0",
"sass-loader": "^14.0.0",
"style-loader": "^3.3.4",
"svg-inline-loader": "^0.8.2",
"ts-loader": "^9.2.6",
"typescript": "^4.4.3",
"webpack": "^5.53.0",
"webpack-cli": "^4.8.0",
"webpack-dev-server": "^4.2.1"
"ts-loader": "^9.5.1",
"typescript": "^5.3.3",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
},
"dependencies": {
"httpgd": "^0.1.7"
Expand Down
2 changes: 1 addition & 1 deletion inst/www/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Makevars.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CXX_STD = CXX14

PKG_CPPFLAGS = -Ilib -DBOOST_NO_AUTO_PTR -DFMT_HEADER_ONLY
PKG_CPPFLAGS = -Ilib -DFMT_HEADER_ONLY

all: clean

Expand Down
1 change: 0 additions & 1 deletion src/Makevars.ucrt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
CXX_STD = CXX14

PKG_CPPFLAGS = -Ilib \
-DBOOST_NO_AUTO_PTR \
-DFMT_HEADER_ONLY \
-DHTTPGD_DEBUG_DEVICE

Expand Down
1 change: 0 additions & 1 deletion src/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ VERSION_HARFBUZZ = 2.7.4
RWINLIB_HARFBUZZ = ../windows/harfbuzz-${VERSION_HARFBUZZ}

PKG_CPPFLAGS = -Ilib -I${RWINLIB_HARFBUZZ}/include \
-DBOOST_NO_AUTO_PTR \
-DFMT_HEADER_ONLY

PKG_LIBS = -L${RWINLIB_HARFBUZZ}/lib${R_ARCH}${CRT} -lWs2_32 -lwsock32
Expand Down
1 change: 0 additions & 1 deletion src/httpgd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

//#include <R_ext/GraphicsEngine.h>

#include <boost/optional.hpp>
#include <string>
#include <vector>

Expand Down
26 changes: 21 additions & 5 deletions src/httpgd_rng.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

#include "httpgd_rng.h"

#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <chrono>
#include <random>

Expand All @@ -13,8 +10,27 @@ namespace rng
{
std::string uuid()
{
boost::uuids::random_generator uuid_gen;
return boost::uuids::to_string(uuid_gen());
const int uuidLength = 36; // Including hyphens
std::string uuid;
uuid.reserve(uuidLength);

std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0, 15);

auto randomByte = [&]() {
const char hexChars[] = "0123456789abcdef";
return hexChars[dis(gen)];
};

for (int i = 0; i < 32; ++i) {
if (i == 8 || i == 12 || i == 16 || i == 20) {
uuid += '-';
}
uuid += randomByte();
}

return uuid;
}

std::string token(int length)
Expand Down
3 changes: 0 additions & 3 deletions src/httpgd_version.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#ifndef HTTPGD_VERSION
#define HTTPGD_VERSION "2.0.0"

#include <boost/version.hpp>
#define HTTPGD_VERSION_BOOST BOOST_LIB_VERSION
#endif
32 changes: 16 additions & 16 deletions src/httpgd_webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#define CROW_MAIN
#include <crow.h>
#include <fmt/format.h>
#include <compat/optional.hpp>

#include <memory>

Expand All @@ -18,12 +19,12 @@ namespace
{
const char *HTTPGD_CLIENT_INFO = "httpgd " HTTPGD_VERSION;

inline boost::optional<std::string> read_txt(const std::string &filepath)
inline std::experimental::optional<std::string> read_txt(const std::string &filepath)
{
std::ifstream t(filepath);
if (t.fail())
{
return boost::none;
return std::experimental::nullopt;
}
std::stringstream buffer;
buffer << t.rdbuf();
Expand Down Expand Up @@ -54,13 +55,13 @@ struct plot_return : public crow::returnable
const unigd_render_access m_render;
};

inline boost::optional<UNIGD_PLOT_ID> req_find_id(unigd_api_v1 *api,
inline std::experimental::optional<UNIGD_PLOT_ID> req_find_id(unigd_api_v1 *api,
UNIGD_HANDLE ugd_handle,
const crow::request &req)
{
if (!api)
{
return boost::none;
return std::experimental::nullopt;
}
const auto p_id = param_to<UNIGD_PLOT_ID>(req.url_params.get("id"));
if (p_id)
Expand All @@ -70,10 +71,10 @@ inline boost::optional<UNIGD_PLOT_ID> req_find_id(unigd_api_v1 *api,
const auto p_index = param_to<UNIGD_PLOT_ID>(req.url_params.get("index"));
if (!p_index)
{
return boost::none;
return std::experimental::nullopt;
}

boost::optional<UNIGD_PLOT_ID> re = boost::none;
std::experimental::optional<UNIGD_PLOT_ID> re = std::experimental::nullopt;
unigd_find_results qr;
const auto handle = api->device_plots_find(ugd_handle, *p_index, 1, &qr);
if (qr.size > 0)
Expand Down Expand Up @@ -144,7 +145,7 @@ void WebServer::TokenGuard::before_handle(crow::request &req, crow::response &re
{
return;
}
boost::optional<std::string> user_token = boost::none;
std::experimental::optional<std::string> user_token = std::experimental::nullopt;
const auto f_header_token = req.headers.find("X-HTTPGD-TOKEN");
if (f_header_token != req.headers.end())
{
Expand All @@ -155,7 +156,7 @@ void WebServer::TokenGuard::before_handle(crow::request &req, crow::response &re
user_token = param_to<std::string>(req.url_params.get("token"));
}

if (!user_token || (user_token.get() != m_token))
if (!user_token || (user_token.value() != m_token))
{
res.code = crow::UNAUTHORIZED;
res.end();
Expand Down Expand Up @@ -290,7 +291,7 @@ void WebServer::run()
UNIGD_FIND_HANDLE find_handle;
unigd_find_results qr;
find_handle = m_api->device_plots_find(
m_ugd_handle, p_index.get_value_or(0), p_limit.get_value_or(0), &qr);
m_ugd_handle, p_index.value_or(0), p_limit.value_or(0), &qr);

std::vector<crow::json::wvalue> plot_list;
plot_list.reserve(qr.size);
Expand All @@ -317,19 +318,19 @@ void WebServer::run()
double width, height, zoom;
if (p_width && p_height)
{
zoom = param_to<double>(req.url_params.get("zoom")).get_value_or(1);
zoom = param_to<double>(req.url_params.get("zoom")).value_or(1);
width = (*p_width) / zoom;
height = (*p_height) / zoom;
}
else
{
zoom = 1;
width = p_width.get_value_or(-1);
height = p_height.get_value_or(-1);
width = p_width.value_or(-1);
height = p_height.value_or(-1);
}
const auto p_id = req_find_id(m_api, m_ugd_handle, req).get_value_or(-1);
const auto p_id = req_find_id(m_api, m_ugd_handle, req).value_or(-1);
const auto p_renderer =
param_to<std::string>(req.url_params.get("renderer")).get_value_or("svg");
param_to<std::string>(req.url_params.get("renderer")).value_or("svg");
const auto p_download =
param_to<const char *>(req.url_params.get("download"));
if (m_api)
Expand Down Expand Up @@ -413,8 +414,7 @@ void WebServer::run()
return crow::response(crow::status::NOT_FOUND);
});

CROW_ROUTE(m_app, "/")
.websocket()
CROW_WEBSOCKET_ROUTE(m_app, "/")
.onopen(
[&](crow::websocket::connection &conn)
{
Expand Down
1 change: 1 addition & 0 deletions src/httpgd_webserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define __UNIGD_HTTPGD_WEBSERVER_H__

#include <crow.h>
#include <crow/middlewares/cors.h>

#include <memory>
#include <mutex>
Expand Down
Loading
Loading