ncm: update enums, refactor comparison operators

This commit is contained in:
Michael Scire 2022-10-18 11:10:17 -07:00
parent 05fee5d53c
commit 8ce4f19615
7 changed files with 52 additions and 49 deletions

View File

@ -27,6 +27,7 @@ namespace ams::ncm {
ContentMetaAttribute_None = (0 << 0), ContentMetaAttribute_None = (0 << 0),
ContentMetaAttribute_IncludesExFatDriver = (1 << 0), ContentMetaAttribute_IncludesExFatDriver = (1 << 0),
ContentMetaAttribute_Rebootless = (1 << 1), ContentMetaAttribute_Rebootless = (1 << 1),
ContentMetaAttribute_Compacted = (1 << 2),
}; };
struct ContentMetaInfo { struct ContentMetaInfo {
@ -101,7 +102,7 @@ namespace ams::ncm {
u32 required_application_version; u32 required_application_version;
u8 content_accessibilities; u8 content_accessibilities;
u8 padding[3]; u8 padding[3];
u64 data_patch_id; /* TODO: DataPatchId? */ DataPatchId data_patch_id;
}; };
struct LegacyAddOnContentMetaExtendedHeader { struct LegacyAddOnContentMetaExtendedHeader {

View File

@ -26,6 +26,9 @@ namespace ams::ncm {
return { this->value }; return { this->value };
} }
constexpr inline bool operator==(const ApplicationId &) const = default;
constexpr inline bool operator!=(const ApplicationId &) const = default;
static const ApplicationId Start; static const ApplicationId Start;
static const ApplicationId End; static const ApplicationId End;
}; };
@ -53,6 +56,9 @@ namespace ams::ncm {
constexpr operator ProgramId() const { constexpr operator ProgramId() const {
return { this->value }; return { this->value };
} }
constexpr inline bool operator==(const PatchId &) const = default;
constexpr inline bool operator!=(const PatchId &) const = default;
}; };
struct PatchGroupId { struct PatchGroupId {
@ -65,6 +71,9 @@ namespace ams::ncm {
constexpr operator DataId() const { constexpr operator DataId() const {
return { this->value }; return { this->value };
} }
constexpr inline bool operator==(const AddOnContentId &) const = default;
constexpr inline bool operator!=(const AddOnContentId &) const = default;
}; };
struct DeltaId { struct DeltaId {
@ -73,6 +82,20 @@ namespace ams::ncm {
constexpr operator ProgramId() const { constexpr operator ProgramId() const {
return { this->value }; return { this->value };
} }
constexpr inline bool operator==(const DeltaId &) const = default;
constexpr inline bool operator!=(const DeltaId &) const = default;
};
struct DataPatchId {
u64 value;
constexpr operator DataId() const {
return { this->value };
}
constexpr inline bool operator==(const DataPatchId &) const = default;
constexpr inline bool operator!=(const DataPatchId &) const = default;
}; };
} }

View File

@ -29,6 +29,7 @@ namespace ams::ncm {
Patch = 0x81, Patch = 0x81,
AddOnContent = 0x82, AddOnContent = 0x82,
Delta = 0x83, Delta = 0x83,
DataPatch = 0x84,
}; };
const char *GetContentMetaTypeString(ContentMetaType type); const char *GetContentMetaTypeString(ContentMetaType type);

View File

@ -22,32 +22,10 @@ namespace ams::ncm {
u64 value; u64 value;
static const DataId Invalid; static const DataId Invalid;
constexpr inline auto operator<=>(const DataId &) const = default;
}; };
inline constexpr bool operator==(const DataId &lhs, const DataId &rhs) {
return lhs.value == rhs.value;
}
inline constexpr bool operator!=(const DataId &lhs, const DataId &rhs) {
return lhs.value != rhs.value;
}
inline constexpr bool operator<(const DataId &lhs, const DataId &rhs) {
return lhs.value < rhs.value;
}
inline constexpr bool operator<=(const DataId &lhs, const DataId &rhs) {
return lhs.value <= rhs.value;
}
inline constexpr bool operator>(const DataId &lhs, const DataId &rhs) {
return lhs.value > rhs.value;
}
inline constexpr bool operator>=(const DataId &lhs, const DataId &rhs) {
return lhs.value >= rhs.value;
}
inline constexpr const DataId DataId::Invalid = {}; inline constexpr const DataId DataId::Invalid = {};
inline constexpr const DataId InvalidDataId = DataId::Invalid; inline constexpr const DataId InvalidDataId = DataId::Invalid;

View File

