From 03cfc3d6eb95d2454c6d155c1ce8cb3d3bad3621 Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Tue, 29 Dec 2020 19:34:33 +0100 Subject: Refactoring: Modernise client side part of searchindex --- src/context.cpp | 96 ++++--- src/context.h | 39 +-- src/searchindex.cpp | 648 +++++++++++++++++++++------------------------- src/searchindex.h | 76 ++---- templates/html/search.css | 2 + 5 files changed, 391 insertions(+), 470 deletions(-) diff --git a/src/context.cpp b/src/context.cpp index b7a547f..a7eb9a3 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -9610,25 +9610,26 @@ TemplateVariant SymbolContext::get(const char *name) const class SymbolListContext::Private : public GenericNodeListContext { public: - Private(const SearchDefinitionList *sdl) + Private(const SearchIndexList::const_iterator &start, + const SearchIndexList::const_iterator &end) { - QListIterator li(*sdl); - const Definition *def; const Definition *prev = 0; - for (li.toFirst();(def=li.current());) + for (auto it = start; it!=end;) { - ++li; - const Definition *next = li.current(); + const Definition *def = *it; + ++it; + const Definition *next = it!=end ? *it : 0; append(SymbolContext::alloc(def,prev,next)); prev = def; } } }; -SymbolListContext::SymbolListContext(const SearchDefinitionList *sdl) +SymbolListContext::SymbolListContext(const SearchIndexList::const_iterator &start, + const SearchIndexList::const_iterator &end) : RefCountedContext("SymbolListContext") { - p = new Private(sdl); + p = new Private(start,end); } SymbolListContext::~SymbolListContext() @@ -9659,7 +9660,8 @@ TemplateListIntf::ConstIterator *SymbolListContext::createIterator() const class SymbolGroupContext::Private { public: - Private(const SearchDefinitionList *sdl) : m_sdl(sdl) + Private(const SearchIndexList::const_iterator &start, + const SearchIndexList::const_iterator &end) : m_start(start), m_end(end) { static bool init=FALSE; if (!init) @@ -9676,22 +9678,23 @@ class SymbolGroupContext::Private } TemplateVariant id() const { - return m_sdl->id(); + return searchId(*m_start); } TemplateVariant name() const { - return m_sdl->name(); + return searchName(*m_start); } TemplateVariant symbolList() const { if (!m_cache.symbolList) { - m_cache.symbolList.reset(SymbolListContext::alloc(m_sdl)); + m_cache.symbolList.reset(SymbolListContext::alloc(m_start,m_end)); } return m_cache.symbolList.get(); } private: - const SearchDefinitionList *m_sdl; + SearchIndexList::const_iterator m_start; + SearchIndexList::const_iterator m_end; struct Cachable { SharedPtr symbolList; @@ -9703,10 +9706,11 @@ class SymbolGroupContext::Private PropertyMapper SymbolGroupContext::Private::s_inst; -SymbolGroupContext::SymbolGroupContext(const SearchDefinitionList *sdl) +SymbolGroupContext::SymbolGroupContext(const SearchIndexList::const_iterator &start, + const SearchIndexList::const_iterator &end) : RefCountedContext("SymbolGroupContext") { - p = new Private(sdl); + p = new Private(start,end); } SymbolGroupContext::~SymbolGroupContext() @@ -9725,18 +9729,30 @@ TemplateVariant SymbolGroupContext::get(const char *name) const class SymbolGroupListContext::Private : public GenericNodeListContext { public: - Private(const SearchIndexList *sil) + Private(const SearchIndexList &sil) { - SDict::Iterator li(*sil); - SearchDefinitionList *dl; - for (li.toFirst();(dl=li.current());++li) + QCString lastName; + auto it = sil.begin(); + auto it_begin = it; + while (it!=sil.end()) { - append(SymbolGroupContext::alloc(dl)); + QCString name = searchName(*it); + if (name!=lastName) + { + append(SymbolGroupContext::alloc(it_begin,it)); + it_begin = it; + lastName = name; + } + ++it; + } + if (it_begin!=sil.end()) + { + append(SymbolGroupContext::alloc(it_begin,sil.end())); } } }; -SymbolGroupListContext::SymbolGroupListContext(const SearchIndexList *sil) +SymbolGroupListContext::SymbolGroupListContext(const SearchIndexList &sil) : RefCountedContext("SymbolGroupListContext") { p = new Private(sil); @@ -9770,7 +9786,9 @@ TemplateListIntf::ConstIterator *SymbolGroupListContext::createIterator() const class SymbolIndexContext::Private { public: - Private(const SearchIndexList *sl,const QCString &name) : m_searchList(sl), m_name(name) + Private(const std::string &letter, + const SearchIndexList &sl, + const QCString &name) : m_letter(letter), m_searchList(sl), m_name(name) { static bool init=FALSE; if (!init) @@ -9791,7 +9809,7 @@ class SymbolIndexContext::Private } TemplateVariant letter() const { - return QString(QChar(m_searchList->letter())).utf8(); + return m_letter; } TemplateVariant symbolGroups() const { @@ -9802,7 +9820,8 @@ class SymbolIndexContext::Private return m_cache.symbolGroups.get(); } private: - const SearchIndexList *m_searchList; + QCString m_letter; + const SearchIndexList &m_searchList; QCString m_name; struct Cachable { @@ -9815,10 +9834,10 @@ class SymbolIndexContext::Private PropertyMapper SymbolIndexContext::Private::s_inst; -SymbolIndexContext::SymbolIndexContext(const SearchIndexList *sl,const QCString &name) +SymbolIndexContext::SymbolIndexContext(const std::string &letter,const SearchIndexList &sl,const QCString &name) : RefCountedContext("SymbolIndexContext") { - p = new Private(sl,name); + p = new Private(letter,sl,name); } SymbolIndexContext::~SymbolIndexContext() @@ -9837,19 +9856,17 @@ TemplateVariant SymbolIndexContext::get(const char *name) const class SymbolIndicesContext::Private : public GenericNodeListContext { public: - Private(const SearchIndexInfo *info) + Private(const SearchIndexInfo &info) { // use info->symbolList to populate the list - SIntDict::Iterator it(info->symbolList); - const SearchIndexList *sl; - for (it.toFirst();(sl=it.current());++it) // for each letter + for (const auto &kv : info.symbolMap) { - append(SymbolIndexContext::alloc(sl,info->name)); + append(SymbolIndexContext::alloc(kv.first,kv.second,info.name)); } } }; -SymbolIndicesContext::SymbolIndicesContext(const SearchIndexInfo *info) : RefCountedContext("SymbolIndicesContext") +SymbolIndicesContext::SymbolIndicesContext(const SearchIndexInfo &info) : RefCountedContext("SymbolIndicesContext") { p = new Private(info); } @@ -9882,7 +9899,7 @@ TemplateListIntf::ConstIterator *SymbolIndicesContext::createIterator() const class SearchIndexContext::Private { public: - Private(const SearchIndexInfo *info) : m_info(info) + Private(const SearchIndexInfo &info) : m_info(info) { static bool init=FALSE; if (!init) @@ -9899,11 +9916,11 @@ class SearchIndexContext::Private } TemplateVariant name() const { - return m_info->name; + return m_info.name; } TemplateVariant text() const { - return m_info->text; + return m_info.getText(); } TemplateVariant symbolIndices() const { @@ -9914,7 +9931,7 @@ class SearchIndexContext::Private return m_cache.symbolIndices.get(); } private: - const SearchIndexInfo *m_info; + const SearchIndexInfo &m_info; struct Cachable { SharedPtr symbolIndices; @@ -9926,7 +9943,7 @@ class SearchIndexContext::Private PropertyMapper SearchIndexContext::Private::s_inst; -SearchIndexContext::SearchIndexContext(const SearchIndexInfo *info) +SearchIndexContext::SearchIndexContext(const SearchIndexInfo &info) : RefCountedContext("SearchIndexContext") { p = new Private(info); @@ -9950,10 +9967,9 @@ class SearchIndicesContext::Private : public GenericNodeListContext public: Private() { - const SearchIndexInfo *indices = getSearchIndices(); - for (int i=0;i #include "dirdef.h" #include "classdef.h" +#include "searchindex.h" class Definition; class PageDef; @@ -52,9 +53,6 @@ class MemberGroupSDict; class MemberGroupList; class DotNode; class DotGfxHierarchyTable; -struct SearchIndexInfo; -class SearchIndexList; -class SearchDefinitionList; //---------------------------------------------------- @@ -1206,8 +1204,9 @@ class SymbolContext : public RefCountedContext, public TemplateStructIntf class SymbolListContext : public RefCountedContext, public TemplateListIntf { public: - static SymbolListContext *alloc(const SearchDefinitionList *sdl) - { return new SymbolListContext(sdl); } + static SymbolListContext *alloc(const SearchIndexList::const_iterator &start, + const SearchIndexList::const_iterator &end) + { return new SymbolListContext(start,end); } // TemplateListIntf virtual uint count() const; @@ -1217,7 +1216,8 @@ class SymbolListContext : public RefCountedContext, public TemplateListIntf virtual int release() { return RefCountedContext::release(); } private: - SymbolListContext(const SearchDefinitionList *sdl); + SymbolListContext(const SearchIndexList::const_iterator &start, + const SearchIndexList::const_iterator &end); ~SymbolListContext(); class Private; Private *p; @@ -1228,8 +1228,9 @@ class SymbolListContext : public RefCountedContext, public TemplateListIntf class SymbolGroupContext : public RefCountedContext, public TemplateStructIntf { public: - static SymbolGroupContext *alloc(const SearchDefinitionList *sdl) - { return new SymbolGroupContext(sdl); } + static SymbolGroupContext *alloc(const SearchIndexList::const_iterator &start, + const SearchIndexList::const_iterator &end) + { return new SymbolGroupContext(start,end); } // TemplateStructIntf methods virtual TemplateVariant get(const char *name) const; @@ -1237,7 +1238,8 @@ class SymbolGroupContext : public RefCountedContext, public TemplateStructIntf virtual int release() { return RefCountedContext::release(); } private: - SymbolGroupContext(const SearchDefinitionList *sdl); + SymbolGroupContext(const SearchIndexList::const_iterator &start, + const SearchIndexList::const_iterator &end); ~SymbolGroupContext(); class Private; Private *p; @@ -1248,7 +1250,7 @@ class SymbolGroupContext : public RefCountedContext, public TemplateStructIntf class SymbolGroupListContext : public RefCountedContext, public TemplateListIntf { public: - static SymbolGroupListContext *alloc(const SearchIndexList *sil) + static SymbolGroupListContext *alloc(const SearchIndexList &sil) { return new SymbolGroupListContext(sil); } // TemplateListIntf @@ -1259,7 +1261,7 @@ class SymbolGroupListContext : public RefCountedContext, public TemplateListIntf virtual int release() { return RefCountedContext::release(); } private: - SymbolGroupListContext(const SearchIndexList *sil); + SymbolGroupListContext(const SearchIndexList &sil); ~SymbolGroupListContext(); class Private; Private *p; @@ -1270,8 +1272,9 @@ class SymbolGroupListContext : public RefCountedContext, public TemplateListIntf class SymbolIndexContext : public RefCountedContext, public TemplateStructIntf { public: - static SymbolIndexContext *alloc(const SearchIndexList *sl,const QCString &name) - { return new SymbolIndexContext(sl,name); } + static SymbolIndexContext *alloc(const std::string &letter, + const SearchIndexList &sl,const QCString &name) + { return new SymbolIndexContext(letter,sl,name); } // TemplateStructIntf methods virtual TemplateVariant get(const char *name) const; @@ -1279,7 +1282,7 @@ class SymbolIndexContext : public RefCountedContext, public TemplateStructIntf virtual int release() { return RefCountedContext::release(); } private: - SymbolIndexContext(const SearchIndexList *sl,const QCString &name); + SymbolIndexContext(const std::string &letter,const SearchIndexList &sl,const QCString &name); ~SymbolIndexContext(); class Private; Private *p; @@ -1290,7 +1293,7 @@ class SymbolIndexContext : public RefCountedContext, public TemplateStructIntf class SymbolIndicesContext : public RefCountedContext, public TemplateListIntf { public: - static SymbolIndicesContext *alloc(const SearchIndexInfo *info) + static SymbolIndicesContext *alloc(const SearchIndexInfo &info) { return new SymbolIndicesContext(info); } // TemplateListIntf @@ -1301,7 +1304,7 @@ class SymbolIndicesContext : public RefCountedContext, public TemplateListIntf virtual int release() { return RefCountedContext::release(); } private: - SymbolIndicesContext(const SearchIndexInfo *info); + SymbolIndicesContext(const SearchIndexInfo &info); ~SymbolIndicesContext(); class Private; Private *p; @@ -1312,7 +1315,7 @@ class SymbolIndicesContext : public RefCountedContext, public TemplateListIntf class SearchIndexContext : public RefCountedContext, public TemplateStructIntf { public: - static SearchIndexContext *alloc(const SearchIndexInfo *info) + static SearchIndexContext *alloc(const SearchIndexInfo &info) { return new SearchIndexContext(info); } // TemplateStructIntf methods @@ -1321,7 +1324,7 @@ class SearchIndexContext : public RefCountedContext, public TemplateStructIntf virtual int release() { return RefCountedContext::release(); } private: - SearchIndexContext(const SearchIndexInfo *info); + SearchIndexContext(const SearchIndexInfo &info); ~SearchIndexContext(); class Private; Private *p; diff --git a/src/searchindex.cpp b/src/searchindex.cpp index 42601b9..0b2b219 100644 --- a/src/searchindex.cpp +++ b/src/searchindex.cpp @@ -1,8 +1,6 @@ /****************************************************************************** * - * - * - * Copyright (C) 1997-2015 by Dimitri van Heesch. + * Copyright (C) 1997-2020 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby @@ -15,6 +13,7 @@ * */ + #include #include @@ -31,7 +30,6 @@ #include "message.h" #include "version.h" #include "groupdef.h" -#include "classlist.h" #include "filedef.h" #include "memberdef.h" #include "filename.h" @@ -40,6 +38,10 @@ #include "namespacedef.h" #include "classdef.h" +//--------------------------------------------------------------------------------------------- +// the following part is for the server based search engine +//--------------------------------------------------------------------------------------------- + // file format: (all multi-byte values are stored in big endian format) // 4 byte header // 256*256*4 byte index (4 bytes) @@ -532,11 +534,96 @@ void SearchIndexExternal::write(const char *fileName) } } -//--------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------- // the following part is for the javascript based search engine +//--------------------------------------------------------------------------------------------- + +QCString searchName(const Definition *d) +{ + return d->definitionType()==Definition::TypeGroup ? QCString(toGroupDef(d)->groupTitle()) : + d->definitionType()==Definition::TypePage ? toPageDef(d)->title() : + d->localName(); +} + +QCString searchId(const Definition *d) +{ + QCString s = searchName(d); + int c; + uint i; + QCString result; + for (i=0;i0x7f || c<0) // part of multibyte character + { + result+=(char)c; + } + else if (isalnum(c)) // simply alpha numerical character + { + result+=(char)tolower(c); + } + else // other 'unprintable' characters + { + char val[4]; + sprintf(val,"_%02x",(uchar)c); + result+=val; + } + } + return result; +} -static SearchIndexInfo g_searchIndexInfo[NUM_SEARCH_INDICES]; +#define SEARCH_INDEX_ALL 0 +#define SEARCH_INDEX_CLASSES 1 +#define SEARCH_INDEX_INTERFACES 2 +#define SEARCH_INDEX_STRUCTS 3 +#define SEARCH_INDEX_EXCEPTIONS 4 +#define SEARCH_INDEX_NAMESPACES 5 +#define SEARCH_INDEX_FILES 6 +#define SEARCH_INDEX_FUNCTIONS 7 +#define SEARCH_INDEX_VARIABLES 8 +#define SEARCH_INDEX_TYPEDEFS 9 +#define SEARCH_INDEX_SEQUENCES 10 +#define SEARCH_INDEX_DICTIONARIES 11 +#define SEARCH_INDEX_ENUMS 12 +#define SEARCH_INDEX_ENUMVALUES 13 +#define SEARCH_INDEX_PROPERTIES 14 +#define SEARCH_INDEX_EVENTS 15 +#define SEARCH_INDEX_RELATED 16 +#define SEARCH_INDEX_DEFINES 17 +#define SEARCH_INDEX_GROUPS 18 +#define SEARCH_INDEX_PAGES 19 + +static std::array g_searchIndexInfo = +{ { + // index name getText symbolList + { /* SEARCH_INDEX_ALL */ "all" , []() { return theTranslator->trAll(); }, {} }, + { /* SEARCH_INDEX_CLASSES */ "classes" , []() { return theTranslator->trClasses(); }, {} }, + { /* SEARCH_INDEX_INTERFACES */ "interfaces" , []() { return theTranslator->trSliceInterfaces(); }, {} }, + { /* SEARCH_INDEX_STRUCTS */ "structs" , []() { return theTranslator->trStructs(); }, {} }, + { /* SEARCH_INDEX_EXCEPTIONS */ "exceptions" , []() { return theTranslator->trExceptions(); }, {} }, + { /* SEARCH_INDEX_NAMESPACES */ "namespaces" , []() { return Config_getBool(OPTIMIZE_OUTPUT_SLICE) ? + theTranslator->trModules() : + theTranslator->trNamespace(TRUE,FALSE); }, {} }, + { /* SEARCH_INDEX_FILES */ "files" , []() { return theTranslator->trFile(TRUE,FALSE); }, {} }, + { /* SEARCH_INDEX_FUNCTIONS */ "functions" , []() { return Config_getBool(OPTIMIZE_OUTPUT_SLICE) ? + theTranslator->trOperations() : + theTranslator->trFunctions(); }, {} }, + { /* SEARCH_INDEX_VARIABLES */ "variables" , []() { return Config_getBool(OPTIMIZE_OUTPUT_SLICE) ? + theTranslator->trConstants() : + theTranslator->trVariables(); }, {} }, + { /* SEARCH_INDEX_TYPEDEFS */ "typedefs" , []() { return theTranslator->trTypedefs(); }, {} }, + { /* SEARCH_INDEX_SEQUENCES */ "sequences" , []() { return theTranslator->trSequences(); }, {} }, + { /* SEARCH_INDEX_DICTIONARIES */ "dictionaries", []() { return theTranslator->trDictionaries(); }, {} }, + { /* SEARCH_INDEX_ENUMS */ "enums" , []() { return theTranslator->trEnumerations(); }, {} }, + { /* SEARCH_INDEX_ENUMVALUES */ "enumvalues" , []() { return theTranslator->trEnumerationValues(); }, {} }, + { /* SEARCH_INDEX_PROPERTIES */ "properties" , []() { return theTranslator->trProperties(); }, {} }, + { /* SEARCH_INDEX_EVENTS */ "events" , []() { return theTranslator->trEvents(); }, {} }, + { /* SEARCH_INDEX_RELATED */ "related" , []() { return theTranslator->trFriends(); }, {} }, + { /* SEARCH_INDEX_DEFINES */ "defines" , []() { return theTranslator->trDefines(); }, {} }, + { /* SEARCH_INDEX_GROUPS */ "groups" , []() { return theTranslator->trGroup(TRUE,FALSE); }, {} }, + { /* SEARCH_INDEX_PAGES */ "pages" , []() { return theTranslator->trPage(TRUE,FALSE); }, {} } +} }; static void addMemberToSearchIndex(const MemberDef *md) { @@ -556,55 +643,56 @@ static void addMemberToSearchIndex(const MemberDef *md) QCString n = md->name(); if (!n.isEmpty()) { - uint letter = getUtf8CodeToLower(n,0); + char letter[MAX_UTF8_CHAR_SIZE]; + getUtf8Char(n,letter,CaseModifier::ToLower); bool isFriendToHide = hideFriendCompounds && (QCString(md->typeString())=="friend class" || QCString(md->typeString())=="friend struct" || QCString(md->typeString())=="friend union"); if (!(md->isFriend() && isFriendToHide)) { - g_searchIndexInfo[SEARCH_INDEX_ALL].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,md); } if (md->isFunction() || md->isSlot() || md->isSignal()) { - g_searchIndexInfo[SEARCH_INDEX_FUNCTIONS].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_FUNCTIONS].add(letter,md); } else if (md->isVariable()) { - g_searchIndexInfo[SEARCH_INDEX_VARIABLES].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_VARIABLES].add(letter,md); } else if (md->isSequence()) { - g_searchIndexInfo[SEARCH_INDEX_SEQUENCES].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_SEQUENCES].add(letter,md); } else if (md->isDictionary()) { - g_searchIndexInfo[SEARCH_INDEX_DICTIONARIES].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_DICTIONARIES].add(letter,md); } else if (md->isTypedef()) { - g_searchIndexInfo[SEARCH_INDEX_TYPEDEFS].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_TYPEDEFS].add(letter,md); } else if (md->isEnumerate()) { - g_searchIndexInfo[SEARCH_INDEX_ENUMS].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_ENUMS].add(letter,md); } else if (md->isEnumValue()) { - g_searchIndexInfo[SEARCH_INDEX_ENUMVALUES].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_ENUMVALUES].add(letter,md); } else if (md->isProperty()) { - g_searchIndexInfo[SEARCH_INDEX_PROPERTIES].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_PROPERTIES].add(letter,md); } else if (md->isEvent()) { - g_searchIndexInfo[SEARCH_INDEX_EVENTS].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_EVENTS].add(letter,md); } else if (md->isRelated() || md->isForeign() || (md->isFriend() && !isFriendToHide)) { - g_searchIndexInfo[SEARCH_INDEX_RELATED].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_RELATED].add(letter,md); } } } @@ -617,155 +705,80 @@ static void addMemberToSearchIndex(const MemberDef *md) QCString n = md->name(); if (!n.isEmpty()) { - uint letter = getUtf8CodeToLower(n,0); - g_searchIndexInfo[SEARCH_INDEX_ALL].symbolList.append(letter,md); + char letter[MAX_UTF8_CHAR_SIZE]; + getUtf8Char(n,letter,CaseModifier::ToLower); + g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,md); if (md->isFunction()) { - g_searchIndexInfo[SEARCH_INDEX_FUNCTIONS].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_FUNCTIONS].add(letter,md); } else if (md->isVariable()) { - g_searchIndexInfo[SEARCH_INDEX_VARIABLES].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_VARIABLES].add(letter,md); } else if (md->isSequence()) { - g_searchIndexInfo[SEARCH_INDEX_SEQUENCES].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_SEQUENCES].add(letter,md); } else if (md->isDictionary()) { - g_searchIndexInfo[SEARCH_INDEX_DICTIONARIES].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_DICTIONARIES].add(letter,md); } else if (md->isTypedef()) { - g_searchIndexInfo[SEARCH_INDEX_TYPEDEFS].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_TYPEDEFS].add(letter,md); } else if (md->isEnumerate()) { - g_searchIndexInfo[SEARCH_INDEX_ENUMS].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_ENUMS].add(letter,md); } else if (md->isEnumValue()) { - g_searchIndexInfo[SEARCH_INDEX_ENUMVALUES].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_ENUMVALUES].add(letter,md); } else if (md->isDefine()) { - g_searchIndexInfo[SEARCH_INDEX_DEFINES].symbolList.append(letter,md); + g_searchIndexInfo[SEARCH_INDEX_DEFINES].add(letter,md); } } } } -// see also function convertToId() in search.js, which should match in -// behaviour -static QCString searchId(const QCString &s) -{ - int c; - uint i; - QCString result; - for (i=0;i0x7f || c<0) // part of multibyte character - { - result+=(char)c; - } - else if (isalnum(c)) // simply alpha numerical character - { - result+=(char)tolower(c); - } - else // other 'unprintable' characters - { - char val[4]; - sprintf(val,"_%02x",(uchar)c); - result+=val; - } - } - return result; -} +//--------------------------------------------------------------------------------------------- void createJavaScriptSearchIndex() { - bool sliceOpt = Config_getBool(OPTIMIZE_OUTPUT_SLICE); - - // set index names - g_searchIndexInfo[SEARCH_INDEX_ALL].name = "all"; - g_searchIndexInfo[SEARCH_INDEX_CLASSES].name = "classes"; - g_searchIndexInfo[SEARCH_INDEX_INTERFACES].name = "interfaces"; - g_searchIndexInfo[SEARCH_INDEX_STRUCTS].name = "structs"; - g_searchIndexInfo[SEARCH_INDEX_EXCEPTIONS].name = "exceptions"; - g_searchIndexInfo[SEARCH_INDEX_NAMESPACES].name = "namespaces"; - g_searchIndexInfo[SEARCH_INDEX_FILES].name = "files"; - g_searchIndexInfo[SEARCH_INDEX_FUNCTIONS].name = "functions"; - g_searchIndexInfo[SEARCH_INDEX_VARIABLES].name = "variables"; - g_searchIndexInfo[SEARCH_INDEX_TYPEDEFS].name = "typedefs"; - g_searchIndexInfo[SEARCH_INDEX_SEQUENCES].name = "sequences"; - g_searchIndexInfo[SEARCH_INDEX_DICTIONARIES].name = "dictionaries"; - g_searchIndexInfo[SEARCH_INDEX_ENUMS].name = "enums"; - g_searchIndexInfo[SEARCH_INDEX_ENUMVALUES].name = "enumvalues"; - g_searchIndexInfo[SEARCH_INDEX_PROPERTIES].name = "properties"; - g_searchIndexInfo[SEARCH_INDEX_EVENTS].name = "events"; - g_searchIndexInfo[SEARCH_INDEX_RELATED].name = "related"; - g_searchIndexInfo[SEARCH_INDEX_DEFINES].name = "defines"; - g_searchIndexInfo[SEARCH_INDEX_GROUPS].name = "groups"; - g_searchIndexInfo[SEARCH_INDEX_PAGES].name = "pages"; - - // set index texts - g_searchIndexInfo[SEARCH_INDEX_ALL].text = theTranslator->trAll(); - g_searchIndexInfo[SEARCH_INDEX_CLASSES].text = theTranslator->trClasses(); - g_searchIndexInfo[SEARCH_INDEX_INTERFACES].text = theTranslator->trSliceInterfaces(); - g_searchIndexInfo[SEARCH_INDEX_STRUCTS].text = theTranslator->trStructs(); - g_searchIndexInfo[SEARCH_INDEX_EXCEPTIONS].text = theTranslator->trExceptions(); - g_searchIndexInfo[SEARCH_INDEX_NAMESPACES].text = sliceOpt ? theTranslator->trModules() : - theTranslator->trNamespace(TRUE,FALSE); - g_searchIndexInfo[SEARCH_INDEX_FILES].text = theTranslator->trFile(TRUE,FALSE); - g_searchIndexInfo[SEARCH_INDEX_FUNCTIONS].text = sliceOpt ? theTranslator->trOperations() : - theTranslator->trFunctions(); - g_searchIndexInfo[SEARCH_INDEX_VARIABLES].text = sliceOpt ? theTranslator->trConstants() : - theTranslator->trVariables(); - g_searchIndexInfo[SEARCH_INDEX_TYPEDEFS].text = theTranslator->trTypedefs(); - g_searchIndexInfo[SEARCH_INDEX_SEQUENCES].text = theTranslator->trSequences(); - g_searchIndexInfo[SEARCH_INDEX_DICTIONARIES].text = theTranslator->trDictionaries(); - g_searchIndexInfo[SEARCH_INDEX_ENUMS].text = theTranslator->trEnumerations(); - g_searchIndexInfo[SEARCH_INDEX_ENUMVALUES].text = theTranslator->trEnumerationValues(); - g_searchIndexInfo[SEARCH_INDEX_PROPERTIES].text = theTranslator->trProperties(); - g_searchIndexInfo[SEARCH_INDEX_EVENTS].text = theTranslator->trEvents(); - g_searchIndexInfo[SEARCH_INDEX_RELATED].text = theTranslator->trFriends(); - g_searchIndexInfo[SEARCH_INDEX_DEFINES].text = theTranslator->trDefines(); - g_searchIndexInfo[SEARCH_INDEX_GROUPS].text = theTranslator->trGroup(TRUE,FALSE); - g_searchIndexInfo[SEARCH_INDEX_PAGES].text = theTranslator->trPage(TRUE,FALSE); - - // add symbols to letter -> symbol list map - // index classes for (const auto &cd : *Doxygen::classLinkedMap) { - uint letter = getUtf8CodeToLower(cd->localName(),0); - if (cd->isLinkable() && isId(letter)) + char letter[MAX_UTF8_CHAR_SIZE]; + getUtf8Char(cd->localName(),letter,CaseModifier::ToLower); + if (cd->isLinkable()) { - g_searchIndexInfo[SEARCH_INDEX_ALL].symbolList.append(letter,cd.get()); - if (sliceOpt) + g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,cd.get()); + if (Config_getBool(OPTIMIZE_OUTPUT_SLICE)) { if (cd->compoundType()==ClassDef::Interface) { - g_searchIndexInfo[SEARCH_INDEX_INTERFACES].symbolList.append(letter,cd.get()); + g_searchIndexInfo[SEARCH_INDEX_INTERFACES].add(letter,cd.get()); } else if (cd->compoundType()==ClassDef::Struct) { - g_searchIndexInfo[SEARCH_INDEX_STRUCTS].symbolList.append(letter,cd.get()); + g_searchIndexInfo[SEARCH_INDEX_STRUCTS].add(letter,cd.get()); } else if (cd->compoundType()==ClassDef::Exception) { - g_searchIndexInfo[SEARCH_INDEX_EXCEPTIONS].symbolList.append(letter,cd.get()); + g_searchIndexInfo[SEARCH_INDEX_EXCEPTIONS].add(letter,cd.get()); } else // cd->compoundType()==ClassDef::Class { - g_searchIndexInfo[SEARCH_INDEX_CLASSES].symbolList.append(letter,cd.get()); + g_searchIndexInfo[SEARCH_INDEX_CLASSES].add(letter,cd.get()); } } else // non slice optimisation: group all types under classes { - g_searchIndexInfo[SEARCH_INDEX_CLASSES].symbolList.append(letter,cd.get()); + g_searchIndexInfo[SEARCH_INDEX_CLASSES].add(letter,cd.get()); } } } @@ -773,11 +786,12 @@ void createJavaScriptSearchIndex() // index namespaces for (const auto &nd : *Doxygen::namespaceLinkedMap) { - uint letter = getUtf8CodeToLower(nd->name(),0); - if (nd->isLinkable() && isId(letter)) + char letter[MAX_UTF8_CHAR_SIZE]; + getUtf8Char(nd->name(),letter,CaseModifier::ToLower); + if (nd->isLinkable()) { - g_searchIndexInfo[SEARCH_INDEX_ALL].symbolList.append(letter,nd.get()); - g_searchIndexInfo[SEARCH_INDEX_NAMESPACES].symbolList.append(letter,nd.get()); + g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,nd.get()); + g_searchIndexInfo[SEARCH_INDEX_NAMESPACES].add(letter,nd.get()); } } @@ -786,11 +800,12 @@ void createJavaScriptSearchIndex() { for (const auto &fd : *fn) { - uint letter = getUtf8CodeToLower(fd->name(),0); - if (fd->isLinkable() && isId(letter)) + char letter[MAX_UTF8_CHAR_SIZE]; + getUtf8Char(fd->name(),letter,CaseModifier::ToLower); + if (fd->isLinkable()) { - g_searchIndexInfo[SEARCH_INDEX_ALL].symbolList.append(letter,fd.get()); - g_searchIndexInfo[SEARCH_INDEX_FILES].symbolList.append(letter,fd.get()); + g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,fd.get()); + g_searchIndexInfo[SEARCH_INDEX_FILES].add(letter,fd.get()); } } } @@ -831,13 +846,10 @@ void createJavaScriptSearchIndex() QCString title = gd->groupTitle(); if (!title.isEmpty()) // TODO: able searching for all word in the title { - uchar charCode = title.at(0); - uint letter = charCode<128 ? tolower(charCode) : charCode; - if (isId(letter)) - { - g_searchIndexInfo[SEARCH_INDEX_ALL].symbolList.append(letter,gd); - g_searchIndexInfo[SEARCH_INDEX_GROUPS].symbolList.append(letter,gd); - } + char letter[MAX_UTF8_CHAR_SIZE]; + getUtf8Char(title,letter,CaseModifier::ToLower); + g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,gd); + g_searchIndexInfo[SEARCH_INDEX_GROUPS].add(letter,gd); } } } @@ -852,13 +864,10 @@ void createJavaScriptSearchIndex() QCString title = pd->title(); if (!title.isEmpty()) { - uchar charCode = title.at(0); - uint letter = charCode<128 ? tolower(charCode) : charCode; - if (isId(letter)) - { - g_searchIndexInfo[SEARCH_INDEX_ALL].symbolList.append(letter,pd); - g_searchIndexInfo[SEARCH_INDEX_PAGES].symbolList.append(letter,pd); - } + char letter[MAX_UTF8_CHAR_SIZE]; + getUtf8Char(title,letter,CaseModifier::ToLower); + g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,pd); + g_searchIndexInfo[SEARCH_INDEX_PAGES].add(letter,pd); } } } @@ -867,45 +876,43 @@ void createJavaScriptSearchIndex() QCString title = Doxygen::mainPage->title(); if (!title.isEmpty()) { - uchar charCode = title.at(0); - uint letter = charCode<128 ? tolower(charCode) : charCode; - if (isId(letter)) - { - g_searchIndexInfo[SEARCH_INDEX_ALL].symbolList.append(letter,Doxygen::mainPage); - g_searchIndexInfo[SEARCH_INDEX_PAGES].symbolList.append(letter,Doxygen::mainPage); - } + char letter[MAX_UTF8_CHAR_SIZE]; + getUtf8Char(title,letter,CaseModifier::ToLower); + g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,Doxygen::mainPage); + g_searchIndexInfo[SEARCH_INDEX_PAGES].add(letter,Doxygen::mainPage); } } // sort all lists - int i; - for (i=0;i::Iterator it(g_searchIndexInfo[i].symbolList); - SearchIndexList *sl; - for (it.toFirst();(sl=it.current());++it) + for (auto &kv : sii.symbolMap) // for each symbol in the index { - sl->sort(); + // sort the symbols (first on "search" name, and then on full name) + std::sort(kv.second.begin(), + kv.second.end(), + [](const Definition *d1,const Definition *d2) + { + int eq = qstricmp(searchName(d1),searchName(d2)); // search name first + return eq==0 ? qstricmp(d1->name(),d2->name())<0 : eq<0; // then full name + }); } } } void writeJavaScriptSearchIndex() { - int i; int cnt = 0; // write index files QCString searchDirName = Config_getString(HTML_OUTPUT)+"/search"; - for (i=0;i::Iterator it(g_searchIndexInfo[i].symbolList); - SearchIndexList *sl; int p=0; - for (it.toFirst();(sl=it.current());++it,++p) // for each letter + for (const auto &kv : sii.symbolMap) { QCString baseName; - baseName.sprintf("%s_%x",g_searchIndexInfo[i].name.data(),p); + baseName.sprintf("%s_%x",sii.name.data(),p); QCString fileName = searchDirName + "/"+baseName+Doxygen::htmlFileExtension; QCString dataFileName = searchDirName + "/"+baseName+".js"; @@ -975,44 +982,61 @@ void writeJavaScriptSearchIndex() ti << "[" << endl; bool firstEntry=TRUE; - SDict::Iterator li(*sl); - SearchDefinitionList *dl; - int itemCount=0; - for (li.toFirst();(dl=li.current());++li) + int childCount=0; + QCString lastName; + const Definition *prevScope = 0; + for (auto it = kv.second.begin(); it!=kv.second.end();) { - const Definition *d = dl->getFirst(); + const Definition *d = *it; + QCString sname = searchName(d); + QCString id = searchId(d); - if (!firstEntry) + if (sname!=lastName) // this item has a different search word { - ti << "," << endl; + if (!firstEntry) + { + ti << "]]]"; + ti << "," << endl; + } + firstEntry=FALSE; + + ti << " ['" << id << "_" << cnt++ << "',['" << convertToXML(sname) << "',["; + childCount=0; + prevScope=0; } - firstEntry=FALSE; - ti << " ['" << dl->id() << "_" << cnt++ << "',['" << convertToXML(dl->name()) << "',["; + ++it; + const Definition *scope = d->getOuterScope(); + const Definition *next = it!=kv.second.end() ? *it : 0; + const Definition *nextScope = 0; + const MemberDef *md = toMemberDef(d); + if (next) nextScope = next->getOuterScope(); + QCString anchor = d->anchor(); - if (dl->count()==1) // item with a unique name + if (childCount>0) { - const MemberDef *md = toMemberDef(d); - QCString anchor = d->anchor(); - - ti << "'" << externalRef("../",d->getReference(),TRUE) - << addHtmlExtensionIfMissing(d->getOutputFileBase()); - if (!anchor.isEmpty()) - { - ti << "#" << anchor; - } - ti << "',"; + ti << "],["; + } + ti << "'" << externalRef("../",d->getReference(),TRUE) + << addHtmlExtensionIfMissing(d->getOutputFileBase()); + if (!anchor.isEmpty()) + { + ti << "#" << anchor; + } + ti << "',"; - static bool extLinksInWindow = Config_getBool(EXT_LINKS_IN_WINDOW); - if (!extLinksInWindow || d->getReference().isEmpty()) - { - ti << "1,"; - } - else - { - ti << "0,"; - } + static bool extLinksInWindow = Config_getBool(EXT_LINKS_IN_WINDOW); + if (!extLinksInWindow || d->getReference().isEmpty()) + { + ti << "1,"; + } + else + { + ti << "0,"; + } + if (lastName!=sname && (next==0 || searchName(next)!=sname)) // unique name + { if (d->getOuterScope()!=Doxygen::globalScope) { ti << "'" << convertToXML(d->getOuterScope()->name()) << "'"; @@ -1030,127 +1054,84 @@ void writeJavaScriptSearchIndex() { ti << "''"; } - ti << "]]"; } - else // multiple items with the same name + else // multiple entries with the same name { - QListIterator di(*dl); - bool overloadedFunction = FALSE; - const Definition *prevScope = 0; - int childCount=0; - for (di.toFirst();(d=di.current());) + bool found=FALSE; + bool overloadedFunction = ((prevScope!=0 && scope==prevScope) || + (scope && scope==nextScope)) && md && (md->isFunction() || md->isSlot()); + QCString prefix; + if (md) prefix=convertToXML(md->localName()); + if (overloadedFunction) // overloaded member function { - ++di; - const Definition *scope = d->getOuterScope(); - const Definition *next = di.current(); - const Definition *nextScope = 0; - const MemberDef *md = toMemberDef(d); - if (next) nextScope = next->getOuterScope(); - QCString anchor = d->anchor(); - - if (childCount>0) - { - ti << "],["; - } - ti << "'" << externalRef("../",d->getReference(),TRUE) - << addHtmlExtensionIfMissing(d->getOutputFileBase()); - if (!anchor.isEmpty()) - { - ti << "#" << anchor; - } - ti << "',"; - - static bool extLinksInWindow = Config_getBool(EXT_LINKS_IN_WINDOW); - if (!extLinksInWindow || d->getReference().isEmpty()) - { - ti << "1,"; - } - else - { - ti << "0,"; - } - bool found=FALSE; - overloadedFunction = ((prevScope!=0 && scope==prevScope) || - (scope && scope==nextScope) - ) && md && - (md->isFunction() || md->isSlot()); - QCString prefix; - if (md) prefix=convertToXML(md->localName()); - if (overloadedFunction) // overloaded member function - { - prefix+=convertToXML(md->argsString()); - // show argument list to disambiguate overloaded functions - } - else if (md) // unique member function - { - prefix+="()"; // only to show it is a function - } - QCString name; - if (d->definitionType()==Definition::TypeClass) - { - name = convertToXML((toClassDef(d))->displayName()); - found = TRUE; - } - else if (d->definitionType()==Definition::TypeNamespace) - { - name = convertToXML((toNamespaceDef(d))->displayName()); - found = TRUE; - } - else if (scope==0 || scope==Doxygen::globalScope) // in global scope + prefix+=convertToXML(md->argsString()); + // show argument list to disambiguate overloaded functions + } + else if (md) // unique member function + { + prefix+="()"; // only to show it is a function + } + QCString name; + if (d->definitionType()==Definition::TypeClass) + { + name = convertToXML((toClassDef(d))->displayName()); + found = TRUE; + } + else if (d->definitionType()==Definition::TypeNamespace) + { + name = convertToXML((toNamespaceDef(d))->displayName()); + found = TRUE; + } + else if (scope==0 || scope==Doxygen::globalScope) // in global scope + { + if (md) { - if (md) + const FileDef *fd = md->getBodyDef(); + if (fd==0) fd = md->resolveAlias()->getFileDef(); + if (fd) { - const FileDef *fd = md->getBodyDef(); - if (fd==0) fd = md->resolveAlias()->getFileDef(); - if (fd) - { - if (!prefix.isEmpty()) prefix+=": "; - name = prefix + convertToXML(fd->localName()); - found = TRUE; - } + if (!prefix.isEmpty()) prefix+=": "; + name = prefix + convertToXML(fd->localName()); + found = TRUE; } } - else if (md && (md->resolveAlias()->getClassDef() || md->resolveAlias()->getNamespaceDef())) - // member in class or namespace scope - { - SrcLangExt lang = md->getLanguage(); - name = convertToXML(d->getOuterScope()->qualifiedName()) - + getLanguageSpecificSeparator(lang) + prefix; - found = TRUE; - } - else if (scope) // some thing else? -> show scope - { - name = prefix + convertToXML(scope->name()); - found = TRUE; - } - if (!found) // fallback - { - name = prefix + "("+theTranslator->trGlobalNamespace()+")"; - } - - ti << "'" << name << "'"; - - prevScope = scope; - childCount++; } + else if (md && (md->resolveAlias()->getClassDef() || md->resolveAlias()->getNamespaceDef())) + // member in class or namespace scope + { + SrcLangExt lang = md->getLanguage(); + name = convertToXML(d->getOuterScope()->qualifiedName()) + + getLanguageSpecificSeparator(lang) + prefix; + found = TRUE; + } + else if (scope) // some thing else? -> show scope + { + name = prefix + convertToXML(scope->name()); + found = TRUE; + } + if (!found) // fallback + { + name = prefix + "("+theTranslator->trGlobalNamespace()+")"; + } + + ti << "'" << name << "'"; - ti << "]]"; + prevScope = scope; + childCount++; } - ti << "]"; - itemCount++; + lastName = sname; } if (!firstEntry) { - ti << endl; + ti << "]]]" << endl; } - ti << "];" << endl; - } else { err("Failed to open file '%s' for writing...\n",fileName.data()); } + p++; } } @@ -1161,64 +1142,57 @@ void writeJavaScriptSearchIndex() FTextStream t(&f); t << "var indexSectionsWithContent =" << endl; t << "{" << endl; - bool first=TRUE; int j=0; - for (i=0;i0) + if (!sii.symbolMap.empty()) { - if (!first) t << "," << endl; + if (j>0) t << "," << endl; t << " " << j << ": \""; - SIntDict::Iterator it(g_searchIndexInfo[i].symbolList); - SearchIndexList *sl; - for (it.toFirst();(sl=it.current());++it) // for each letter + for (const auto &kv : sii.symbolMap) { - if ( sl->letter() == '"' ) t << QString( QChar( '\\' ) ).utf8(); - t << QString( QChar( sl->letter() ) ).utf8(); + if ( kv.first == "\"" ) t << "\\"; + t << kv.first.c_str(); } t << "\""; - first=FALSE; j++; } } - if (!first) t << "\n"; + if (j>0) t << "\n"; t << "};" << endl << endl; t << "var indexSectionNames =" << endl; t << "{" << endl; - first=TRUE; j=0; - for (i=0;i0) + if (!sii.symbolMap.empty()) { - if (!first) t << "," << endl; - t << " " << j << ": \"" << g_searchIndexInfo[i].name << "\""; - first=FALSE; + if (j>0) t << "," << endl; + t << " " << j << ": \"" << sii.name << "\""; j++; } } - if (!first) t << "\n"; + if (j>0) t << "\n"; t << "};" << endl << endl; t << "var indexSectionLabels =" << endl; t << "{" << endl; - first=TRUE; j=0; - for (i=0;i0) + if (!sii.symbolMap.empty()) { - if (!first) t << "," << endl; - t << " " << j << ": \"" << convertToXML(g_searchIndexInfo[i].text) << "\""; - first=FALSE; + if (j>0) t << "," << endl; + t << " " << j << ": \"" << convertToXML(sii.getText()) << "\""; j++; } } - if (!first) t << "\n"; + if (j>0) t << "\n"; t << "};" << endl << endl; } ResourceMgr::instance().copyResource("search.js",searchDirName); } + { QFile f(searchDirName+"/nomatches"+Doxygen::htmlFileExtension); if (f.open(IO_WriteOnly)) @@ -1244,53 +1218,23 @@ void writeJavaScriptSearchIndex() Doxygen::indexList->addStyleSheetFile("search/search.js"); } -const SearchIndexInfo *getSearchIndices() +void SearchIndexInfo::add(const std::string &letter,const Definition *def) { - return g_searchIndexInfo; -} - -//--------------------------------------------------------------------------------------------- - -SearchIndexList::SearchIndexList(uint letter) - : SDict< SearchDefinitionList >(17,FALSE), m_letter(letter) -{ - setAutoDelete(TRUE); -} - -SearchIndexList::~SearchIndexList() -{ -} - -void SearchIndexList::append(const Definition *d) -{ - QCString dispName = d->localName(); - SearchDefinitionList *l = find(dispName); - if (l==0) + //printf("%p: %s->%s (full=%s)\n",this,letter.data(),searchName(def).data(),def->name().data()); + auto it = symbolMap.find(letter); + if (it!=symbolMap.end()) { - if (d->definitionType()==Definition::TypeGroup) - { - dispName = (toGroupDef(d))->groupTitle(); - } - else if (d->definitionType()==Definition::TypePage) - { - dispName = (toPageDef(d))->title(); - } - l=new SearchDefinitionList(searchId(dispName),dispName); - SDict< SearchDefinitionList >::append(dispName,l); + it->second.push_back(def); + } + else + { + symbolMap.insert(std::make_pair(letter,std::vector({def}))); } - l->append(d); -} - -uint SearchIndexList::letter() const -{ - return m_letter; } -int SearchIndexList::compareValues(const SearchDefinitionList *md1, const SearchDefinitionList *md2) const +const std::array &getSearchIndices() { - QCString n1 = md1->getFirst()->localName(); - QCString n2 = md2->getFirst()->localName(); - return qstricmp(n1.data(),n2.data()); + return g_searchIndexInfo; } //--------------------------------------------------------------------------------------------- diff --git a/src/searchindex.h b/src/searchindex.h index 71c1ce1..9039f00 100644 --- a/src/searchindex.h +++ b/src/searchindex.h @@ -1,8 +1,6 @@ /****************************************************************************** * - * - * - * Copyright (C) 1997-2015 by Dimitri van Heesch. + * Copyright (C) 1997-2020 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby @@ -15,25 +13,20 @@ * */ -#ifndef _SEARCHINDEX_H -#define _SEARCHINDEX_H +#ifndef SEARCHINDEX_H +#define SEARCHINDEX_H #include #include #include #include #include +#include +#include -#include -#include -#include -#include "sortdict.h" -#include "definition.h" -#include "util.h" +#include -class FTextStream; class Definition; -class MemberDef; /*! Initialize the search indexer */ void initSearchIndexer(); @@ -116,61 +109,24 @@ class SearchIndexExternal : public SearchIndexIntf //------- client side search index ---------------------- -#define SEARCH_INDEX_ALL 0 -#define SEARCH_INDEX_CLASSES 1 -#define SEARCH_INDEX_INTERFACES 2 -#define SEARCH_INDEX_STRUCTS 3 -#define SEARCH_INDEX_EXCEPTIONS 4 -#define SEARCH_INDEX_NAMESPACES 5 -#define SEARCH_INDEX_FILES 6 -#define SEARCH_INDEX_FUNCTIONS 7 -#define SEARCH_INDEX_VARIABLES 8 -#define SEARCH_INDEX_TYPEDEFS 9 -#define SEARCH_INDEX_SEQUENCES 10 -#define SEARCH_INDEX_DICTIONARIES 11 -#define SEARCH_INDEX_ENUMS 12 -#define SEARCH_INDEX_ENUMVALUES 13 -#define SEARCH_INDEX_PROPERTIES 14 -#define SEARCH_INDEX_EVENTS 15 -#define SEARCH_INDEX_RELATED 16 -#define SEARCH_INDEX_DEFINES 17 -#define SEARCH_INDEX_GROUPS 18 -#define SEARCH_INDEX_PAGES 19 -#define NUM_SEARCH_INDICES 20 - -class SearchDefinitionList : public QList -{ - public: - SearchDefinitionList(const QCString &id,const QCString &name) : m_id(id), m_name(name) {} - QCString id() const { return m_id; } - QCString name() const { return m_name; } - private: - QCString m_id; - QCString m_name; -}; +#define NUM_SEARCH_INDICES 20 -class SearchIndexList : public SDict< SearchDefinitionList > -{ - public: - typedef const Definition ElementType; - SearchIndexList(uint letter); - ~SearchIndexList(); - void append(const Definition *d); - uint letter() const; - private: - int compareValues(const SearchDefinitionList *md1, const SearchDefinitionList *md2) const; - uint m_letter; -}; +QCString searchId(const Definition *d); +QCString searchName(const Definition *d); + +using SearchIndexList = std::vector; +using SearchIndexMap = std::map; struct SearchIndexInfo { - LetterToIndexMap symbolList; + void add(const std::string &letter,const Definition *def); QCString name; - QCString text; + std::function getText; + SearchIndexMap symbolMap; }; void createJavaScriptSearchIndex(); void writeJavaScriptSearchIndex(); -const SearchIndexInfo *getSearchIndices(); +const std::array &getSearchIndices(); #endif diff --git a/templates/html/search.css b/templates/html/search.css index 254b5e7..830a23b 100644 --- a/templates/html/search.css +++ b/templates/html/search.css @@ -204,12 +204,14 @@ a.SRScope:focus, a.SRScope:active { span.SRScope { padding-left: 4px; + font-family: Arial, Verdana, sans-serif; } .SRPage .SRStatus { padding: 2px 5px; font-size: 8pt; font-style: italic; + font-family: Arial, Verdana, sans-serif; } .SRResult { -- cgit v0.12