From 4e9f7807fbca948f355fa6aa17e0bbeb86d065a3 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 15 Feb 2017 11:23:24 +0100 Subject: Move qJsonFromRawLibraryMetaData into qfactoryloader_p.h This is still not a great place for it, but this way we can Q_REQUIRE_CONFIG(library) in qlibrary_p.h and qfactoryloader_p.h is the only private header that doesn't require library support in plugin.pri. Change-Id: Ia6c1ac8799822eca1e0cbeca98d1c1b8de74beae Reviewed-by: Oswald Buddenhagen --- src/corelib/plugin/qfactoryloader_p.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/corelib/plugin/qfactoryloader_p.h') diff --git a/src/corelib/plugin/qfactoryloader_p.h b/src/corelib/plugin/qfactoryloader_p.h index 0876d141c4..70a934c976 100644 --- a/src/corelib/plugin/qfactoryloader_p.h +++ b/src/corelib/plugin/qfactoryloader_p.h @@ -57,11 +57,22 @@ #include "QtCore/qobject.h" #include "QtCore/qstringlist.h" #include "QtCore/qjsonobject.h" +#include "QtCore/qjsondocument.h" #include "QtCore/qmap.h" +#include "QtCore/qendian.h" #include "private/qlibrary_p.h" QT_BEGIN_NAMESPACE +inline QJsonDocument qJsonFromRawLibraryMetaData(const char *raw) +{ + raw += strlen("QTMETADATA "); + // the size of the embedded JSON object can be found 8 bytes into the data (see qjson_p.h), + // but doesn't include the size of the header (8 bytes) + QByteArray json(raw, qFromLittleEndian(*(const uint *)(raw + 8)) + 8); + return QJsonDocument::fromBinaryData(json); +} + class QFactoryLoaderPrivate; class Q_CORE_EXPORT QFactoryLoader : public QObject { -- cgit v1.2.3