ACF $AcfVersion:0$
TDeviceReadTextArchiveWrap.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/QIODevice>
7
8// ACF includes
9#include <iser/IVersionInfo.h>
10#include <iser/CArchiveBase.h>
11#include <iser/CArchiveTag.h>
12
13
14namespace ifile
15{
16
17
21template <class Base, class Device = QIODevice>
23{
24public:
25 typedef Base BaseClass;
26
28 QIODevice& device,
29 bool serializeHeader = true,
32
33protected:
34 QIODevice& GetDevice() const;
35
36private:
37 Device& m_device;
38};
39
40
41// public methods
42
43template <class Base, class Device>
45 QIODevice& device,
46 bool serializeHeader,
47 const iser::CArchiveTag& rootTag)
48 :BaseClass(serializeHeader, rootTag),
49 m_device(device)
50{
51 if (!m_device.isOpen()){
52 if (!m_device.open(QIODevice::ReadOnly | QIODevice::Text)){
53 Q_ASSERT(false);
54
55 return;
56 }
57 }
58
59 if (m_device.isOpen()){
60 Q_ASSERT(m_device.isReadable());
61 Q_ASSERT(m_device.isTextModeEnabled());
62
63 if (!BaseClass::SetContent(&m_device)){
64 Q_ASSERT(false);
65
66 m_device.close();
67 }
68 }
69}
70
71
72template <class Base, class Device>
77
78
79// protected methods
80
81template <class Base, class Device>
83{
84 return m_device;
85}
86
87
88} // namespace ifile
89
90
Template wrapper for the text-based writing archives using an i/o-device given from outside.
TDeviceReadTextArchiveWrap(QIODevice &device, bool serializeHeader=true, const iser::CArchiveTag &rootTag=iser::CArchiveBase::s_acfRootTag)
static CArchiveTag s_acfRootTag
Process tag used to group data in archive stream.
Definition CArchiveTag.h:22
Contains interfaces and implementations of file system related components.