mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 00:13:08 +00:00
Add C string types
This commit is contained in:
parent
3dea1a9f81
commit
8d930b4e88
@ -81,28 +81,28 @@ public:
|
|||||||
return std::basic_string_view<T>{data};
|
return std::basic_string_view<T>{data};
|
||||||
}
|
}
|
||||||
|
|
||||||
char* begin() {
|
T* begin() {
|
||||||
if (this == nullptr) {
|
if (this == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* begin() const {
|
const T* begin() const {
|
||||||
if (this == nullptr) {
|
if (this == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* end() {
|
T* end() {
|
||||||
if (this == nullptr) {
|
if (this == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return data + N;
|
return data + N;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* end() const {
|
const T* end() const {
|
||||||
if (this == nullptr) {
|
if (this == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@ -152,6 +152,24 @@ public:
|
|||||||
static_assert(sizeof(CString<13>) == sizeof(char[13])); // Ensure size still matches a simple array
|
static_assert(sizeof(CString<13>) == sizeof(char[13])); // Ensure size still matches a simple array
|
||||||
static_assert(std::weakly_incrementable<CString<13>::Iterator>);
|
static_assert(std::weakly_incrementable<CString<13>::Iterator>);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A null-terminated wide string with a fixed maximum length
|
||||||
|
* This class is not meant to be used as a general-purpose string class
|
||||||
|
* It is meant to be used as `char[N]` where memory layout is fixed
|
||||||
|
* @tparam N Maximum length of the string
|
||||||
|
*/
|
||||||
|
template <size_t N>
|
||||||
|
using CWString = CString<N, wchar_t>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief A null-terminated 16-bit char string with a fixed maximum length
|
||||||
|
* This class is not meant to be used as a general-purpose string class
|
||||||
|
* It is meant to be used as `char[N]` where memory layout is fixed
|
||||||
|
* @tparam N Maximum length of the string
|
||||||
|
*/
|
||||||
|
template <size_t N>
|
||||||
|
using CU16String = CString<N, char16_t>;
|
||||||
|
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace Common
|
Loading…
Reference in New Issue
Block a user