ICF 3.1.1.10
Technical documentation of ICF Libraries
CJsonStringWriteArchive.h
Go to the documentation of this file.
1/********************************************************************************
2** This file is part of the ICF Framework. Copyright (C) Witold Gantzke & Kirill Lepskiy
3** ICF Framework may be used under the terms of the LGPL License v. 2.1 by the Free Software Foundation.
4********************************************************************************/
5
6#pragma once
7
8
9// Qt includes
10#include <QtCore/QJsonDocument>
11#include <QtCore/QJsonObject>
12#include <QtCore/QJsonArray>
13#include <QtCore/QVector>
14#include <QtCore/QTextStream>
15
16// ICF includes
18
19
20namespace iser
21{
22
23
28{
29public:
31
33 QByteArray& inputString,
34 const iser::IVersionInfo* versionInfoPtr = nullptr,
35 QJsonDocument::JsonFormat jsonFormat = QJsonDocument::Compact);
36
38
39 // reimplemented (iser::IArchive)
40 bool IsTagSkippingSupported() const override;
42 const iser::CArchiveTag& listTag,
43 const iser::CArchiveTag& subTag,
44 int count,
45 std::function<bool(int, iser::IArchive&)> iterArchiveFn,
46 std::function<bool(int)> resizeFn = nullptr) override;
48 const iser::CArchiveTag& listTag,
49 const iser::CArchiveTag& groupTag,
50 int count,
51 std::function<bool(int, iser::IArchive&)> groupArchiveFn,
52 std::function<bool(int)> resizeFn = nullptr) override;
54 bool ProcessLeaf(const iser::CArchiveTag& tag, QString& value) override;
55
56protected:
57 void WriteTag(const iser::CArchiveTag& tag, QString separator, bool isWriteTag = true);
58 bool BeginTagForArray(const CArchiveTag& tag);
59
60 // reimplemented (iser::CTextWriteArchiveBase)
61 bool WriteTextNode(const QByteArray& text) override;
62 bool BeginTag(const iser::CArchiveTag& tag) override;
63 bool EndTag(const iser::CArchiveTag& tag) override;
64
65private:
66 QTextStream m_stream;
67 bool m_firstTag;
68 QJsonDocument::JsonFormat m_jsonFormat;
69
70 QByteArray m_currentAttribute;
71
72 bool m_serializeHeader;
73 iser::CArchiveTag m_rootTag;
74
75 bool m_isSeparatorNeeded; // idicate that separator must be added before something is outputted
76 bool m_allowAttribute; // indicate if attribute outputting is allowed now
77
78 QList<const iser::CArchiveTag*> m_tagsStack;
79};
80
81
82} // namespace iser
83
84
Process tag used to group data in archive stream.
Definition CArchiveTag.h:25
Implementation of an ICF Archive serializing to JSON string.
bool BeginTag(const iser::CArchiveTag &tag) override
Begin of archive tag.
bool WriteTextNode(const QByteArray &text) override
Write single unformatted text node.
bool IsTagSkippingSupported() const override
Check if skiping to the end of tag on EndTag is supported.
bool ProcessGroupList(const iser::CArchiveTag &listTag, const iser::CArchiveTag &groupTag, int count, std::function< bool(int, iser::IArchive &)> groupArchiveFn, std::function< bool(int)> resizeFn=nullptr) override
bool ProcessAnyList(const iser::CArchiveTag &listTag, const iser::CArchiveTag &subTag, int count, std::function< bool(int, iser::IArchive &)> iterArchiveFn, std::function< bool(int)> resizeFn=nullptr) override
void WriteTag(const iser::CArchiveTag &tag, QString separator, bool isWriteTag=true)
CJsonStringWriteArchive(QByteArray &inputString, const iser::IVersionInfo *versionInfoPtr=nullptr, QJsonDocument::JsonFormat jsonFormat=QJsonDocument::Compact)
bool BeginTagForArray(const CArchiveTag &tag)
bool EndTag(const iser::CArchiveTag &tag) override
End of archive tag.
iser::CTextWriteArchiveBase BaseClass
bool ProcessLeaf(const iser::CArchiveTag &tag, QString &value) override
Process primitive type.
Common archive implementation of text-based storing archives.
bool ProcessLeaf(const CArchiveTag &tag, bool &value) override
Process primitive type.
Represent input/output persistence archive.
Definition IArchive.h:34
Provides access to version information.
Contains general persistence mechanism with basic archives implementations.

© Witold Gantzke and Kirill Lepskiy