1/*
2 This file is part of the KDE project
3 SPDX-FileCopyrightText: 2009 David Faure <faure@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#ifndef KSYCOCADEVICES_P_H
9#define KSYCOCADEVICES_P_H
10
11#include <config-ksycoca.h>
12#include <stdlib.h>
13// TODO: remove mmap() from kdewin32 and use QFile::mmap() when needed
14#ifdef Q_OS_WIN
15#define HAVE_MMAP 0
16#endif
17
18class QString;
19class QDataStream;
20class QBuffer;
21class QFile;
22class QIODevice;
23class KMemFile;
24
25class KSycocaAbstractDevice
26{
27public:
28 KSycocaAbstractDevice()
29 : m_stream(nullptr)
30 {
31 }
32
33 virtual ~KSycocaAbstractDevice();
34
35 virtual QIODevice *device() = 0;
36
37 QDataStream *&stream();
38
39private:
40 QDataStream *m_stream;
41};
42
43#if HAVE_MMAP
44// Reading from a mmap'ed file
45class KSycocaMmapDevice : public KSycocaAbstractDevice
46{
47public:
48 KSycocaMmapDevice(const char *sycoca_mmap, size_t sycoca_size);
49 ~KSycocaMmapDevice() override;
50 QIODevice *device() override;
51
52private:
53 QBuffer *m_buffer;
54};
55#endif
56
57// Reading from a QFile
58class KSycocaFileDevice : public KSycocaAbstractDevice
59{
60public:
61 explicit KSycocaFileDevice(const QString &path);
62 ~KSycocaFileDevice() override;
63 QIODevice *device() override;
64
65private:
66 QFile *m_database;
67};
68
69#ifndef QT_NO_SHAREDMEMORY
70// Reading from a KMemFile
71class KSycocaMemFileDevice : public KSycocaAbstractDevice
72{
73public:
74 explicit KSycocaMemFileDevice(const QString &path);
75 ~KSycocaMemFileDevice() override;
76 QIODevice *device() override;
77
78private:
79 KMemFile *m_database;
80};
81#endif
82
83// Reading from a dummy memory buffer
84class KSycocaBufferDevice : public KSycocaAbstractDevice
85{
86public:
87 KSycocaBufferDevice();
88 ~KSycocaBufferDevice() override;
89 QIODevice *device() override;
90
91private:
92 QBuffer *m_buffer;
93};
94
95#endif /* KSYCOCADEVICES_P_H */
96

source code of kservice/src/sycoca/ksycocadevices_p.h