mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-24 04:00:02 +01:00
- remove common lib - split settings, remove common-md - move ipc interop/kb_layout to interop - rename core -> settings, settings -> old_settings - os-detect header-only; interop -> PowerToysInterop - split notifications, move single-use headers where they're used - winstore lib - rename com utils - rename Updating and Telemetry projects - rename core -> settings-ui and remove examples folder - rename settings-ui folder + consisent common/version include
42 lines
962 B
C++
42 lines
962 B
C++
#include "helper.h"
|
|
|
|
#include "../utils/string_utils.h"
|
|
|
|
#include <algorithm>
|
|
#include <sstream>
|
|
|
|
VersionHelper::VersionHelper(std::string str)
|
|
{
|
|
// Remove whitespaces chars and a leading 'v'
|
|
str = left_trim<char>(trim<char>(str), "v");
|
|
// Replace '.' with spaces
|
|
replace_chars(str, ".", ' ');
|
|
|
|
std::istringstream ss{ str };
|
|
ss >> major;
|
|
ss >> minor;
|
|
ss >> revision;
|
|
if (ss.fail() || !ss.eof())
|
|
{
|
|
throw std::logic_error("VersionHelper: couldn't parse the supplied version string");
|
|
}
|
|
}
|
|
|
|
VersionHelper::VersionHelper(const size_t major, const size_t minor, const size_t revision) :
|
|
major{ major },
|
|
minor{ minor },
|
|
revision{ revision }
|
|
{
|
|
}
|
|
|
|
std::wstring VersionHelper::toWstring() const
|
|
{
|
|
std::wstring result{ L"v" };
|
|
result += std::to_wstring(major);
|
|
result += L'.';
|
|
result += std::to_wstring(minor);
|
|
result += L'.';
|
|
result += std::to_wstring(revision);
|
|
return result;
|
|
}
|