logic: fixed handling non-ascii characters in cdb path and in cdb filename and command

This commit is contained in:
mlangkabel
2018-02-13 16:10:10 +01:00
parent 4af9e42610
commit b2bad8ab05
15 changed files with 64 additions and 58 deletions
+2 -2
View File
@@ -236,12 +236,12 @@ SettingsMigrator ProjectSettings::getMigrations() const
const std::string language = migration->getValueFromSettings<std::string>(settings, "language_settings/language", "");
const std::string standard = migration->getValueFromSettings<std::string>(settings, "language_settings/standard", "");
if (language == "C" && !utility::isPrefix("c", standard))
if (language == "C" && !utility::isPrefix<std::string>("c", standard))
{
migration->setValueInSettings(settings, "language_settings/standard", "c" + standard);
}
if (language == "C++" && !utility::isPrefix("c++", standard))
if (language == "C++" && !utility::isPrefix<std::string>("c++", standard))
{
migration->setValueInSettings(settings, "language_settings/standard", "c++" + standard);
}
+1 -1
View File
@@ -58,7 +58,7 @@ FilePath::FilePath(FilePath&& other)
{
}
FilePath::FilePath(const std::string& filePath, const std::string& base)
FilePath::FilePath(const std::wstring& filePath, const std::wstring& base)
: m_path(std::make_unique<boost::filesystem::path>(boost::filesystem::absolute(filePath, base)))
, m_exists(false)
, m_checkedExists(false)
+1 -1
View File
@@ -21,7 +21,7 @@ public:
explicit FilePath(const std::wstring& filePath);
FilePath(const FilePath& other);
FilePath(FilePath&& other);
FilePath(const std::string& filePath, const std::string& base);
FilePath(const std::wstring& filePath, const std::wstring& base);
~FilePath();
boost::filesystem::path getPath() const;
-17
View File
@@ -237,23 +237,6 @@ namespace utility
return str;
}
bool isPrefix(const std::string& prefix, const std::string& text)
{
if (prefix.size() <= text.size())
{
std::pair<std::string::const_iterator, std::string::const_iterator> res =
std::mismatch(prefix.begin(), prefix.end(), text.begin());
return res.first == prefix.end();
}
return false;
}
bool isPostfix(const std::string& postfix, const std::string& text)
{
return text.size() >= postfix.size() && text.rfind(postfix) == (text.size() - postfix.size());
}
std::string toUpperCase(const std::string& in)
{
std::string out;
+24 -2
View File
@@ -49,8 +49,11 @@ namespace utility
std::string substrBetween(const std::string& str, const std::string& delimiter1, const std::string& delimiter2);
bool isPrefix(const std::string& prefix, const std::string& text);
bool isPostfix(const std::string& postfix, const std::string& text);
template <typename StringType>
bool isPrefix(const StringType& prefix, const StringType& text);
template <typename StringType>
bool isPostfix(const StringType& postfix, const StringType& text);
std::string toUpperCase(const std::string& in);
std::string toLowerCase(const std::string& in);
@@ -154,6 +157,25 @@ namespace utility
return ss.str();
}
template <typename StringType>
bool isPrefix(const StringType& prefix, const StringType& text)
{
if (prefix.size() <= text.size())
{
std::pair<StringType::const_iterator, StringType::const_iterator> res =
std::mismatch(prefix.begin(), prefix.end(), text.begin());
return res.first == prefix.end();
}
return false;
}
template <typename StringType>
bool isPostfix(const StringType& postfix, const StringType& text)
{
return text.size() >= postfix.size() && text.rfind(postfix) == (text.size() - postfix.size());
}
template <typename StringType>
bool equalsCaseInsensitive(const StringType& a, const StringType& b)
{