ADC/net/adc_device_netmsg.h
2024-10-04 17:26:15 +03:00

56 lines
1.6 KiB
C++

#pragma once
#include "../common/adc_utils.h"
#include "adc_netmsg.h"
namespace adc
{
/* ABSTRACT DEVICE DEFAULT APPLICATION-LEVEL NETWORK PROTOCOL DEFINITIONS */
namespace constants
{
static constexpr char ADC_DEFAULT_KEY_PARAM_DELIMITER[] = " ";
static constexpr char ADC_DEFAULT_PARAM_PARAM_DELIMITER[] = " ";
} // namespace constants
template <traits::adc_output_char_range ByteSeqT>
class AdcDeviceNetMessage : protected AdcKeyValueMessage<ByteSeqT, constants::ADC_DEFAULT_KEY_PARAM_DELIMITER>
{
using base_t = AdcKeyValueMessage<ByteSeqT, constants::ADC_DEFAULT_KEY_PARAM_DELIMITER>;
public:
static constexpr std::span keyParamDelimiter{constants::ADC_DEFAULT_KEY_PARAM_DELIMITER,
sizeof(constants::ADC_DEFAULT_KEY_PARAM_DELIMITER)};
static constexpr std::span paramParamDelimiter{constants::ADC_DEFAULT_PARAM_PARAM_DELIMITER,
sizeof(constants::ADC_DEFAULT_PARAM_PARAM_DELIMITER)};
AdcDeviceNetMessage(ByteSeqT& byte_seq) : base_t(byte_seq) {}
template <traits::adc_char_view VT>
VT keyword() const
{
auto v = utils::AdcTrimSpaces(base_t::template key<VT>());
return VT(v.begin(), v.end());
}
auto keyword() const
{
return keyword<std::string_view>();
}
template <traits::adc_range_of_view_char_range R>
auto params(size_t start = 0, size_t N = std::numeric_limits<size_t>::max())
{
auto val = base_t::template value<std::ranges::range_value_t<R>>();
}
};
} // namespace adc