ACF $AcfVersion:0$
CJsonWriteArchiveBase.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/QVector>
10#include <QtCore/QDataStream>
11#include <QtCore/QBuffer>
12
13// ACF includes
15#include <istd/TDelPtr.h>
16
17
18namespace iser
19{
20
21
26{
27public:
29
31
32 void SetFormat(QJsonDocument::JsonFormat jsonFormat);
33
34 // reimplemented (iser::IArchive)
35 virtual bool IsTagSkippingSupported() const override;
36 virtual bool BeginTag(const iser::CArchiveTag& tag) override;
37 virtual bool BeginMultiTag(const iser::CArchiveTag& tag, const iser::CArchiveTag& subTag, int& count) override;
38 virtual bool EndTag(const iser::CArchiveTag& tag) override;
39 virtual bool Process(QString& value) override;
40 virtual bool Process(QByteArray& value) override;
41 virtual bool ProcessData(void* dataPtr, int size) override;
42
44
45protected:
47 const iser::IVersionInfo* versionInfoPtr,
48 bool serializeHeader,
49 const iser::CArchiveTag& rootTag);
50
51 bool InitStream(bool serializeHeader);
52 bool InitArchive(QIODevice* devicePtr);
53 bool InitArchive(QByteArray& inputString);
54 bool WriteTag(const iser::CArchiveTag& tag, QString separator);
56 bool Flush();
57
58 // reimplemented (iser::CTextWriteArchiveBase)
59 virtual bool WriteTextNode(const QByteArray& text) override;
60
61protected:
62 QTextStream m_stream;
63 QBuffer m_buffer;
65 QJsonDocument::JsonFormat m_jsonFormat;
68
69 bool m_isSeparatorNeeded; // idicate that separator must be added before something is outputted
70 bool m_allowAttribute; // indicate if attribute outputting is allowed now
71
77
79
80 QList<TagsStackItem> m_tagsStack;
81};
82
83
84} // namespace iser
85
86
Process tag used to group data in archive stream.
Definition CArchiveTag.h:22
Implementation of an ACF Archive serializing to JSON string.
bool InitArchive(QByteArray &inputString)
virtual bool BeginTag(const iser::CArchiveTag &tag) override
Begins a tagged section in the archive.
bool InitStream(bool serializeHeader)
virtual bool EndTag(const iser::CArchiveTag &tag) override
Ends a tagged section in the archive.
QJsonDocument::JsonFormat m_jsonFormat
QList< TagsStackItem > m_tagsStack
virtual bool WriteTextNode(const QByteArray &text) override
Write single unformatted text node.
iser::CTextWriteArchiveBase BaseClass
CJsonWriteArchiveBase(const iser::IVersionInfo *versionInfoPtr, bool serializeHeader, const iser::CArchiveTag &rootTag)
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.
void SetFormat(QJsonDocument::JsonFormat jsonFormat)
bool InitArchive(QIODevice *devicePtr)
virtual bool Process(QString &value) override
Process primitive type.
virtual bool IsTagSkippingSupported() const override
Checks if skipping to the end of a tag on EndTag() is supported.
bool WriteTag(const iser::CArchiveTag &tag, QString separator)
virtual bool Process(QByteArray &value) override
Process primitive type.
virtual bool ProcessData(void *dataPtr, int size) override
Process binary data block.
Common archive implementation of text-based storing archives.
virtual bool Process(bool &value) override
Processes (reads or writes) a boolean value.
Provides access to version information.
Contains general persistence mechanism with basic archives implementations.