mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-01 07:18:22 -04:00
erpt: reimplement the sysmodule (#875)
* erpt: reimplement the sysmodule * fatal: update for latest bindings * erpt: amend logic for culling orphan attachments
This commit is contained in:
parent
eca5ac01b8
commit
79b9e07ee9
117 changed files with 6716 additions and 59 deletions
|
@ -178,9 +178,9 @@ namespace ams::util {
|
|||
constexpr BitFlagSet<N, T> operator^(const BitFlagSet<N, T> &rhs) const { BitFlagSet<N, T> v = *this; v ^= rhs; return v; }
|
||||
constexpr BitFlagSet<N, T> operator|(const BitFlagSet<N, T> &rhs) const { BitFlagSet<N, T> v = *this; v |= rhs; return v; }
|
||||
|
||||
constexpr BitFlagSet<N, T> &operator&=(const BitFlagSet<N, T> &rhs) const { ams::util::impl::AndImpl<StorageCount>(this->_storage, rhs._storage); return *this; }
|
||||
constexpr BitFlagSet<N, T> &operator^=(const BitFlagSet<N, T> &rhs) const { ams::util::impl::XorImpl<StorageCount>(this->_storage, rhs._storage); return *this; }
|
||||
constexpr BitFlagSet<N, T> &operator|=(const BitFlagSet<N, T> &rhs) const { ams::util::impl::OrImpl<StorageCount>(this->_storage, rhs._storage); return *this; }
|
||||
constexpr BitFlagSet<N, T> &operator&=(const BitFlagSet<N, T> &rhs) { ams::util::impl::AndImpl<StorageCount>(this->_storage, rhs._storage); return *this; }
|
||||
constexpr BitFlagSet<N, T> &operator^=(const BitFlagSet<N, T> &rhs) { ams::util::impl::XorImpl<StorageCount>(this->_storage, rhs._storage); return *this; }
|
||||
constexpr BitFlagSet<N, T> &operator|=(const BitFlagSet<N, T> &rhs) { ams::util::impl::OrImpl<StorageCount>(this->_storage, rhs._storage); return *this; }
|
||||
};
|
||||
|
||||
template<size_t N, typename T>
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020 Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours/common.hpp>
|
||||
#include <vapours/assert.hpp>
|
||||
|
||||
namespace ams::util {
|
||||
|
||||
template<typename T>
|
||||
constexpr int Strlcpy(T *dst, const T *src, int count) {
|
||||
AMS_ASSERT(dst != nullptr);
|
||||
AMS_ASSERT(src != nullptr);
|
||||
|
||||
const T *cur = src;
|
||||
if (count > 0) {
|
||||
while ((--count) && *cur) {
|
||||
*(dst++) = *(cur++);
|
||||
}
|
||||
*dst = 0;
|
||||
}
|
||||
|
||||
while (*cur) {
|
||||
cur++;
|
||||
}
|
||||
|
||||
return static_cast<int>(cur - src);
|
||||
}
|
||||
|
||||
}
|
|
@ -21,20 +21,60 @@
|
|||
namespace ams::util {
|
||||
|
||||
struct Uuid {
|
||||
static constexpr size_t Size = 0x10;
|
||||
static constexpr size_t Size = 0x10;
|
||||
static constexpr size_t StringSize = sizeof("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
|
||||
|
||||
u8 data[Size];
|
||||
|
||||
bool operator==(const Uuid &rhs) const {
|
||||
return std::memcmp(this->data, rhs.data, Size) == 0;
|
||||
friend bool operator==(const Uuid &lhs, const Uuid &rhs) {
|
||||
return std::memcmp(lhs.data, rhs.data, Size) == 0;
|
||||
}
|
||||
|
||||
bool operator!=(const Uuid &rhs) const {
|
||||
return !(*this == rhs);
|
||||
friend bool operator!=(const Uuid &lhs, const Uuid &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
u8 operator[](size_t i) const {
|
||||
return this->data[i];
|
||||
const char *ToString(char *dst, size_t dst_size) const {
|
||||
std::snprintf(dst, dst_size, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
this->data[ 0], this->data[ 1], this->data[ 2], this->data[ 3], this->data[ 4], this->data[ 5], this->data[ 6], this->data[ 7],
|
||||
this->data[ 8], this->data[ 9], this->data[10], this->data[11], this->data[12], this->data[13], this->data[14], this->data[15]);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
void FromString(const char *str) {
|
||||
char buf[2 + 1] = {};
|
||||
char *end;
|
||||
s32 i = 0;
|
||||
|
||||
for (/* ... */; i < 4; ++i, str += 2) {
|
||||
std::memcpy(buf, str, 2);
|
||||
this->data[i] = static_cast<u8>(std::strtoul(buf, std::addressof(end), 16));
|
||||
}
|
||||
++str;
|
||||
|
||||
for (/* ... */; i < 6; ++i, str += 2) {
|
||||
std::memcpy(buf, str, 2);
|
||||
this->data[i] = static_cast<u8>(std::strtoul(buf, std::addressof(end), 16));
|
||||
}
|
||||
++str;
|
||||
|
||||
for (/* ... */; i < 8; ++i, str += 2) {
|
||||
std::memcpy(buf, str, 2);
|
||||
this->data[i] = static_cast<u8>(std::strtoul(buf, std::addressof(end), 16));
|
||||
}
|
||||
++str;
|
||||
|
||||
for (/* ... */; i < 10; ++i, str += 2) {
|
||||
std::memcpy(buf, str, 2);
|
||||
this->data[i] = static_cast<u8>(std::strtoul(buf, std::addressof(end), 16));
|
||||
}
|
||||
++str;
|
||||
|
||||
for (/* ... */; i < 16; ++i, str += 2) {
|
||||
std::memcpy(buf, str, 2);
|
||||
this->data[i] = static_cast<u8>(std::strtoul(buf, std::addressof(end), 16));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue