From 66dce34169df60c4e6052ffbafe1008cb57bacf5 Mon Sep 17 00:00:00 2001 From: Victor Zarubkin Date: Mon, 20 Nov 2017 23:36:33 +0300 Subject: [PATCH] #31 arbitrary value interface small refactoring --- .../include/easy/serialized_block.h | 12 +++++----- profiler_gui/common_types.h | 24 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/easy_profiler_core/include/easy/serialized_block.h b/easy_profiler_core/include/easy/serialized_block.h index 7e555e3..1875761 100644 --- a/easy_profiler_core/include/easy/serialized_block.h +++ b/easy_profiler_core/include/easy/serialized_block.h @@ -212,27 +212,27 @@ namespace profiler { } template - const Value* convertToValue() const { + const Value* toValue() const { return m_type == dataType ? static_cast*>(this) : nullptr; } template - const Value::data_type, false>* convertToValue() const { + const Value::data_type, false>* toValue() const { static_assert(StdToDataType::data_type != DataType::TypesCount, "You should use standard builtin scalar types as profiler::Value type!"); - return convertToValue::data_type>(); + return toValue::data_type>(); } template - const Value* convertToArray() const { + const Value* toArray() const { return m_isArray && m_type == dataType ? static_cast*>(this) : nullptr; } template - const Value::data_type, true>* convertToArray() const { + const Value::data_type, true>* toArray() const { static_assert(StdToDataType::data_type != DataType::TypesCount, "You should use standard builtin scalar types as profiler::Value type!"); - return convertToArray::data_type>(); + return toArray::data_type>(); } }; // end of class ArbitraryValue. #pragma pack(pop) diff --git a/profiler_gui/common_types.h b/profiler_gui/common_types.h index ef58d07..9fbe565 100644 --- a/profiler_gui/common_types.h +++ b/profiler_gui/common_types.h @@ -457,18 +457,18 @@ inline QString valueString(const ::profiler::ArbitraryValue& _serializedValue) switch (_serializedValue.type()) { - case ::profiler::DataType::Bool: return _serializedValue.convertToValue()->value() ? QStringLiteral("true") : QStringLiteral("false"); - case ::profiler::DataType::Char: return QChar(_serializedValue.convertToValue()->value()); - case ::profiler::DataType::Int8: return QChar(_serializedValue.convertToValue()->value()); - case ::profiler::DataType::Uint8: return QString::number(_serializedValue.convertToValue()->value()); - case ::profiler::DataType::Int16: return QString::number(_serializedValue.convertToValue()->value()); - case ::profiler::DataType::Uint16: return QString::number(_serializedValue.convertToValue()->value()); - case ::profiler::DataType::Int32: return QString::number(_serializedValue.convertToValue()->value()); - case ::profiler::DataType::Uint32: return QString::number(_serializedValue.convertToValue()->value()); - case ::profiler::DataType::Int64: return QString::number(_serializedValue.convertToValue()->value()); - case ::profiler::DataType::Uint64: return QString::number(_serializedValue.convertToValue()->value()); - case ::profiler::DataType::Float: return QString::number(_serializedValue.convertToValue()->value()); - case ::profiler::DataType::Double: return QString::number(_serializedValue.convertToValue()->value()); + case ::profiler::DataType::Bool: return _serializedValue.toValue()->value() ? QStringLiteral("true") : QStringLiteral("false"); + case ::profiler::DataType::Char: return QChar(_serializedValue.toValue()->value()); + case ::profiler::DataType::Int8: return QChar(_serializedValue.toValue()->value()); + case ::profiler::DataType::Uint8: return QString::number(_serializedValue.toValue()->value()); + case ::profiler::DataType::Int16: return QString::number(_serializedValue.toValue()->value()); + case ::profiler::DataType::Uint16: return QString::number(_serializedValue.toValue()->value()); + case ::profiler::DataType::Int32: return QString::number(_serializedValue.toValue()->value()); + case ::profiler::DataType::Uint32: return QString::number(_serializedValue.toValue()->value()); + case ::profiler::DataType::Int64: return QString::number(_serializedValue.toValue()->value()); + case ::profiler::DataType::Uint64: return QString::number(_serializedValue.toValue()->value()); + case ::profiler::DataType::Float: return QString::number(_serializedValue.toValue()->value()); + case ::profiler::DataType::Double: return QString::number(_serializedValue.toValue()->value()); case ::profiler::DataType::String: return _serializedValue.data(); default: return QStringLiteral("Unknown"); }