This commit is contained in:
2025-10-08 18:13:46 +03:00
parent 27dccfe7c0
commit e0e10395fb
5 changed files with 384 additions and 49 deletions

View File

@@ -16,7 +16,7 @@ namespace mcc::utils
static const std::regex decimalNumberRx{" *[-+]?([0-9]*[.])?[0-9]+([eE][-+]?[0-9]+)? *"};
static const std::regex sexagesimalReprRx{" *[-+]?[0-9]{1,2}:[0-9]{1,2}:([0-9]{0,2}[.])?[0-9]+ *"};
static bool isEqual(std::floating_point auto const& v1, std::floating_point auto const& v2)
constexpr static bool isEqual(std::floating_point auto const& v1, std::floating_point auto const& v2)
{
constexpr auto eps = std::numeric_limits<std::common_type_t<decltype(v1), decltype(v2)>>::epsilon();
@@ -26,7 +26,7 @@ static bool isEqual(std::floating_point auto const& v1, std::floating_point auto
enum class TrimType { TRIM_LEFT, TRIM_RIGHT, TRIM_BOTH };
template <std::ranges::contiguous_range R>
static std::string_view trimSpaces(R&& r, TrimType type = TrimType::TRIM_BOTH)
constexpr static std::string_view trimSpaces(R&& r, TrimType type = TrimType::TRIM_BOTH)
requires std::same_as<char, std::remove_cvref_t<std::ranges::range_value_t<R>>>
{
auto is_space = [](const auto& ch) { return ch == ' '; };
@@ -59,7 +59,7 @@ static std::string_view trimSpaces(R&& r, TrimType type = TrimType::TRIM_BOTH)
return std::string_view(f1, f2);
}
static std::string_view trimSpaces(const char* r, TrimType type = TrimType::TRIM_BOTH)
constexpr static std::string_view trimSpaces(const char* r, TrimType type = TrimType::TRIM_BOTH)
{
return trimSpaces(std::string_view(r), type);
}
@@ -404,7 +404,15 @@ static constexpr size_t FNV1aHash(std::forward_iterator auto begin, std::sentine
class MccSimpleDeserializer
{
public:
static constexpr std::string RANGE_DELIM_SEQ = ",";
static constexpr std::string_view RANGE_DELIM_SEQ = ",";
MccSimpleDeserializer() : _rangeDelim(RANGE_DELIM_SEQ) {}
template <traits::mcc_input_char_range R>
MccSimpleDeserializer(R&& r) : MccSimpleDeserializer()
{
setRangeDelim(std::forward<R>(r));
}
template <traits::mcc_input_char_range R>
MccSimpleDeserializer& setRangeDelim(R&& r)
@@ -485,7 +493,7 @@ public:
}
protected:
std::string _rangeDelim{RANGE_DELIM_SEQ};
std::string _rangeDelim;
};