cemu-vcpkg/toolsrc/src/triplet.cpp

57 lines
1.7 KiB
C++
Raw Normal View History

2017-01-27 12:49:09 -08:00
#include "pch.h"
2017-04-03 15:02:45 -07:00
#include "Triplet.h"
2016-09-18 20:50:08 -07:00
#include "vcpkg_Checks.h"
2017-02-15 20:39:49 -08:00
#include "vcpkg_Strings.h"
2016-09-18 20:50:08 -07:00
namespace vcpkg
{
2017-04-03 15:02:45 -07:00
const Triplet Triplet::X86_WINDOWS = from_canonical_name("x86-windows");
const Triplet Triplet::X64_WINDOWS = from_canonical_name("x64-windows");
const Triplet Triplet::X86_UWP = from_canonical_name("x86-uwp");
const Triplet Triplet::X64_UWP = from_canonical_name("x64-uwp");
const Triplet Triplet::ARM_UWP = from_canonical_name("arm-uwp");
2016-09-18 20:50:08 -07:00
2017-04-03 15:02:45 -07:00
bool operator==(const Triplet& left, const Triplet& right)
2016-09-18 20:50:08 -07:00
{
return left.canonical_name() == right.canonical_name();
2016-09-18 20:50:08 -07:00
}
2017-04-03 15:02:45 -07:00
bool operator!=(const Triplet& left, const Triplet& right)
2016-09-18 20:50:08 -07:00
{
return !(left == right);
}
2017-04-03 15:02:45 -07:00
Triplet Triplet::from_canonical_name(const std::string& triplet_as_string)
{
2017-02-15 20:39:49 -08:00
const std::string s(Strings::ascii_to_lowercase(triplet_as_string));
auto it = std::find(s.cbegin(), s.cend(), '-');
Checks::check_exit(VCPKG_LINE_INFO, it != s.cend(), "Invalid triplet: %s", triplet_as_string);
2017-04-03 15:02:45 -07:00
Triplet t;
t.m_canonical_name = s;
return t;
}
2017-04-03 15:02:45 -07:00
const std::string& Triplet::canonical_name() const
{
return this->m_canonical_name;
}
2017-04-03 15:02:45 -07:00
std::string Triplet::architecture() const
2016-09-18 20:50:08 -07:00
{
auto it = std::find(this->m_canonical_name.cbegin(), this->m_canonical_name.cend(), '-');
return std::string(this->m_canonical_name.cbegin(), it);
2016-09-18 20:50:08 -07:00
}
2017-04-03 15:02:45 -07:00
std::string Triplet::system() const
2016-09-18 20:50:08 -07:00
{
auto it = std::find(this->m_canonical_name.cbegin(), this->m_canonical_name.cend(), '-');
return std::string(it + 1, this->m_canonical_name.cend());
2016-09-18 20:50:08 -07:00
}
2017-04-07 17:44:24 -07:00
const std::string& Triplet::to_string() const
{
return this->m_canonical_name;
}
2016-09-18 20:50:08 -07:00
}