21#include <unordered_map>
57 auto it =
m_urls.find(idx);
64 if (hiPriority) it->second.freq|=1;
76 if (ctx==
nullptr)
return;
84 if (!isSourceFile) baseUrl=url;
171 m_urls.emplace(it->second,
URL(name,url));
177 if (
word.length()<2)
return -1;
190 uint32_t c1=
static_cast<uint8_t
>(
word[0]);
191 uint32_t c2=
static_cast<uint8_t
>(
word[1]);
197 if (
word.isEmpty())
return;
201 if (idx<0 || idx>=
static_cast<int>(
m_index.size()))
return;
206 m_index[idx].emplace_back(wStr);
207 it =
m_words.emplace( wStr.
str(),
static_cast<int>(
m_index[idx].size())-1 ).first;
225 (
word[i+1]>=
'A' &&
word[i+1]<=
'Z')))
229 if (
word[i]!=0 && i>=1)
244 f.put(
static_cast<int>((index>>24)&0xff));
245 f.put(
static_cast<int>((index>>16)&0xff));
246 f.put(
static_cast<int>((index>>8)&0xff));
247 f.put(
static_cast<int>(index&0xff));
253 for (
size_t i=0;i<l;i++) f.put(s[i]);
261 size_t wordsOffset = size;
265 const auto &wlist =
m_index[i];
268 for (
const auto &iw : wlist)
270 size_t ws = iw.word().length()+1;
279 size_t offset=wordsOffset;
282 const auto &wlist =
m_index[i];
285 indexOffsets[i]=offset;
286 for (
const auto &iw : wlist)
288 offset+= iw.word().length()+1;
298 size_t padding = size;
300 padding = size - padding;
302 std::vector<size_t> wordStatOffsets(
m_words.size());
309 const auto &wlist =
m_index[i];
312 for (
const auto &iw : wlist)
315 wordStatOffsets[count++] = size;
316 size+=4 + iw.urls().size() * 8;
320 std::vector<size_t> urlOffsets(
m_urls.size());
321 for (
const auto &udi :
m_urls)
323 urlOffsets[udi.first]=size;
324 size+=udi.second.name.length()+1+
325 udi.second.url.length()+1;
333 f.put(
'D'); f.put(
'O'); f.put(
'X'); f.put(
'S');
343 const auto &wlist =
m_index[i];
346 for (
const auto &iw : wlist)
349 writeInt(f,wordStatOffsets[count++]);
355 for (
size_t i=0;i<padding;i++) f.put(0);
359 const auto &wlist =
m_index[i];
362 for (
const auto &iw : wlist)
364 size_t numUrls = iw.urls().size();
366 for (
const auto &ui : iw.urls())
368 writeInt(f,urlOffsets[ui.second.urlIdx]);
375 for (
const auto &udi :
m_urls)
426 return (
toClassDef(ctx))->compoundTypeString();
508 t <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
512 doc.normalText.addChar(0);
513 doc.importantText.addChar(0);
515 t <<
" <field name=\"type\">" << doc.type <<
"</field>\n";
516 t <<
" <field name=\"name\">" <<
convertToXML(doc.name) <<
"</field>\n";
517 if (!doc.args.isEmpty())
519 t <<
" <field name=\"args\">" <<
convertToXML(doc.args) <<
"</field>\n";
521 if (!doc.extId.isEmpty())
523 t <<
" <field name=\"tag\">" <<
convertToXML(doc.extId) <<
"</field>\n";
525 t <<
" <field name=\"url\">" <<
convertToXML(doc.url) <<
"</field>\n";
526 t <<
" <field name=\"keywords\">" <<
convertToXML(doc.importantText.get()) <<
"</field>\n";
527 t <<
" <field name=\"text\">" <<
convertToXML(doc.normalText.get()) <<
"</field>\n";
534 err(
"Failed to open file %s for writing!\n",
qPrint(fileName));
545 if (searchEngine && serverBasedSearch)
A abstract class representing of a compound symbol.
virtual QCString compoundTypeString() const =0
Returns the type of compound as a string.
The common base class of all entity definitions found in the sources.
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.
virtual DefType definitionType() const =0
virtual QCString qualifiedName() const =0
virtual QCString getOutputFileBase() const =0
virtual const QCString & name() const =0
static SearchIndexIntf searchIndex
A model of a group of symbols.
virtual QCString groupTitle() const =0
Class representing a string buffer optimized for growing.
void addStr(const QCString &s)
A model of a class/file/namespace member symbol.
virtual bool isSignal() const =0
virtual bool isFriend() const =0
virtual bool isForeign() const =0
virtual bool isRelated() const =0
virtual bool isTypedef() const =0
virtual bool isSlot() const =0
virtual bool isEvent() const =0
virtual bool isFunction() const =0
virtual bool isDefine() const =0
virtual bool isEnumerate() const =0
virtual bool isVariable() const =0
virtual bool isEnumValue() const =0
virtual bool isProperty() const =0
A model of a page symbol.
virtual bool hasTitle() const =0
virtual QCString title() const =0
This is an alternative implementation of QCString.
QCString & prepend(const char *s)
size_t length() const
Returns the length of the string, not counting the 0-terminator.
bool isEmpty() const
Returns TRUE iff the string is empty.
const std::string & str() const
void addUrlIndex(int, bool)
void addWord(const QCString &word, bool hiPriority)
SearchDocEntry * m_current
void write(const QCString &file)
std::map< std::string, SearchDocEntry > m_docEntries
void setCurrentDoc(const Definition *ctx, const QCString &anchor, bool isSourceFile)
std::map< int, URL > m_urls
void addWordRec(const QCString &word, bool hiPrio, bool recurse)
void addWord(const QCString &word, bool hiPriority)
std::vector< std::vector< IndexWord > > m_index
std::unordered_map< std::string, int > m_words
std::unordered_map< std::string, int > m_url2IdMap
void write(const QCString &file)
void setCurrentDoc(const Definition *ctx, const QCString &anchor, bool isSourceFile)
ClassDef * toClassDef(Definition *d)
#define Config_getBool(name)
#define Config_getString(name)
FileDef * toFileDef(Definition *d)
GroupDef * toGroupDef(Definition *d)
Translator * theTranslator
MemberDef * toMemberDef(Definition *d)
std::ofstream openOutputStream(const QCString &name, bool append=false)
PageDef * toPageDef(Definition *d)
Portable versions of functions that are platform dependent.
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
const char * qPrint(const char *s)
static void writeString(std::ostream &f, const QCString &s)
static std::mutex g_searchIndexMutex
static void writeInt(std::ostream &f, size_t index)
static int charsToIndex(const QCString &word)
const size_t numIndexEntries
static QCString definitionToName(const Definition *ctx)
Web server based search engine.
void finalizeSearchIndexer()
SrcLangExt
Language as given by extension.
QCString stripPath(const QCString &s)
QCString filterTitle(const QCString &title)
QCString convertToXML(const QCString &s, bool keepEntities)
QCString getLanguageSpecificSeparator(SrcLangExt lang, bool classScope)
Returns the scope separator to use given the programming language lang.
int getPrefixIndex(const QCString &name)
void addHtmlExtensionIfMissing(QCString &fName)
A bunch of utility functions.