19 #include "tdesycoca.h"
20 #include "tdesycocatype.h"
21 #include "tdesycocafactory.h"
22 #include "tdesycocaentry.h"
23 #include "tdesycocadict.h"
24 #include <tqstringlist.h>
28 template class TQDict<KSycocaEntry>;
29 template class TQDict<TDESharedPtr<KSycocaEntry> >;
31 KSycocaFactory::KSycocaFactory(KSycocaFactoryId factory_id)
32 : m_resourceList(0), m_entryDict(0), m_sycocaDict(0)
34 if (!KSycoca::self()->isBuilding())
36 m_str = KSycoca::self()->findFactory( factory_id );
43 m_sycocaDictOffset = i;
45 m_beginEntryOffset = i;
49 int saveOffset = m_str->device()->at();
51 m_sycocaDict =
new KSycocaDict(m_str, m_sycocaDictOffset);
52 saveOffset = m_str->device()->at(saveOffset);
60 m_entryDict =
new KSycocaEntryDict(977);
61 m_entryDict->setAutoDelete(
true);
62 m_sycocaDict =
new KSycocaDict();
63 m_beginEntryOffset = 0;
68 KSycoca::self()->addFactory(
this);
71 KSycocaFactory::~KSycocaFactory()
78 KSycocaFactory::saveHeader(TQDataStream &str)
81 str.device()->at(mOffset);
82 str << (TQ_INT32) m_sycocaDictOffset;
83 str << (TQ_INT32) m_beginEntryOffset;
84 str << (TQ_INT32) m_endEntryOffset;
88 KSycocaFactory::save(TQDataStream &str)
90 if (!m_entryDict)
return;
92 if (!m_sycocaDict)
return;
94 mOffset = str.device()->at();
95 m_sycocaDictOffset = 0;
100 m_beginEntryOffset = str.device()->at();
104 for(TQDictIterator<KSycocaEntry::Ptr> it ( *m_entryDict );
113 m_endEntryOffset = str.device()->at();
117 str << (TQ_INT32) entryCount;
118 for(TQDictIterator<KSycocaEntry::Ptr> it ( *m_entryDict );
123 str << (TQ_INT32) entry->offset();
127 m_sycocaDictOffset = str.device()->at();
128 m_sycocaDict->save(str);
130 int endOfFactoryData = str.device()->at();
136 str.device()->at(endOfFactoryData);
140 KSycocaFactory::addEntry(
KSycocaEntry *newEntry,
const char *)
142 if (!m_entryDict)
return;
145 if (!m_sycocaDict)
return;
149 m_sycocaDict->add( name, newEntry );
155 if (!m_entryDict)
return;
158 if (!m_sycocaDict)
return;
161 m_entryDict->remove( name );
162 m_sycocaDict->remove( name );
165 KSycocaEntry::List KSycocaFactory::allEntries()
167 KSycocaEntry::List list;
168 if (!m_str)
return list;
172 m_str->device()->at(m_endEntryOffset);
174 (*m_str) >> entryCount;
176 if (entryCount > 8192)
178 KSycoca::flagError();
182 TQ_INT32 *offsetList =
new TQ_INT32[entryCount];
183 for(
int i = 0; i < entryCount; i++)
185 (*m_str) >> offsetList[i];
188 for(
int i = 0; i < entryCount; i++)
196 delete [] offsetList;
200 void KSycocaFactory::virtual_hook(
int ,
void* )
Base class for all Sycoca entries.
virtual TQString name() const =0
Can be used to control the lifetime of an object that has derived TDEShared.
const char * name(StdAction id)