2018-10-20 14:55:12 +00:00
|
|
|
#include <nn/hac/ContentMetaInfo.h>
|
|
|
|
|
|
|
|
nn::hac::ContentMetaInfo::ContentMetaInfo()
|
|
|
|
{
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
nn::hac::ContentMetaInfo::ContentMetaInfo(const ContentMetaInfo& other)
|
|
|
|
{
|
|
|
|
*this = other;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nn::hac::ContentMetaInfo::operator=(const ContentMetaInfo& other)
|
|
|
|
{
|
|
|
|
clear();
|
|
|
|
mRawBinary = other.mRawBinary;
|
|
|
|
mTitleId = other.mTitleId;
|
2018-10-22 13:07:17 +00:00
|
|
|
mTitleVersion = other.mTitleVersion;
|
2018-10-20 14:55:12 +00:00
|
|
|
mType = other.mType;
|
|
|
|
mAttributes = other.mAttributes;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nn::hac::ContentMetaInfo::operator==(const ContentMetaInfo& other) const
|
|
|
|
{
|
|
|
|
return (mTitleId == other.mTitleId) \
|
2018-10-22 13:07:17 +00:00
|
|
|
&& (mTitleVersion == other.mTitleVersion) \
|
2018-10-20 14:55:12 +00:00
|
|
|
&& (mType == other.mType) \
|
|
|
|
&& (mAttributes == other.mAttributes);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nn::hac::ContentMetaInfo::operator!=(const ContentMetaInfo& other) const
|
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nn::hac::ContentMetaInfo::toBytes()
|
|
|
|
{
|
|
|
|
mRawBinary.alloc(sizeof(sContentMetaInfo));
|
|
|
|
sContentMetaInfo* info = (sContentMetaInfo*)mRawBinary.data();
|
|
|
|
|
|
|
|
info->id = mTitleId;
|
2018-10-22 13:07:17 +00:00
|
|
|
info->version = mTitleVersion;
|
2018-10-20 14:55:12 +00:00
|
|
|
info->type = mType;
|
|
|
|
info->attributes = mAttributes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nn::hac::ContentMetaInfo::fromBytes(const byte_t* bytes, size_t len)
|
|
|
|
{
|
|
|
|
if (len < sizeof(sContentMetaInfo))
|
|
|
|
{
|
|
|
|
throw fnd::Exception(kModuleName, "ContentMetaInfo too small");
|
|
|
|
}
|
|
|
|
|
|
|
|
const sContentMetaInfo* info = (const sContentMetaInfo*)bytes;
|
|
|
|
|
|
|
|
mTitleId = info->id.get();
|
2018-10-22 13:07:17 +00:00
|
|
|
mTitleVersion = info->version.get();
|
2018-10-20 14:55:12 +00:00
|
|
|
mType = (cnmt::ContentMetaType)info->type;
|
|
|
|
mAttributes = info->attributes;
|
|
|
|
}
|
|
|
|
|
|
|
|
const fnd::Vec<byte_t>& nn::hac::ContentMetaInfo::getBytes() const
|
|
|
|
{
|
|
|
|
return mRawBinary;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nn::hac::ContentMetaInfo::clear()
|
|
|
|
{
|
|
|
|
mRawBinary.clear();
|
|
|
|
mTitleId = 0;
|
2018-10-22 13:07:17 +00:00
|
|
|
mTitleVersion = 0;
|
2018-10-20 14:55:12 +00:00
|
|
|
mType = cnmt::ContentMetaType::METATYPE_APPLICATION;
|
|
|
|
mAttributes = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t nn::hac::ContentMetaInfo::getTitleId() const
|
|
|
|
{
|
|
|
|
return mTitleId;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nn::hac::ContentMetaInfo::setTitleId(uint64_t title_id)
|
|
|
|
{
|
|
|
|
mTitleId = title_id;
|
|
|
|
}
|
|
|
|
|
2018-10-22 13:07:17 +00:00
|
|
|
uint32_t nn::hac::ContentMetaInfo::getTitleVersion() const
|
2018-10-20 14:55:12 +00:00
|
|
|
{
|
2018-10-22 13:07:17 +00:00
|
|
|
return mTitleVersion;
|
2018-10-20 14:55:12 +00:00
|
|
|
}
|
|
|
|
|
2018-10-22 13:07:17 +00:00
|
|
|
void nn::hac::ContentMetaInfo::setTitleVersion(uint32_t ver)
|
2018-10-20 14:55:12 +00:00
|
|
|
{
|
2018-10-22 13:07:17 +00:00
|
|
|
mTitleVersion = ver;
|
2018-10-20 14:55:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nn::hac::cnmt::ContentMetaType nn::hac::ContentMetaInfo::getContentMetaType() const
|
|
|
|
{
|
|
|
|
return mType;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nn::hac::ContentMetaInfo::setContentMetaType(cnmt::ContentMetaType type)
|
|
|
|
{
|
|
|
|
mType = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte_t nn::hac::ContentMetaInfo::getAttributes() const
|
|
|
|
{
|
|
|
|
return mAttributes;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nn::hac::ContentMetaInfo::setAttributes(byte_t attr)
|
|
|
|
{
|
|
|
|
mAttributes = attr;
|
|
|
|
}
|