2018-08-07 07:17:51 +00:00
|
|
|
#include <nn/hac/ServiceAccessControlBinary.h>
|
2018-06-29 04:00:15 +00:00
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
nn::hac::ServiceAccessControlBinary::ServiceAccessControlBinary()
|
2018-06-29 04:00:15 +00:00
|
|
|
{
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
nn::hac::ServiceAccessControlBinary::ServiceAccessControlBinary(const ServiceAccessControlBinary & other)
|
2018-06-29 04:00:15 +00:00
|
|
|
{
|
|
|
|
*this = other;
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
void nn::hac::ServiceAccessControlBinary::operator=(const ServiceAccessControlBinary & other)
|
2018-06-29 04:00:15 +00:00
|
|
|
{
|
|
|
|
mRawBinary = other.mRawBinary;
|
|
|
|
mServices = other.mServices;
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
bool nn::hac::ServiceAccessControlBinary::operator==(const ServiceAccessControlBinary & other) const
|
2018-06-29 04:00:15 +00:00
|
|
|
{
|
|
|
|
return (mServices == other.mServices);
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
bool nn::hac::ServiceAccessControlBinary::operator!=(const ServiceAccessControlBinary & other) const
|
2018-06-29 04:00:15 +00:00
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
void nn::hac::ServiceAccessControlBinary::toBytes()
|
2018-06-29 04:00:15 +00:00
|
|
|
{
|
|
|
|
size_t totalSize = 0;
|
|
|
|
for (size_t i = 0; i < mServices.size(); i++)
|
|
|
|
{
|
|
|
|
mServices[i].toBytes();
|
|
|
|
totalSize += mServices[i].getBytes().size();
|
|
|
|
}
|
|
|
|
|
|
|
|
mRawBinary.alloc(totalSize);
|
|
|
|
for (size_t i = 0, pos = 0; i < mServices.size(); pos += mServices[i].getBytes().size(), i++)
|
|
|
|
{
|
|
|
|
memcpy((mRawBinary.data() + pos), mServices[i].getBytes().data(), mServices[i].getBytes().size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
void nn::hac::ServiceAccessControlBinary::fromBytes(const byte_t* data, size_t len)
|
2018-06-29 04:00:15 +00:00
|
|
|
{
|
|
|
|
clear();
|
|
|
|
mRawBinary.alloc(len);
|
|
|
|
memcpy(mRawBinary.data(), data, mRawBinary.size());
|
|
|
|
|
|
|
|
ServiceAccessControlEntry sac;
|
|
|
|
for (size_t pos = 0; pos < len; pos += mServices.atBack().getBytes().size())
|
|
|
|
{
|
|
|
|
sac.fromBytes((const byte_t*)(mRawBinary.data() + pos), len - pos);
|
|
|
|
mServices.addElement(sac);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
const fnd::Vec<byte_t>& nn::hac::ServiceAccessControlBinary::getBytes() const
|
2018-06-29 04:00:15 +00:00
|
|
|
{
|
|
|
|
return mRawBinary;
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
void nn::hac::ServiceAccessControlBinary::clear()
|
2018-06-29 04:00:15 +00:00
|
|
|
{
|
|
|
|
mRawBinary.clear();
|
|
|
|
mServices.clear();
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
const fnd::List<nn::hac::ServiceAccessControlEntry>& nn::hac::ServiceAccessControlBinary::getServiceList() const
|
2018-06-29 04:00:15 +00:00
|
|
|
{
|
|
|
|
return mServices;
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
void nn::hac::ServiceAccessControlBinary::addService(const ServiceAccessControlEntry& service)
|
2018-06-29 04:00:15 +00:00
|
|
|
{
|
|
|
|
mServices.addElement(service);
|
|
|
|
}
|