...
This commit is contained in:
@@ -388,4 +388,49 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
namespace constants
|
||||
{
|
||||
|
||||
static constexpr char DEFAULT_CONVERTER_DELIMITER[] = " ";
|
||||
|
||||
} // namespace constants
|
||||
|
||||
template <const char* DELIMITER = constants::DEFAULT_CONVERTER_DELIMITER>
|
||||
class AdcDefaultValueConverter
|
||||
{
|
||||
public:
|
||||
template <typename SerializedT, typename ValueT>
|
||||
static SerializedT serialize(const ValueT& value)
|
||||
{
|
||||
SerializedT res;
|
||||
|
||||
if constexpr (traits::adc_is_tuple_v<ValueT>) {
|
||||
AdcCharRangeFromTuple(res, value, DELIMITER);
|
||||
} else if constexpr (traits::adc_input_char_range<ValueT>) {
|
||||
AdcCharRangeFromValueRange(res, value, DELIMITER);
|
||||
} else {
|
||||
res = AdcTrivialSerializer<SerializedT>(value);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
template <typename ValueT, typename SerializedT>
|
||||
static ValueT deserialize(const SerializedT& svalue)
|
||||
{
|
||||
ValueT res;
|
||||
|
||||
if constexpr (traits::adc_is_tuple_v<ValueT>) {
|
||||
AdcTupleFromCharRange(res, svalue, DELIMITER);
|
||||
} else if constexpr (traits::adc_output_char_range<ValueT>) {
|
||||
AdcValueRangeFromCharRange(res, svalue, DELIMITER);
|
||||
} else {
|
||||
res = AdcTrivialDeserializer<ValueT>(svalue);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adc::utils
|
||||
|
||||
Reference in New Issue
Block a user