mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-26 08:01:51 +08:00
#31 arbitrary value interface small refactoring
This commit is contained in:
parent
43df2d8636
commit
66dce34169
@ -212,27 +212,27 @@ namespace profiler {
|
||||
}
|
||||
|
||||
template <DataType dataType>
|
||||
const Value<dataType, false>* convertToValue() const {
|
||||
const Value<dataType, false>* toValue() const {
|
||||
return m_type == dataType ? static_cast<const Value<dataType, false>*>(this) : nullptr;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
const Value<StdToDataType<T>::data_type, false>* convertToValue() const {
|
||||
const Value<StdToDataType<T>::data_type, false>* toValue() const {
|
||||
static_assert(StdToDataType<T>::data_type != DataType::TypesCount,
|
||||
"You should use standard builtin scalar types as profiler::Value type!");
|
||||
return convertToValue<StdToDataType<T>::data_type>();
|
||||
return toValue<StdToDataType<T>::data_type>();
|
||||
}
|
||||
|
||||
template <DataType dataType>
|
||||
const Value<dataType, true>* convertToArray() const {
|
||||
const Value<dataType, true>* toArray() const {
|
||||
return m_isArray && m_type == dataType ? static_cast<const Value<dataType, true>*>(this) : nullptr;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
const Value<StdToDataType<T>::data_type, true>* convertToArray() const {
|
||||
const Value<StdToDataType<T>::data_type, true>* toArray() const {
|
||||
static_assert(StdToDataType<T>::data_type != DataType::TypesCount,
|
||||
"You should use standard builtin scalar types as profiler::Value type!");
|
||||
return convertToArray<StdToDataType<T>::data_type>();
|
||||
return toArray<StdToDataType<T>::data_type>();
|
||||
}
|
||||
}; // end of class ArbitraryValue.
|
||||
#pragma pack(pop)
|
||||
|
@ -457,18 +457,18 @@ inline QString valueString(const ::profiler::ArbitraryValue& _serializedValue)
|
||||
|
||||
switch (_serializedValue.type())
|
||||
{
|
||||
case ::profiler::DataType::Bool: return _serializedValue.convertToValue<bool>()->value() ? QStringLiteral("true") : QStringLiteral("false");
|
||||
case ::profiler::DataType::Char: return QChar(_serializedValue.convertToValue<char>()->value());
|
||||
case ::profiler::DataType::Int8: return QChar(_serializedValue.convertToValue<int8_t>()->value());
|
||||
case ::profiler::DataType::Uint8: return QString::number(_serializedValue.convertToValue<uint8_t>()->value());
|
||||
case ::profiler::DataType::Int16: return QString::number(_serializedValue.convertToValue<int16_t>()->value());
|
||||
case ::profiler::DataType::Uint16: return QString::number(_serializedValue.convertToValue<uint16_t>()->value());
|
||||
case ::profiler::DataType::Int32: return QString::number(_serializedValue.convertToValue<int32_t>()->value());
|
||||
case ::profiler::DataType::Uint32: return QString::number(_serializedValue.convertToValue<uint32_t>()->value());
|
||||
case ::profiler::DataType::Int64: return QString::number(_serializedValue.convertToValue<int64_t>()->value());
|
||||
case ::profiler::DataType::Uint64: return QString::number(_serializedValue.convertToValue<uint64_t>()->value());
|
||||
case ::profiler::DataType::Float: return QString::number(_serializedValue.convertToValue<float>()->value());
|
||||
case ::profiler::DataType::Double: return QString::number(_serializedValue.convertToValue<double>()->value());
|
||||
case ::profiler::DataType::Bool: return _serializedValue.toValue<bool>()->value() ? QStringLiteral("true") : QStringLiteral("false");
|
||||
case ::profiler::DataType::Char: return QChar(_serializedValue.toValue<char>()->value());
|
||||
case ::profiler::DataType::Int8: return QChar(_serializedValue.toValue<int8_t>()->value());
|
||||
case ::profiler::DataType::Uint8: return QString::number(_serializedValue.toValue<uint8_t>()->value());
|
||||
case ::profiler::DataType::Int16: return QString::number(_serializedValue.toValue<int16_t>()->value());
|
||||
case ::profiler::DataType::Uint16: return QString::number(_serializedValue.toValue<uint16_t>()->value());
|
||||
case ::profiler::DataType::Int32: return QString::number(_serializedValue.toValue<int32_t>()->value());
|
||||
case ::profiler::DataType::Uint32: return QString::number(_serializedValue.toValue<uint32_t>()->value());
|
||||
case ::profiler::DataType::Int64: return QString::number(_serializedValue.toValue<int64_t>()->value());
|
||||
case ::profiler::DataType::Uint64: return QString::number(_serializedValue.toValue<uint64_t>()->value());
|
||||
case ::profiler::DataType::Float: return QString::number(_serializedValue.toValue<float>()->value());
|
||||
case ::profiler::DataType::Double: return QString::number(_serializedValue.toValue<double>()->value());
|
||||
case ::profiler::DataType::String: return _serializedValue.data();
|
||||
default: return QStringLiteral("Unknown");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user