From 753c00543d9c5c92cf685070364ecec67cf33e26 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 23 Aug 2023 14:10:58 +0200 Subject: [PATCH] Utils: Introduce a Storage class ... mapping Keys (currently QString) to Data (currently QVariant), i.e. effectively an oddly named QVariantMap. Plan is to 1. make QVariantMap using loading/saving related functions to use Storage instead of QVariant map, 2. replace QString by a UTF-8 container (QByteArray for starters) 3. add/remove parts of the map interface so that neither decoration of string literals in user code are needed, nor that unnecessary allocations happen. Long term Storage could cover some of the current JSON uses, with Storage's implementation possibly switching over to something based on JSON (or CBOR?) directly, to be closer what we typically send over the wire. Change-Id: Ic33b8e95fed5268d6298b5391ff42cbb582b56c4 Reviewed-by: Marcus Tillmanns --- src/libs/utils/CMakeLists.txt | 1 + src/libs/utils/storage.cpp | 9 +++++++++ src/libs/utils/storage.h | 14 ++++++++++++++ src/libs/utils/utils.qbs | 2 ++ 4 files changed, 26 insertions(+) create mode 100644 src/libs/utils/storage.cpp create mode 100644 src/libs/utils/storage.h diff --git a/src/libs/utils/CMakeLists.txt b/src/libs/utils/CMakeLists.txt index d1ad5ee298b..0bce11fcb58 100644 --- a/src/libs/utils/CMakeLists.txt +++ b/src/libs/utils/CMakeLists.txt @@ -161,6 +161,7 @@ add_qtc_library(Utils sortfiltermodel.h span.h statuslabel.cpp statuslabel.h + storage.cpp storage.h stringtable.cpp stringtable.h stringutils.cpp stringutils.h styleanimator.cpp styleanimator.h diff --git a/src/libs/utils/storage.cpp b/src/libs/utils/storage.cpp new file mode 100644 index 00000000000..c443c48ba63 --- /dev/null +++ b/src/libs/utils/storage.cpp @@ -0,0 +1,9 @@ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include "storage.h" + + +namespace Utils { + +} // Utils diff --git a/src/libs/utils/storage.h b/src/libs/utils/storage.h new file mode 100644 index 00000000000..ddcdd233a94 --- /dev/null +++ b/src/libs/utils/storage.h @@ -0,0 +1,14 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include + +namespace Utils { + +using Key = QString; +using Data = QVariant; +using Storage = QMap; + +} // Utils diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 0dcda50bbae..d2f9c814bb5 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -293,6 +293,8 @@ Project { "../3rdparty/span/span.hpp", "statuslabel.cpp", "statuslabel.h", + "storage.cpp", + "storage.h", "stringtable.cpp", "stringtable.h", "stringutils.cpp",