Always storing MBID in lowercase to avoid silly duplicates
This commit is contained in:
@@ -98,15 +98,25 @@ stringTrimEnd(const std::string& str, const std::string& whitespace)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
stringToLower(const std::string& str)
|
stringToLower(std::string_view str)
|
||||||
{
|
{
|
||||||
return boost::algorithm::to_lower_copy(str);
|
std::string res;
|
||||||
|
res.reserve(str.size());
|
||||||
|
|
||||||
|
std::transform(std::cbegin(str), std::cend(str), std::back_inserter(res), [](char c) { return std::tolower(c);});
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
stringToUpper(const std::string& str)
|
stringToUpper(const std::string& str)
|
||||||
{
|
{
|
||||||
return boost::to_upper_copy<std::string>(str);
|
std::string res;
|
||||||
|
res.reserve(str.size());
|
||||||
|
|
||||||
|
std::transform(std::cbegin(str), std::cend(str), std::back_inserter(res), [](char c) { return std::toupper(c);});
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
|
||||||
|
#include "utils/String.hpp"
|
||||||
|
|
||||||
namespace StringUtils
|
namespace StringUtils
|
||||||
{
|
{
|
||||||
template <>
|
template <>
|
||||||
@@ -40,6 +42,10 @@ stringIsUUID(std::string_view str)
|
|||||||
return std::regex_match(std::cbegin(str), std::cend(str), re);
|
return std::regex_match(std::cbegin(str), std::cend(str), re);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UUID::UUID(std::string_view str)
|
||||||
|
: _value {StringUtils::stringToLower(str)}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<UUID>
|
std::optional<UUID>
|
||||||
UUID::fromString(std::string_view str)
|
UUID::fromString(std::string_view str)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ std::string
|
|||||||
stringTrimEnd(const std::string& str, const std::string& whitespaces = " \t");
|
stringTrimEnd(const std::string& str, const std::string& whitespaces = " \t");
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
stringToLower(const std::string& str);
|
stringToLower(std::string_view str);
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
stringToUpper(const std::string& str);
|
stringToUpper(const std::string& str);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class UUID
|
|||||||
std::string_view getAsString() const { return _value; }
|
std::string_view getAsString() const { return _value; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UUID(std::string_view value) : _value {value} {}
|
UUID(std::string_view value);
|
||||||
std::string _value;
|
std::string _value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user