nstool/lib/libhac/source/MiscFlagsHandler.cpp

89 lines
1.7 KiB
C++
Raw Permalink Normal View History

2018-08-07 07:17:51 +00:00
#include <nn/hac/MiscFlagsHandler.h>
2018-08-07 07:17:51 +00:00
nn::hac::MiscFlagsHandler::MiscFlagsHandler() :
mIsSet(false)
{}
2018-08-07 07:17:51 +00:00
void nn::hac::MiscFlagsHandler::operator=(const MiscFlagsHandler & other)
{
mIsSet = other.mIsSet;
mFlags = other.mFlags;
}
2018-08-07 07:17:51 +00:00
bool nn::hac::MiscFlagsHandler::operator==(const MiscFlagsHandler & other) const
{
return (mIsSet == other.mIsSet) \
&& (mFlags == other.mFlags);
}
2018-08-07 07:17:51 +00:00
bool nn::hac::MiscFlagsHandler::operator!=(const MiscFlagsHandler & other) const
{
return !(*this == other);
}
2018-08-07 07:17:51 +00:00
void nn::hac::MiscFlagsHandler::importKernelCapabilityList(const fnd::List<KernelCapabilityEntry>& caps)
{
if (caps.size() > kMaxKernelCapNum)
{
throw fnd::Exception(kModuleName, "Too many kernel capabilities");
}
if (caps.size() == 0)
return;
MiscFlagsEntry entry;
entry.setKernelCapability(caps[0]);
clear();
2018-03-22 05:26:22 +00:00
for (uint32_t i = 0; i < FLAG_NUM; i++)
{
if ((entry.getFlags() & BIT(i)) == BIT(i))
{
mFlags.addElement((Flags)i);
}
}
mIsSet = true;
}
2018-08-07 07:17:51 +00:00
void nn::hac::MiscFlagsHandler::exportKernelCapabilityList(fnd::List<KernelCapabilityEntry>& caps) const
{
if (isSet() == false)
return;
// convert list to word flags
2018-03-22 05:26:22 +00:00
uint32_t flag = 0;
for (size_t i = 0; i < mFlags.size(); i++)
{
flag |= BIT(mFlags[i]);
}
// create MiscFlag entry
MiscFlagsEntry entry;
entry.setFlags(flag);
// add to list
caps.addElement(entry.getKernelCapability());
}
2018-08-07 07:17:51 +00:00
void nn::hac::MiscFlagsHandler::clear()
{
mIsSet = false;
mFlags.clear();
}
2018-08-07 07:17:51 +00:00
bool nn::hac::MiscFlagsHandler::isSet() const
{
return mIsSet;
}
2018-08-07 07:17:51 +00:00
const fnd::List<nn::hac::MiscFlagsHandler::Flags>& nn::hac::MiscFlagsHandler::getFlagList() const
{
return mFlags;
}
2018-08-07 07:17:51 +00:00
void nn::hac::MiscFlagsHandler::setFlagList(fnd::List<Flags> flags)
{
mFlags = flags;
mIsSet = true;
}