...
This commit is contained in:
@@ -40,8 +40,6 @@ namespace adc
|
||||
|
||||
class AdcEndpointParser
|
||||
{
|
||||
typedef std::span<char> host_part_t;
|
||||
|
||||
public:
|
||||
static constexpr std::string_view protoHostDelim = "://";
|
||||
static constexpr std::string_view hostPortDelim = ":";
|
||||
@@ -117,19 +115,16 @@ public:
|
||||
|
||||
_proto = validProtoMarks[idx];
|
||||
|
||||
// _host = std::string_view{found.end(), _endpoint.end()};
|
||||
_host = host_part_t{found.end(), _endpoint.end()};
|
||||
_host = std::string_view{found.end(), _endpoint.end()};
|
||||
|
||||
auto f1 = std::ranges::search(_host, portPathDelim);
|
||||
std::string_view port_sv;
|
||||
if (f1.empty() && isLocal()) { // no path, but it is mandatory for 'local'!
|
||||
return _isValid;
|
||||
} else {
|
||||
// _host = std::string_view(_host.begin(), f1.begin());
|
||||
_host = host_part_t{found.end(), _endpoint.end()};
|
||||
_host = std::string_view(_host.begin(), f1.begin());
|
||||
|
||||
// _path = std::string_view(f1.end(), &*_endpoint.end());
|
||||
_path = std::string_view(&*f1.end(), &*_endpoint.end());
|
||||
_path = std::string_view(f1.end(), &*_endpoint.end());
|
||||
|
||||
f1 = std::ranges::search(_host, hostPortDelim);
|
||||
if (f1.empty() && !isLocal()) { // no port, but it is mandatory for non-local!
|
||||
@@ -138,8 +133,7 @@ public:
|
||||
|
||||
port_sv = std::string_view(f1.end(), _host.end());
|
||||
if (port_sv.size()) {
|
||||
// _host = std::string_view(_host.begin(), f1.begin());
|
||||
_host = host_part_t{found.end(), _endpoint.end()};
|
||||
_host = std::string_view(_host.begin(), f1.begin());
|
||||
|
||||
if (!isLocal()) {
|
||||
// convert port string to int
|
||||
@@ -165,7 +159,7 @@ public:
|
||||
}
|
||||
return ok;
|
||||
})) {
|
||||
// _host = validLocalProtoTypes[idx];
|
||||
_host = validLocalProtoTypes[idx];
|
||||
} else {
|
||||
return _isValid;
|
||||
}
|
||||
@@ -229,20 +223,17 @@ public:
|
||||
|
||||
bool isLocalStream() const
|
||||
{
|
||||
// return host() == localProtoTypeStream;
|
||||
return utils::AdcCharRangeCompare(host(), localProtoTypeStream, true);
|
||||
return host() == localProtoTypeStream;
|
||||
}
|
||||
|
||||
bool isLocalDatagram() const
|
||||
{
|
||||
// return host() == localProtoTypeDatagram;
|
||||
return utils::AdcCharRangeCompare(host(), localProtoTypeDatagram, true);
|
||||
return host() == localProtoTypeDatagram;
|
||||
}
|
||||
|
||||
bool isLocalSeqpacket() const
|
||||
{
|
||||
// return host() == localProtoTypeSeqpacket;
|
||||
return utils::AdcCharRangeCompare(host(), localProtoTypeSeqpacket, true);
|
||||
return host() == localProtoTypeSeqpacket;
|
||||
}
|
||||
|
||||
|
||||
@@ -273,9 +264,7 @@ public:
|
||||
|
||||
protected:
|
||||
std::string _endpoint;
|
||||
// std::string_view _proto, _host, _path;
|
||||
std::string_view _proto, _path;
|
||||
host_part_t _host;
|
||||
std::string_view _proto, _host, _path;
|
||||
int _port;
|
||||
bool _isValid;
|
||||
|
||||
@@ -309,54 +298,28 @@ protected:
|
||||
// return res;
|
||||
// }
|
||||
|
||||
// auto part = _proto;
|
||||
|
||||
// switch (what) {
|
||||
// case PROTO_PART:
|
||||
// part = _proto;
|
||||
// break;
|
||||
// case HOST_PART:
|
||||
// part = _host;
|
||||
// break;
|
||||
// case PATH_PART:
|
||||
// part = _path;
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
// if constexpr (std::ranges::view<R>) {
|
||||
// return R(part.begin(), part.end());
|
||||
// } else {
|
||||
// std::ranges::copy(part, std::back_inserter(res));
|
||||
// }
|
||||
auto part = _proto;
|
||||
|
||||
switch (what) {
|
||||
case PROTO_PART:
|
||||
if constexpr (std::ranges::view<R>) {
|
||||
res = R(_proto.begin(), _proto.size());
|
||||
} else {
|
||||
std::ranges::copy(_proto, std::back_inserter(res));
|
||||
}
|
||||
part = _proto;
|
||||
break;
|
||||
case HOST_PART:
|
||||
if constexpr (std::ranges::view<R>) {
|
||||
res = R(_host.begin(), _host.end());
|
||||
} else {
|
||||
std::ranges::copy(_host, std::back_inserter(res));
|
||||
}
|
||||
part = _host;
|
||||
break;
|
||||
case PATH_PART:
|
||||
if constexpr (std::ranges::view<R>) {
|
||||
res = R(_path.begin(), _path.end());
|
||||
} else {
|
||||
std::ranges::copy(_path, std::back_inserter(res));
|
||||
}
|
||||
part = _path;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if constexpr (std::ranges::view<R>) {
|
||||
return {part.begin(), part.end()};
|
||||
} else {
|
||||
std::ranges::copy(part, std::back_inserter(res));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user