@ -27,32 +27,10 @@ namespace ams::ncm {
return { this->value }; return { this->value };
} }
#endif #endif
constexpr inline auto operator<=>(const ProgramId &) const = default;
}; };
inline constexpr bool operator==(const ProgramId &lhs, const ProgramId &rhs) {
return lhs.value == rhs.value;
}
inline constexpr bool operator!=(const ProgramId &lhs, const ProgramId &rhs) {
return lhs.value != rhs.value;
}
inline constexpr bool operator<(const ProgramId &lhs, const ProgramId &rhs) {
return lhs.value < rhs.value;
}
inline constexpr bool operator<=(const ProgramId &lhs, const ProgramId &rhs) {
return lhs.value <= rhs.value;
}
inline constexpr bool operator>(const ProgramId &lhs, const ProgramId &rhs) {
return lhs.value > rhs.value;
}
inline constexpr bool operator>=(const ProgramId &lhs, const ProgramId &rhs) {
return lhs.value >= rhs.value;
}
inline constexpr const ProgramId InvalidProgramId = {}; inline constexpr const ProgramId InvalidProgramId = {};
} }

View File

@ -228,6 +228,9 @@ namespace ams::ncm {
return { this->value }; return { this->value };
} }
constexpr inline bool operator==(const SystemDataId &) const = default;
constexpr inline bool operator!=(const SystemDataId &) const = default;
static const SystemDataId Start; static const SystemDataId Start;
static const SystemDataId CertStore; static const SystemDataId CertStore;
@ -340,6 +343,9 @@ namespace ams::ncm {
constexpr operator DataId() const { constexpr operator DataId() const {
return { this->value }; return { this->value };
} }
constexpr inline bool operator==(const SystemUpdateId &) const = default;
constexpr inline bool operator!=(const SystemUpdateId &) const = default;
}; };
struct SystemAppletId { struct SystemAppletId {
@ -349,6 +355,9 @@ namespace ams::ncm {
return { this->value }; return { this->value };
} }
constexpr inline bool operator==(const SystemAppletId &) const = default;
constexpr inline bool operator!=(const SystemAppletId &) const = default;
static const SystemAppletId Start; static const SystemAppletId Start;
static const SystemAppletId Qlaunch; static const SystemAppletId Qlaunch;
@ -433,6 +442,9 @@ namespace ams::ncm {
return { this->value }; return { this->value };
} }
constexpr inline bool operator==(const SystemDebugAppletId &) const = default;
constexpr inline bool operator!=(const SystemDebugAppletId &) const = default;
static const SystemDebugAppletId Start; static const SystemDebugAppletId Start;
static const SystemDebugAppletId SnapShotDumper; static const SystemDebugAppletId SnapShotDumper;
@ -465,6 +477,9 @@ namespace ams::ncm {
return static_cast<SystemAppletId>(*this); return static_cast<SystemAppletId>(*this);
} }
constexpr inline bool operator==(const LibraryAppletId &) const = default;
constexpr inline bool operator!=(const LibraryAppletId &) const = default;
static const LibraryAppletId Auth; static const LibraryAppletId Auth;
static const LibraryAppletId Controller; static const LibraryAppletId Controller;
static const LibraryAppletId Error; static const LibraryAppletId Error;
@ -527,6 +542,9 @@ namespace ams::ncm {
return static_cast<SystemAppletId>(*this); return static_cast<SystemAppletId>(*this);
} }
constexpr inline bool operator==(const WebAppletId &) const = default;
constexpr inline bool operator!=(const WebAppletId &) const = default;
static const WebAppletId Web; static const WebAppletId Web;
static const WebAppletId Shop; static const WebAppletId Shop;
static const WebAppletId OfflineWeb; static const WebAppletId OfflineWeb;
@ -558,6 +576,9 @@ namespace ams::ncm {
constexpr operator ProgramId() const { constexpr operator ProgramId() const {
return { this->value }; return { this->value };
} }
constexpr inline bool operator==(const SystemApplicationId &) const = default;
constexpr inline bool operator!=(const SystemApplicationId &) const = default;
}; };
} }

View File

@ -22,6 +22,7 @@ namespace ams::ncm {
case ContentMetaType::Application: return "Application"; case ContentMetaType::Application: return "Application";
case ContentMetaType::Patch: return "Patch"; case ContentMetaType::Patch: return "Patch";
case ContentMetaType::AddOnContent: return "AddOnContent"; case ContentMetaType::AddOnContent: return "AddOnContent";
case ContentMetaType::DataPatch: return "DataPatch";
default: return "(unknown)"; default: return "(unknown)";
} }
} }