代码拉取完成,页面将自动刷新
#include "sample.h"
#include <QtEndian>
#include <QDebug>
sample::sample()
{
static_assert(Q_BYTE_ORDER == Q_LITTLE_ENDIAN, "Only supports LITTLE ENDIAN");
}
uint32_t sample::getRgb() const
{
typedef decltype(state.val) T;
const decltype(state) s{qFromBigEndian<T>(state.val)};
return s.rgb;
}
uint32_t sample::getBed() const
{
const decltype(state) s {qFromBigEndian<uint32_t>(state.val)};
return s.bed;
}
uint32_t sample::getKitchen() const
{
const decltype(state) s{qFromBigEndian<uint32_t>(state.val)};
return s.kitchen;
}
void sample::setRgb(uint32_t newRgb)
{
decltype(state) s {qFromBigEndian<uint32_t>(state.val)};
s.rgb = newRgb;
state.val = qToBigEndian<uint32_t>(s.val);
// Q_ASSERT(false);
}
namespace
{
constexpr double factor = 8.38190317e-8;
}
double sample::getLongitude() const
{
double ret = qFromBigEndian<decltype(longitude)>(longitude);
ret *= factor;
return ret;
}
void sample::setLongitude(double newLongitude)
{
decltype(longitude) v1 = newLongitude / factor;
auto v2 = qToBigEndian<decltype(longitude)>(v1);
longitude = v2;
}
void sample::print() const
{
qDebug() << "<" << "longtitude=" << getLongitude()
<< ",bed=" << this->getBed()
<< ",kitchen=" << this->getKitchen()
<< ",rgb=" << this->getRgb();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。