From 60fa49bc29a9a61d25aecf1291dc0de0173ee200 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Fri, 18 Oct 2024 00:08:06 +0300 Subject: [PATCH] ... --- net/adc_endpoint.h | 33 ++++++++++++++++++++++++--------- net/asio/adc_netservice_asio.h | 10 +++++++--- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/net/adc_endpoint.h b/net/adc_endpoint.h index 42d451e..5c49918 100644 --- a/net/adc_endpoint.h +++ b/net/adc_endpoint.h @@ -1,5 +1,6 @@ #pragma once +#include /* @@ -63,6 +64,9 @@ public: fromRange(ept); } + + virtual ~AdcEndpointParser() = default; + template requires std::ranges::contiguous_range bool fromRange(const R& ept) @@ -88,19 +92,23 @@ public: _proto = std::string_view{_endpoint.begin(), found.begin()}; - for (auto& valid_proto : validProtoMarks) { - _isValid = _proto == valid_proto; - if (_isValid) { - break; - } - } + // for (auto& valid_proto : validProtoMarks) { + // _isValid = _proto == valid_proto; + // if (_isValid) { + // break; + // } + // } - if (!_isValid) { + // if (!_isValid) { + // return _isValid; + // } + + // _isValid = false; + + if (!checkProtoMark(_proto)) { return _isValid; } - _isValid = false; - _host = std::string_view{found.end(), _endpoint.end()}; if (_proto == protoMarkLocal) { // local proto allows only hostname _path = std::string_view(); @@ -220,6 +228,13 @@ protected: int _port; bool _isValid; + + virtual bool checkProtoMark(std::string_view proto_mark) + { + return std::ranges::any_of(AdcEndpointParser::validProtoMarks, + [proto_mark](const auto& el) { return el == proto_mark; }); + } + enum EndpointPart { PROTO_PART, HOST_PART, PATH_PART }; template diff --git a/net/asio/adc_netservice_asio.h b/net/asio/adc_netservice_asio.h index a9381d2..fa0b58b 100644 --- a/net/asio/adc_netservice_asio.h +++ b/net/asio/adc_netservice_asio.h @@ -266,7 +266,8 @@ public: // NOTE: CANNOT MOVE asio::streambuf CORRECTLY?!!! - AdcNetServiceASIOBase(AdcNetServiceASIOBase&& other) = delete; + AdcNetServiceASIOBase(AdcNetServiceASIOBase&& other) = default; + // AdcNetServiceASIOBase(AdcNetServiceASIOBase&& other) = delete; AdcNetServiceASIOBase(const AdcNetServiceASIOBase&) = delete; // no copy constructor! virtual ~AdcNetServiceASIOBase() {} @@ -274,7 +275,8 @@ public: AdcNetServiceASIOBase& operator=(const AdcNetServiceASIOBase&) = delete; - AdcNetServiceASIOBase& operator=(AdcNetServiceASIOBase&& other) = delete; + // AdcNetServiceASIOBase& operator=(AdcNetServiceASIOBase&& other) = delete; + AdcNetServiceASIOBase& operator=(AdcNetServiceASIOBase&& other) = default; constexpr netservice_ident_t ident() const @@ -362,6 +364,8 @@ public: template auto asyncReceive(TokenT&& token, const TimeoutT& timeout = DEFAULT_RECEIVE_TIMEOUT) { + static asio::streambuf _streamBuffer; + // check completion token signature and deduce message type // if constexpr (!adc_asio_special_comp_token_c && !is_async_ctx_t) { if constexpr (!adc_asio_special_comp_token_c) { @@ -562,7 +566,7 @@ protected: socket_t _socket; - asio::streambuf _streamBuffer; + // asio::streambuf _streamBuffer; std::queue> _receiveQueue;