22
22
#include "uintdatainformation.h"
24
#include <QtScript/QScriptEngine>
27
template<typename T, PrimitiveDataType typeValue>
28
QScriptValue UIntDataInformation<T, typeValue>::asScriptValue(T value, QScriptEngine* engine,
24
#include <QtScript/QScriptValue>
30
QScriptValue UIntDataInformation<T>::asScriptValue(T value, QScriptEngine* engine,
29
31
ScriptHandlerInfo* handlerInfo)
42
44
return QScriptValue(QString::number(value, 10));
45
template<typename T, PrimitiveDataType typeValue>
46
QScriptValue UIntDataInformation<T, typeValue>::valueAsQScriptValue() const
48
QScriptValue UIntDataInformation<T>::valueAsQScriptValue() const
48
return UIntDataInformation<T, typeValue>::asScriptValue(UnsignedDataInformation<T>::mValue, 0, 0);
50
return UIntDataInformation<T>::asScriptValue(UnsignedDataInformation<T>::mValue, 0, 0);
51
template<typename T, PrimitiveDataType typeValue>
52
QString UIntDataInformation<T, typeValue>::valueString() const
54
QString UIntDataInformation<T>::valueString() const
54
if (!UIntDataInformation::mWasAbleToRead)
56
if (!this->mWasAbleToRead)
55
57
return i18nc("invalid value (out of range)", "<invalid>");
56
return UIntDataInformation<T, typeValue>::valueString(UnsignedDataInformation<T>::mValue);
58
return UIntDataInformation<T>::valueString(UnsignedDataInformation<T>::mValue);
59
template<typename T, PrimitiveDataType typeValue>
60
QString UIntDataInformation<T, typeValue>::valueString(T value)
62
QString UIntDataInformation<T>::valueString(T value, int base)
62
int base = UnsignedDataInformation<T>::displayBase();
63
64
QString num = QString::number(value, base);
65
num.prepend(QLatin1String("0x"));
67
num.prepend(QLatin1String("0b"));
69
num.prepend(QLatin1String("0o"));
70
else if (base == 10 && Kasten1::StructViewPreferences::localeAwareDecimalFormatting())
71
num = KGlobal::locale()->formatNumber(num, false, 0);
67
if (Kasten2::StructViewPreferences::localeAwareDecimalFormatting())
68
num = KGlobal::locale()->formatNumber(num, false, 0);
72
//add one space every 8 chars
73
for (int i = 8; i < num.length(); i += 9) {
74
num.insert(num.length() - i, QLatin1Char(' '));
77
num.prepend(QLatin1String("0x"));
79
num.prepend(QLatin1String("0b"));
81
num.prepend(QLatin1String("0o"));
83
kDebug() << "unsupported number base" << base;
75
88
//explicitly instantiate all valid classes (c++-faq-lite 35.12)
76
template class UIntDataInformation<quint8, Type_UInt8>;
77
template class UIntDataInformation<quint16, Type_UInt16>;
78
template class UIntDataInformation<quint32, Type_UInt32>;
79
template class UIntDataInformation<quint64, Type_UInt64>;
89
template class UIntDataInformation<quint8>;
90
template class UIntDataInformation<quint16>;
91
template class UIntDataInformation<quint32>;
92
template class UIntDataInformation<quint64>;