Fix inconsistent function definition
[TortoiseGit.git] / src / Utils / I18NHelper.h
bloba6a6d70dc6faed9c89f2e22f2cd7a54c3e360523
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2020 - TortoiseGit
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
21 class CI18NHelper
23 private:
24 CI18NHelper() = delete;
26 static std::wstring AdjustVersion(const std::wstring& sVer)
28 if (std::count(sVer.cbegin(), sVer.cend(), L'.') != 3)
29 return {};
31 if (auto lastDot = sVer.find_last_of(L'.'); lastDot >= wcslen(L"1.2.3")) // strip last entry; MSI also ignores the build number
32 return sVer.substr(0, lastDot + 1);
34 return {};
37 public:
38 static bool DoVersionStringsMatch(const std::wstring& sVer1, const std::wstring& sVer2)
40 auto sAdjustedVer1 = AdjustVersion(sVer1);
41 auto sAdjustedVer2 = AdjustVersion(sVer2);
43 if (sAdjustedVer1.empty() || sAdjustedVer2.empty())
44 return false;
46 return AdjustVersion(sVer1) == AdjustVersion(sVer2);