...
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <ranges>
|
||||
#include <vector>
|
||||
|
||||
#include "../common/adc_traits.h"
|
||||
#include "../common/adc_utils.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -152,7 +152,7 @@ protected:
|
||||
|
||||
output_seq_t _outputSequence;
|
||||
|
||||
AdcNetMessageInterface() : _storageSequence(), _outputSequence() {};
|
||||
AdcNetMessageInterface() : _storageSequence(), _outputSequence(){};
|
||||
|
||||
template <typename T, typename... Ts>
|
||||
AdcNetMessageInterface(const T& v, const Ts&... vs) : AdcNetMessageInterface()
|
||||
@@ -292,7 +292,8 @@ public:
|
||||
auto max_el = _storageSequence.size() - start;
|
||||
N >= max_el ? max_el * 2 - 1 : N * 2 - 1;
|
||||
|
||||
std::ranges::copy(_outputSequence | std::views::drop(start * 2) | std::views::take(N), std::back_inserter(r));
|
||||
std::ranges::copy(_outputSequence | std::views::drop(start * 2) | std::views::take(N) | std::views::join,
|
||||
std::back_inserter(r));
|
||||
}
|
||||
|
||||
const output_seq_t& storageSeq() override
|
||||
@@ -374,6 +375,8 @@ public:
|
||||
this->_storageSequence.clear();
|
||||
this->_outputSequence.clear();
|
||||
|
||||
// TODO: what if key is an empty range?!!!
|
||||
|
||||
if constexpr (traits::adc_input_char_range<KeyT> || traits::formattable<KeyT>) {
|
||||
std::ranges::copy(key, std::back_inserter(_key));
|
||||
} else if constexpr (traits::formattable<KeyT>) {
|
||||
@@ -394,6 +397,7 @@ public:
|
||||
void key(R& r) const
|
||||
{
|
||||
if constexpr (std::is_convertible_v<std::string, R>) {
|
||||
r = _key;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -413,6 +417,23 @@ public:
|
||||
this->tokensBytes(r, start, N);
|
||||
}
|
||||
|
||||
|
||||
template <std::input_iterator IterT>
|
||||
void setFromBytes(IterT begin, IterT end)
|
||||
{
|
||||
auto sp = std::span(begin, end);
|
||||
|
||||
auto found = std::ranges::search(sp, keyparamDelimiter);
|
||||
|
||||
if (found.empty()) { // no parameters
|
||||
setKeyParam(sp);
|
||||
} else {
|
||||
auto N = std::ranges::distance(sp.begin(), found.begin());
|
||||
setKeyParam(sp.first(N), sp.last(sp.size() - N - keyparamDelimiter.size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
std::string _key;
|
||||
// _outputSequence will store parameters
|
||||
|
||||
Reference in New Issue
Block a user