...
This commit is contained in:
@@ -493,18 +493,6 @@ template <typename T>
|
||||
concept mcc_netmessage_c = requires(T t) { T(); };
|
||||
|
||||
|
||||
/* helper types to format serialized celestial coordinates */
|
||||
/* it can be used as inputs in "construct" method or corresponding constructor */
|
||||
|
||||
// format of output (serialized) coordinates
|
||||
enum class MccNetMessageCoordFormat { CFMT_DEGREES, CFMT_SGM };
|
||||
|
||||
// precision of sexagesimal coordinates (number of decimal places in seconds/arcseconds)
|
||||
struct MccNetMessageCoordPrec {
|
||||
uint8_t hour_prec = 2;
|
||||
uint8_t deg_prec = 1;
|
||||
};
|
||||
|
||||
|
||||
template <mcc::traits::mcc_char_range BYTEREPR_T = std::string_view,
|
||||
mcc_netmsg_valid_keys_c BASE_T = MccNetMessageValidKeywords>
|
||||
@@ -537,7 +525,7 @@ protected:
|
||||
if (value == MccCoordPairKind::COORDS_KIND_UNKNOWN) {
|
||||
return std::make_error_code(std::errc::invalid_argument);
|
||||
}
|
||||
} else if constexpr (std::same_as<VT, MccNetMessageCoordFormat>) {
|
||||
} else if constexpr (std::same_as<VT, MccCoordinateSerializer::SerializedCoordFormat>) {
|
||||
std::string v;
|
||||
auto ec = (*this)(std::forward<IR>(bytes), v);
|
||||
if (ec) {
|
||||
@@ -545,13 +533,13 @@ protected:
|
||||
}
|
||||
|
||||
if (v.compare(MCC_COMMPROTO_KEYWORD_COORDFMT_SEXGM_STR) == 0) {
|
||||
value = MccNetMessageCoordFormat::CFMT_SGM;
|
||||
value = MccCoordinateSerializer::SerializedCoordFormat::CFMT_SGM;
|
||||
} else if (v.compare(MCC_COMMPROTO_KEYWORD_COORDFMT_FIXED_STR) == 0) {
|
||||
value = MccNetMessageCoordFormat::CFMT_DEGREES;
|
||||
value = MccCoordinateSerializer::SerializedCoordFormat::CFMT_DEGREES;
|
||||
} else {
|
||||
return std::make_error_code(std::errc::invalid_argument);
|
||||
}
|
||||
} else if constexpr (std::same_as<VT, MccNetMessageCoordPrec>) {
|
||||
} else if constexpr (std::same_as<VT, MccCoordinateSerializer::SexagesimalCoordPrec>) {
|
||||
std::vector<int64_t> v;
|
||||
auto ec = (*this)(std::forward<IR>(bytes), v);
|
||||
if (ec) {
|
||||
@@ -683,8 +671,10 @@ public:
|
||||
// fromCharRange(msg);
|
||||
// }
|
||||
|
||||
virtual ~MccNetMessage() = default;
|
||||
|
||||
template <traits::mcc_input_char_range KT>
|
||||
constexpr bool withKey(const KT& key)
|
||||
constexpr bool withKey(const KT& key) const
|
||||
{
|
||||
if constexpr (std::is_pointer_v<std::decay_t<KT>>) {
|
||||
return withKey(std::string_view{key});
|
||||
@@ -719,7 +709,7 @@ public:
|
||||
}
|
||||
|
||||
template <std::ranges::range R>
|
||||
R params(size_t start_idx = 0, size_t Nelemes = std::numeric_limits<size_t>::max())
|
||||
R params(size_t start_idx = 0, size_t Nelemes = std::numeric_limits<size_t>::max()) const
|
||||
requires(traits::mcc_view_or_output_char_range<R> || traits::mcc_range_of_char_range<R>)
|
||||
{
|
||||
if (start_idx >= _params.size()) {
|
||||
@@ -758,13 +748,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::string_view params(size_t start_idx = 0, size_t Nelemes = std::numeric_limits<size_t>::max())
|
||||
std::string_view params(size_t start_idx = 0, size_t Nelemes = std::numeric_limits<size_t>::max()) const
|
||||
{
|
||||
return params<std::string_view>(start_idx, Nelemes);
|
||||
}
|
||||
|
||||
template <traits::mcc_view_or_output_char_range R>
|
||||
R param(size_t idx)
|
||||
R param(size_t idx) const
|
||||
{
|
||||
if (idx >= _params.size()) {
|
||||
return {};
|
||||
@@ -780,7 +770,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::string_view param(size_t idx)
|
||||
std::string_view param(size_t idx) const
|
||||
{
|
||||
if (idx >= _params.size()) {
|
||||
return {};
|
||||
@@ -791,7 +781,7 @@ public:
|
||||
|
||||
|
||||
template <typename T, typename DeserFuncT>
|
||||
std::expected<T, std::error_code> paramValue(size_t idx, DeserFuncT&& deser_func)
|
||||
std::expected<T, std::error_code> paramValue(size_t idx, DeserFuncT&& deser_func) const
|
||||
{
|
||||
if (idx >= _params.size()) {
|
||||
return std::unexpected{std::make_error_code(std::errc::argument_out_of_domain)};
|
||||
@@ -808,9 +798,9 @@ public:
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::expected<T, std::error_code> paramValue(size_t idx)
|
||||
std::expected<T, std::error_code> paramValue(size_t idx) const
|
||||
{
|
||||
return paramValue<T>(idx, _defaultDeserilizer);
|
||||
return paramValue<T>(idx, _defaultDeserializer);
|
||||
}
|
||||
|
||||
|
||||
@@ -948,7 +938,7 @@ protected:
|
||||
|
||||
BYTEREPR_T _msgBuffer{};
|
||||
|
||||
inline static DefaultDeserializer _defaultDeserilizer{};
|
||||
inline static DefaultDeserializer _defaultDeserializer{};
|
||||
|
||||
DefaultSerializer _defaultSerializer{};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user