ACF $AcfVersion:0$
CJsonReadArchiveBase.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// Qt includes
6#include <QtCore/QJsonDocument>
7#include <QtCore/QJsonObject>
8#include <QtCore/QJsonArray>
9#include <QtCore/QList>
10#include <QtCore/QIODevice>
11
12// ACF includes
14
15
16namespace iser
17{
18
19
28{
29public:
31
33 bool serializeHeader = true,
34 const iser::CArchiveTag& rootTag = s_acfRootTag);
35
36 // reimplemented (iser::IArchive)
37 virtual bool BeginTag(const iser::CArchiveTag& tag) override;
38 virtual bool BeginMultiTag(const iser::CArchiveTag& tag, const iser::CArchiveTag& subTag, int& count) override;
39 virtual bool EndTag(const iser::CArchiveTag& tag) override;
40 virtual bool Process(QString& value) override;
41
42protected:
43 bool SetContent(QIODevice* devicePtr);
44
45 bool ReadStringNode(QString& text);
46
47 // reimplemented (iser::CTextReadArchiveBase)
48 virtual bool ReadTextNode(QByteArray& text) override;
49
50protected:
51 QJsonDocument m_document;
52
54 {
55 public:
57 void SetKey(const QString& key);
58 const QString GetKey();
59 QString GetValue();
60 QJsonObject GetObject();
61 QJsonValue GetJsonValue();
62 QJsonArray GetArray();
64 void SetValue(const QJsonValue value);
65 bool isObject();
66 bool isArray();
67 private:
68 QJsonArray m_array;
69 QJsonArray::ConstIterator m_arrayIterator;
70 QJsonValue m_value;
71 QString m_key;
72 int activeArrayIndex;
73 };
74
75 QList<HelperIterator> m_iterators;
76 QList<const iser::CArchiveTag*> m_tags;
80};
81
82
83} // namespace iser
84
85
static CArchiveTag s_acfRootTag
Process tag used to group data in archive stream.
Definition CArchiveTag.h:22
void SetValue(const QJsonValue value)
Implementation of an ACF archive deserializing from a JSON string.
bool SetContent(QIODevice *devicePtr)
CJsonReadArchiveBase(bool serializeHeader=true, const iser::CArchiveTag &rootTag=s_acfRootTag)
virtual bool BeginTag(const iser::CArchiveTag &tag) override
Begins a tagged section in the archive.
QList< const iser::CArchiveTag * > m_tags
bool ReadStringNode(QString &text)
virtual bool ReadTextNode(QByteArray &text) override
Read single unformatted text node.
QList< HelperIterator > m_iterators
virtual bool Process(QString &value) override
Process primitive type.
virtual bool EndTag(const iser::CArchiveTag &tag) override
Ends a tagged section in the archive.
virtual bool BeginMultiTag(const iser::CArchiveTag &tag, const iser::CArchiveTag &subTag, int &count) override
Begins a tagged section containing multiple elements of the same type.
Common archive implementation of text-based reading archives.
Contains general persistence mechanism with basic archives implementations.