| 1 | /* |
| 2 | This file is part of the KDE libraries |
| 3 | SPDX-FileCopyrightText: 1999 Waldo Bastian <[email protected]> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-only |
| 6 | */ |
| 7 | |
| 8 | #ifndef KSYCOCAFACTORY_H |
| 9 | #define KSYCOCAFACTORY_Hcxx . . $ `src/sycoca/ksycocafactory_p.h:9:9`! |
| 10 | |
| 11 | #include "ksycocaresourcelist_p.h"cxx . . $ `<file>/src/sycoca/ksycocaresourcelist_p.h`/ |
| 12 | #include <QStandardPaths> |
| 13 | #include <ksycocaentry.h>cxx . . $ `<file>/src/sycoca/ksycocaentry.h`/ |
| 14 | |
| 15 | #include <ksycoca.h>cxx . . $ `<file>/src/sycoca/ksycoca.h`/ // for KSycoca::self() |
| 16 | |
| 17 | #include <memory> |
| 18 | |
| 19 | class QStringcxx . . $ QString#; |
| 20 | class KSycocacxx . . $ KSycoca#; |
| 21 | class KSycocaDictcxx . . $ KSycocaDict#; |
| 22 | template<typename T> |
| 23 | class QListcxx . . $ QList#; |
| 24 | template<typename KT, typename VT> |
| 25 | class QHashcxx . . $ QHash#; |
| 26 | |
| 27 | typedef QHashcxx . . $ QHash#<QStringcxx . . $ QString#, KSycocaEntrycxx . . $ KSycocaEntry#::Ptrcxx . . $ KSycocaEntry#Ptr#> KSycocaEntryDictcxx . . $ KSycocaEntryDict#; |
| 28 | class KSycocaFactoryPrivatecxx . . $ KSycocaFactoryPrivate#; |
| 29 | /*! |
| 30 | * \internal |
| 31 | * Base class for sycoca factories |
| 32 | * Exported for unit tests |
| 33 | */ |
| 34 | class KSERVICE_EXPORTcxx . . $ `build/src/kservice_export.h:15:15`! KSycocaFactorycxx . . $ KSycocaFactory# |
| 35 | { |
| 36 | public: |
| 37 | virtual KSycocaFactoryIdcxx . . $ KSycocaFactoryId# factoryIdcxx . . $ KSycocaFactory#factoryId(2623059a9cbb2855).() const = 0; |
| 38 | |
| 39 | protected: // virtual class |
| 40 | /*! |
| 41 | * Create a factory which can be used to lookup from/create a database |
| 42 | * (depending on KSycoca::isBuilding()) |
| 43 | */ |
| 44 | explicit KSycocaFactorycxx . . $ KSycocaFactory#KSycocaFactory(64e055191b810ef9).(KSycocaFactoryIdcxx . . $ KSycocaFactoryId# factory_id, KSycocacxx . . $ KSycoca# *sycoca); |
| 45 | |
| 46 | public: |
| 47 | virtual ~cxx . . $ KSycocaFactory#`~KSycocaFactory`(ced63f7c635d850d).KSycocaFactorycxx . . $ KSycocaFactory#(); |
| 48 | |
| 49 | /*! |
| 50 | * Returns the position of the factory in the sycoca file |
| 51 | */ |
| 52 | int offsetcxx . . $ KSycocaFactory#offset(455f465bc33b4cdf).() const; |
| 53 | |
| 54 | /*! |
| 55 | * Returns the dict, for special use by KBuildSycoca |
| 56 | */ |
| 57 | KSycocaEntryDictcxx . . $ KSycocaEntryDict# *entryDictcxx . . $ KSycocaFactory#entryDict(ba08d9d726918fa9).() |
| 58 | { |
| 59 | return m_entryDictcxx . . $ KSycocaFactory#m_entryDict.; |
| 60 | } |
| 61 | |
| 62 | /*! |
| 63 | * Construct an entry from a config file. |
| 64 | * To be implemented in the real factories. |
| 65 | */ |
| 66 | virtual KSycocaEntrycxx . . $ KSycocaEntry# *createEntrycxx . . $ KSycocaFactory#createEntry(79b18ceb439d1b22).(const QStringcxx . . $ QString# &file) const = 0; |
| 67 | |
| 68 | /*! |
| 69 | * Add an entry |
| 70 | */ |
| 71 | virtual void addEntrycxx . . $ KSycocaFactory#addEntry(f216dc287b90adf9).(const KSycocaEntrycxx . . $ KSycocaEntry#::Ptrcxx . . $ KSycocaEntry#Ptr# &newEntry); |
| 72 | |
| 73 | /*! |
| 74 | * Remove all entries with the given name. |
| 75 | * Not very fast (O(N)), use with care. |
| 76 | */ |
| 77 | void removeEntrycxx . . $ KSycocaFactory#removeEntry(3520e46b33348bf6).(const QStringcxx . . $ QString# &entryName); |
| 78 | |
| 79 | /*! |
| 80 | * Read an entry from the database |
| 81 | */ |
| 82 | virtual KSycocaEntrycxx . . $ KSycocaEntry# *createEntrycxx . . $ KSycocaFactory#createEntry(1d7312800b020c49).(int offset) const = 0; |
| 83 | |
| 84 | /*! |
| 85 | * Get a list of all entries from the database. |
| 86 | */ |
| 87 | virtual KSycocaEntrycxx . . $ KSycocaEntry#::Listcxx . . $ KSycocaEntry#List# allEntriescxx . . $ KSycocaFactory#allEntries(7e1b86e81f32dcad).() const; |
| 88 | |
| 89 | /*! |
| 90 | * Saves all entries it maintains as well as index files |
| 91 | * for these entries to the stream 'str'. |
| 92 | * |
| 93 | * Also sets mOffset to the starting position. |
| 94 | * |
| 95 | * The stream is positioned at the end of the last index. |
| 96 | * |
| 97 | * Don't forget to call the parent first when you override |
| 98 | * this function. |
| 99 | */ |
| 100 | virtual void savecxx . . $ KSycocaFactory#save(435bb5a52cd94061).(QDataStreamcxx . . $ QDataStream# &str); |
| 101 | |
| 102 | /*! |
| 103 | * Writes out a header to the stream 'str'. |
| 104 | * The baseclass positions the stream correctly. |
| 105 | * |
| 106 | * Don't forget to call the parent first when you override |
| 107 | * this function. |
| 108 | */ |
| 109 | virtual void saveHeadercxx . . $ KSycocaFactory#saveHeader(435bb5a52cd94061).(QDataStreamcxx . . $ QDataStream# &str); |
| 110 | |
| 111 | /*! |
| 112 | * Returns the resources for which this factory is responsible. |
| 113 | * \internal to kbuildsycoca |
| 114 | */ |
| 115 | const KSycocaResourceListcxx . . $ KSycocaResourceList# &resourceListcxx . . $ KSycocaFactory#resourceList(d5d0cab53d9375).() const; |
| 116 | |
| 117 | /*! |
| 118 | * Returns the sycoca dict, for factories to find entries by name. |
| 119 | */ |
| 120 | const KSycocaDictcxx . . $ KSycocaDict# *sycocaDictcxx . . $ KSycocaFactory#sycocaDict(cb8f3009b4e67e0d).() const; |
| 121 | |
| 122 | /*! |
| 123 | * Returns true if the factory is completely empty - no entries defined |
| 124 | */ |
| 125 | bool isEmptycxx . . $ KSycocaFactory#isEmpty(50ce9a9e25b4a850).() const; |
| 126 | |
| 127 | KSycocacxx . . $ KSycoca# *sycocacxx . . $ KSycocaFactory#sycoca(5731ff0e8cd31fd5).() const |
| 128 | { |
| 129 | return m_sycocacxx . . $ KSycocaFactory#m_sycoca.; |
| 130 | } |
| 131 | |
| 132 | protected: |
| 133 | QDataStreamcxx . . $ QDataStream# *streamcxx . . $ KSycocaFactory#stream(89ed3bcf97639bb9).() const; |
| 134 | |
| 135 | KSycocaResourceListcxx . . $ KSycocaResourceList# m_resourceListcxx . . $ KSycocaFactory#m_resourceList.; |
| 136 | KSycocaEntryDictcxx . . $ KSycocaEntryDict# *m_entryDictcxx . . $ KSycocaFactory#m_entryDict. = nullptr; |
| 137 | |
| 138 | /*! |
| 139 | * Returns all directories for the given subdir of GenericDataLocation. |
| 140 | * Helper function for AnyFactory::resourceDirs(). |
| 141 | */ |
| 142 | static QStringListcxx . . $ QStringList# allDirectoriescxx . . $ KSycocaFactory#allDirectories(8335580dfd879b35).(const QStringcxx . . $ QString# &subdir); |
| 143 | |
| 144 | private: |
| 145 | QDataStreamcxx . . $ QDataStream# *m_strcxx . . $ KSycocaFactory#m_str. = nullptr; |
| 146 | KSycocacxx . . $ KSycoca# *m_sycocacxx . . $ KSycocaFactory#m_sycoca. = nullptr; |
| 147 | stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<KSycocaFactoryPrivatecxx . . $ KSycocaFactoryPrivate#> const dcxx . . $ KSycocaFactory#d.; |
| 148 | |
| 149 | protected: |
| 150 | /*! Virtual hook, used to add new "virtual" functions while maintaining |
| 151 | binary compatibility. Unused in this class. |
| 152 | */ |
| 153 | virtual void virtual_hookcxx . . $ KSycocaFactory#virtual_hook(6ca3d68f5c5f0975).(int id, void *data); |
| 154 | }; |
| 155 | |
| 156 | /*! |
| 157 | * This, instead of a typedef, allows to declare "class ..." in header files. |
| 158 | * \internal |
| 159 | */ |
| 160 | class KSycocaFactoryListcxx . . $ KSycocaFactoryList# : public QListcxx . . $ QList#<KSycocaFactorycxx . . $ KSycocaFactory# *> // krazy:exclude=dpointer (acts as a typedef) |
| 161 | { |
| 162 | public: |
| 163 | KSycocaFactoryListcxx . . $ KSycocaFactoryList#KSycocaFactoryList(49f6e7a06ebc5aa8).() |
| 164 | { |
| 165 | } |
| 166 | }; |
| 167 | |
| 168 | #endif |