Doxygen
searchindex.cpp 文件参考
#include <ctype.h>
#include <assert.h>
#include <sstream>
#include "searchindex.h"
#include "config.h"
#include "util.h"
#include "doxygen.h"
#include "language.h"
#include "pagedef.h"
#include "growbuf.h"
#include "message.h"
#include "version.h"
#include "groupdef.h"
#include "filedef.h"
#include "memberdef.h"
#include "filename.h"
#include "membername.h"
#include "resourcemgr.h"
#include "namespacedef.h"
#include "classdef.h"
#include "utf8.h"
#include "classlist.h"
+ searchindex.cpp 的引用(Include)关系图:

浏览源代码.

struct  SearchDocEntry
 
struct  SearchIndexExternal::Private
 

宏定义

#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 SEARCH_INDEX_CONCEPTS   20
 

函数

static int charsToIndex (const QCString &word)
 
static void writeInt (std::ostream &f, size_t index)
 
static void writeString (std::ostream &f, const QCString &s)
 
static QCString definitionToName (const Definition *ctx)
 
QCString searchName (const Definition *d)
 
QCString searchId (const Definition *d)
 
static void addMemberToSearchIndex (const MemberDef *md)
 
void createJavaScriptSearchIndex ()
 
void writeJavaScriptSearchIndex ()
 
const std::array< SearchIndexInfo, NUM_SEARCH_INDICES > & getSearchIndices ()
 
void initSearchIndexer ()
 
void finalizeSearchIndexer ()
 

变量

const size_t numIndexEntries = 256*256
 
static std::array< SearchIndexInfo, NUM_SEARCH_INDICESg_searchIndexInfo
 

宏定义说明

◆ SEARCH_INDEX_ALL

#define SEARCH_INDEX_ALL   0

在文件 searchindex.cpp577 行定义.

◆ SEARCH_INDEX_CLASSES

#define SEARCH_INDEX_CLASSES   1

在文件 searchindex.cpp578 行定义.

◆ SEARCH_INDEX_CONCEPTS

#define SEARCH_INDEX_CONCEPTS   20

在文件 searchindex.cpp597 行定义.

◆ SEARCH_INDEX_DEFINES

#define SEARCH_INDEX_DEFINES   17

在文件 searchindex.cpp594 行定义.

◆ SEARCH_INDEX_DICTIONARIES

#define SEARCH_INDEX_DICTIONARIES   11

在文件 searchindex.cpp588 行定义.

◆ SEARCH_INDEX_ENUMS

#define SEARCH_INDEX_ENUMS   12

在文件 searchindex.cpp589 行定义.

◆ SEARCH_INDEX_ENUMVALUES

#define SEARCH_INDEX_ENUMVALUES   13

在文件 searchindex.cpp590 行定义.

◆ SEARCH_INDEX_EVENTS

#define SEARCH_INDEX_EVENTS   15

在文件 searchindex.cpp592 行定义.

◆ SEARCH_INDEX_EXCEPTIONS

#define SEARCH_INDEX_EXCEPTIONS   4

在文件 searchindex.cpp581 行定义.

◆ SEARCH_INDEX_FILES

#define SEARCH_INDEX_FILES   6

在文件 searchindex.cpp583 行定义.

◆ SEARCH_INDEX_FUNCTIONS

#define SEARCH_INDEX_FUNCTIONS   7

在文件 searchindex.cpp584 行定义.

◆ SEARCH_INDEX_GROUPS

#define SEARCH_INDEX_GROUPS   18

在文件 searchindex.cpp595 行定义.

◆ SEARCH_INDEX_INTERFACES

#define SEARCH_INDEX_INTERFACES   2

在文件 searchindex.cpp579 行定义.

◆ SEARCH_INDEX_NAMESPACES

#define SEARCH_INDEX_NAMESPACES   5

在文件 searchindex.cpp582 行定义.

◆ SEARCH_INDEX_PAGES

#define SEARCH_INDEX_PAGES   19

在文件 searchindex.cpp596 行定义.

◆ SEARCH_INDEX_PROPERTIES

#define SEARCH_INDEX_PROPERTIES   14

在文件 searchindex.cpp591 行定义.

◆ SEARCH_INDEX_RELATED

#define SEARCH_INDEX_RELATED   16

在文件 searchindex.cpp593 行定义.

◆ SEARCH_INDEX_SEQUENCES

#define SEARCH_INDEX_SEQUENCES   10

在文件 searchindex.cpp587 行定义.

◆ SEARCH_INDEX_STRUCTS

#define SEARCH_INDEX_STRUCTS   3

在文件 searchindex.cpp580 行定义.

◆ SEARCH_INDEX_TYPEDEFS

#define SEARCH_INDEX_TYPEDEFS   9

在文件 searchindex.cpp586 行定义.

◆ SEARCH_INDEX_VARIABLES

#define SEARCH_INDEX_VARIABLES   8

在文件 searchindex.cpp585 行定义.

函数说明

◆ addMemberToSearchIndex()

static void addMemberToSearchIndex ( const MemberDef md)
static

在文件 searchindex.cpp631 行定义.

632 {
633  static bool hideFriendCompounds = Config_getBool(HIDE_FRIEND_COMPOUNDS);
634  bool isLinkable = md->isLinkable();
635  const ClassDef *cd=0;
636  const NamespaceDef *nd=0;
637  const FileDef *fd=0;
638  const GroupDef *gd=0;
639  if (isLinkable &&
640  (
641  ((cd=md->getClassDef()) && cd->isLinkable() && cd->templateMaster()==0) ||
642  ((gd=md->getGroupDef()) && gd->isLinkable())
643  )
644  )
645  {
646  std::string n = md->name().str();
647  if (!n.empty())
648  {
649  std::string letter = convertUTF8ToLower(getUTF8CharAt(n,0));
650  bool isFriendToHide = hideFriendCompounds &&
651  (QCString(md->typeString())=="friend class" ||
652  QCString(md->typeString())=="friend struct" ||
653  QCString(md->typeString())=="friend union");
654  if (!(md->isFriend() && isFriendToHide))
655  {
656  g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,md);
657  }
658  if (md->isFunction() || md->isSlot() || md->isSignal())
659  {
661  }
662  else if (md->isVariable())
663  {
665  }
666  else if (md->isSequence())
667  {
669  }
670  else if (md->isDictionary())
671  {
673  }
674  else if (md->isTypedef())
675  {
677  }
678  else if (md->isEnumerate())
679  {
680  g_searchIndexInfo[SEARCH_INDEX_ENUMS].add(letter,md);
681  }
682  else if (md->isEnumValue())
683  {
685  }
686  else if (md->isProperty())
687  {
689  }
690  else if (md->isEvent())
691  {
692  g_searchIndexInfo[SEARCH_INDEX_EVENTS].add(letter,md);
693  }
694  else if (md->isRelated() || md->isForeign() ||
695  (md->isFriend() && !isFriendToHide))
696  {
697  g_searchIndexInfo[SEARCH_INDEX_RELATED].add(letter,md);
698  }
699  }
700  }
701  else if (isLinkable &&
702  (((nd=md->getNamespaceDef()) && nd->isLinkable()) ||
703  ((fd=md->getFileDef()) && fd->isLinkable())
704  )
705  )
706  {
707  std::string n = md->name().str();
708  if (!n.empty())
709  {
710  std::string letter = convertUTF8ToLower(getUTF8CharAt(n,0));
711  g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,md);
712 
713  if (md->isFunction())
714  {
716  }
717  else if (md->isVariable())
718  {
720  }
721  else if (md->isSequence())
722  {
724  }
725  else if (md->isDictionary())
726  {
728  }
729  else if (md->isTypedef())
730  {
732  }
733  else if (md->isEnumerate())
734  {
735  g_searchIndexInfo[SEARCH_INDEX_ENUMS].add(letter,md);
736  }
737  else if (md->isEnumValue())
738  {
740  }
741  else if (md->isDefine())
742  {
743  g_searchIndexInfo[SEARCH_INDEX_DEFINES].add(letter,md);
744  }
745  }
746  }
747 }

引用了 Config_getBool, convertUTF8ToLower(), g_searchIndexInfo, MemberDef::getClassDef(), MemberDef::getFileDef(), MemberDef::getGroupDef(), MemberDef::getNamespaceDef(), getUTF8CharAt(), MemberDef::isDefine(), MemberDef::isDictionary(), MemberDef::isEnumerate(), MemberDef::isEnumValue(), MemberDef::isEvent(), MemberDef::isForeign(), MemberDef::isFriend(), MemberDef::isFunction(), NamespaceDef::isLinkable(), GroupDef::isLinkable(), FileDef::isLinkable(), MemberDef::isLinkable(), ClassDef::isLinkable(), MemberDef::isProperty(), MemberDef::isRelated(), MemberDef::isSequence(), MemberDef::isSignal(), MemberDef::isSlot(), MemberDef::isTypedef(), MemberDef::isVariable(), Definition::name(), SEARCH_INDEX_ALL, SEARCH_INDEX_DEFINES, SEARCH_INDEX_DICTIONARIES, SEARCH_INDEX_ENUMS, SEARCH_INDEX_ENUMVALUES, SEARCH_INDEX_EVENTS, SEARCH_INDEX_FUNCTIONS, SEARCH_INDEX_PROPERTIES, SEARCH_INDEX_RELATED, SEARCH_INDEX_SEQUENCES, SEARCH_INDEX_TYPEDEFS, SEARCH_INDEX_VARIABLES, QCString::str(), ClassDef::templateMaster() , 以及 MemberDef::typeString().

被这些函数引用 addToIndices() , 以及 createJavaScriptSearchIndex().

◆ charsToIndex()

static int charsToIndex ( const QCString word)
static

在文件 searchindex.cpp179 行定义.

180 {
181  if (word.length()<2) return -1;
182 
183  // Fast string hashing algorithm
184  //register ushort h=0;
185  //const char *k = word;
186  //ushort mask=0xfc00;
187  //while ( *k )
188  //{
189  // h = (h&mask)^(h<<6)^(*k++);
190  //}
191  //return h;
192 
193  // Simple hashing that allows for substring searching
194  uint c1=(uchar)word[0];
195  uint c2=(uchar)word[1];
196  return c1*256+c2;
197 }

引用了 QCString::length().

被这些函数引用 SearchIndex::addWord().

◆ createJavaScriptSearchIndex()

void createJavaScriptSearchIndex ( )

在文件 searchindex.cpp751 行定义.

752 {
753  // index classes
754  for (const auto &cd : *Doxygen::classLinkedMap)
755  {
756  std::string letter = convertUTF8ToLower(getUTF8CharAt(cd->localName().str(),0));
757  if (cd->isLinkable())
758  {
759  g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,cd.get());
760  if (Config_getBool(OPTIMIZE_OUTPUT_SLICE))
761  {
762  if (cd->compoundType()==ClassDef::Interface)
763  {
764  g_searchIndexInfo[SEARCH_INDEX_INTERFACES].add(letter,cd.get());
765  }
766  else if (cd->compoundType()==ClassDef::Struct)
767  {
768  g_searchIndexInfo[SEARCH_INDEX_STRUCTS].add(letter,cd.get());
769  }
770  else if (cd->compoundType()==ClassDef::Exception)
771  {
772  g_searchIndexInfo[SEARCH_INDEX_EXCEPTIONS].add(letter,cd.get());
773  }
774  else // cd->compoundType()==ClassDef::Class
775  {
776  g_searchIndexInfo[SEARCH_INDEX_CLASSES].add(letter,cd.get());
777  }
778  }
779  else // non slice optimisation: group all types under classes
780  {
781  g_searchIndexInfo[SEARCH_INDEX_CLASSES].add(letter,cd.get());
782  }
783  }
784  }
785 
786  // index namespaces
787  for (const auto &nd : *Doxygen::namespaceLinkedMap)
788  {
789  std::string letter = convertUTF8ToLower(getUTF8CharAt(nd->name().str(),0));
790  if (nd->isLinkable())
791  {
792  g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,nd.get());
793  g_searchIndexInfo[SEARCH_INDEX_NAMESPACES].add(letter,nd.get());
794  }
795  }
796 
797  // index concepts
798  for (const auto &cd : *Doxygen::conceptLinkedMap)
799  {
800  std::string letter = convertUTF8ToLower(getUTF8CharAt(cd->name().str(),0));
801  if (cd->isLinkable())
802  {
803  g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,cd.get());
804  g_searchIndexInfo[SEARCH_INDEX_CONCEPTS].add(letter,cd.get());
805  }
806  }
807 
808  // index files
809  for (const auto &fn : *Doxygen::inputNameLinkedMap)
810  {
811  for (const auto &fd : *fn)
812  {
813  std::string letter = convertUTF8ToLower(getUTF8CharAt(fd->name().str(),0));
814  if (fd->isLinkable())
815  {
816  g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,fd.get());
817  g_searchIndexInfo[SEARCH_INDEX_FILES].add(letter,fd.get());
818  }
819  }
820  }
821 
822  // index class members
823  {
824  // for each member name
825  for (const auto &mn : *Doxygen::memberNameLinkedMap)
826  {
827  // for each member definition
828  for (const auto &md : *mn)
829  {
830  addMemberToSearchIndex(md.get());
831  }
832  }
833  }
834 
835  // index file/namespace members
836  {
837  // for each member name
838  for (const auto &mn : *Doxygen::functionNameLinkedMap)
839  {
840  // for each member definition
841  for (const auto &md : *mn)
842  {
843  addMemberToSearchIndex(md.get());
844  }
845  }
846  }
847 
848  // index groups
849  for (const auto &gd : *Doxygen::groupLinkedMap)
850  {
851  if (gd->isLinkable())
852  {
853  std::string title = gd->groupTitle().str();
854  if (!title.empty()) // TODO: able searching for all word in the title
855  {
856  std::string letter = convertUTF8ToLower(getUTF8CharAt(title,0));
857  g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,gd.get());
858  g_searchIndexInfo[SEARCH_INDEX_GROUPS].add(letter,gd.get());
859  }
860  }
861  }
862 
863  // index pages
864  for (const auto &pd : *Doxygen::pageLinkedMap)
865  {
866  if (pd->isLinkable())
867  {
868  std::string title = pd->title().str();
869  if (!title.empty())
870  {
871  std::string letter = convertUTF8ToLower(getUTF8CharAt(title,0));
872  g_searchIndexInfo[SEARCH_INDEX_ALL].add(letter,pd.get());
873  g_searchIndexInfo[SEARCH_INDEX_PAGES].add(letter,pd.get());
874  }
875  }
876  }
877  if (Doxygen::mainPage)
878  {
879  std::string title = Doxygen::mainPage->title().str();
880  if (!title.empty())
881  {
882  std::string letter = convertUTF8ToLower(getUTF8CharAt(title,0));
885  }
886  }
887 
888  // sort all lists
889  for (auto &sii : g_searchIndexInfo) // for each index
890  {
891  for (auto &kv : sii.symbolMap) // for each symbol in the index
892  {
893  // sort the symbols (first on "search" name, and then on full name)
894  std::sort(kv.second.begin(),
895  kv.second.end(),
896  [](const Definition *d1,const Definition *d2)
897  {
898  int eq = qstricmp(searchName(d1),searchName(d2)); // search name first
899  return eq==0 ? qstricmp(d1->name(),d2->name())<0 : eq<0; // then full name
900  });
901  }
902  }
903 }

引用了 addMemberToSearchIndex(), Doxygen::classLinkedMap, Doxygen::conceptLinkedMap, Config_getBool, convertUTF8ToLower(), ClassDef::Exception, Doxygen::functionNameLinkedMap, g_searchIndexInfo, getUTF8CharAt(), Doxygen::groupLinkedMap, Doxygen::inputNameLinkedMap, ClassDef::Interface, Doxygen::mainPage, Doxygen::memberNameLinkedMap, Doxygen::namespaceLinkedMap, Doxygen::pageLinkedMap, SEARCH_INDEX_ALL, SEARCH_INDEX_CLASSES, SEARCH_INDEX_CONCEPTS, SEARCH_INDEX_EXCEPTIONS, SEARCH_INDEX_FILES, SEARCH_INDEX_GROUPS, SEARCH_INDEX_INTERFACES, SEARCH_INDEX_NAMESPACES, SEARCH_INDEX_PAGES, SEARCH_INDEX_STRUCTS , 以及 ClassDef::Struct.

被这些函数引用 generateOutput().

◆ definitionToName()

static QCString definitionToName ( const Definition ctx)
static

在文件 searchindex.cpp414 行定义.

415 {
416  if (ctx && ctx->definitionType()==Definition::TypeMember)
417  {
418  const MemberDef *md = toMemberDef(ctx);
419  if (md->isFunction())
420  return "function";
421  else if (md->isSlot())
422  return "slot";
423  else if (md->isSignal())
424  return "signal";
425  else if (md->isVariable())
426  return "variable";
427  else if (md->isTypedef())
428  return "typedef";
429  else if (md->isEnumerate())
430  return "enum";
431  else if (md->isEnumValue())
432  return "enumvalue";
433  else if (md->isProperty())
434  return "property";
435  else if (md->isEvent())
436  return "event";
437  else if (md->isRelated() || md->isForeign())
438  return "related";
439  else if (md->isFriend())
440  return "friend";
441  else if (md->isDefine())
442  return "define";
443  }
444  else if (ctx)
445  {
446  switch(ctx->definitionType())
447  {
449  return (toClassDef(ctx))->compoundTypeString();
451  return "file";
453  return "namespace";
455  return "concept";
457  return "group";
459  return "package";
461  return "page";
462  case Definition::TypeDir:
463  return "dir";
464  default:
465  break;
466  }
467  }
468  return "unknown";
469 }

引用了 Definition::definitionType(), MemberDef::isDefine(), MemberDef::isEnumerate(), MemberDef::isEnumValue(), MemberDef::isEvent(), MemberDef::isForeign(), MemberDef::isFriend(), MemberDef::isFunction(), MemberDef::isProperty(), MemberDef::isRelated(), MemberDef::isSignal(), MemberDef::isSlot(), MemberDef::isTypedef(), MemberDef::isVariable(), toClassDef(), toMemberDef(), Definition::TypeClass, Definition::TypeConcept, Definition::TypeDir, Definition::TypeFile, Definition::TypeGroup, Definition::TypeMember, Definition::TypeNamespace, Definition::TypePackage , 以及 Definition::TypePage.

被这些函数引用 SearchIndexExternal::setCurrentDoc().

◆ finalizeSearchIndexer()

void finalizeSearchIndexer ( )

Cleanup the search indexer

在文件 searchindex.cpp1264 行定义.

1265 {
1266  delete Doxygen::searchIndex;
1267 }

引用了 Doxygen::searchIndex.

被这些函数引用 generateOutput().

◆ getSearchIndices()

const std::array<SearchIndexInfo,NUM_SEARCH_INDICES>& getSearchIndices ( )

在文件 searchindex.cpp1235 行定义.

1236 {
1237  return g_searchIndexInfo;
1238 }

引用了 g_searchIndexInfo.

被这些函数引用 SearchIndicesContext::Private::Private().

◆ initSearchIndexer()

void initSearchIndexer ( )

Initialize the search indexer

在文件 searchindex.cpp1242 行定义.

1243 {
1244  static bool searchEngine = Config_getBool(SEARCHENGINE);
1245  static bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
1246  static bool externalSearch = Config_getBool(EXTERNAL_SEARCH);
1247  if (searchEngine && serverBasedSearch)
1248  {
1249  if (externalSearch) // external tools produce search index and engine
1250  {
1252  }
1253  else // doxygen produces search index and engine
1254  {
1256  }
1257  }
1258  else // no search engine or pure javascript based search function
1259  {
1261  }
1262 }

引用了 Config_getBool , 以及 Doxygen::searchIndex.

被这些函数引用 generateOutput().

◆ searchId()

QCString searchId ( const Definition d)

在文件 searchindex.cpp553 行定义.

554 {
555  std::string s = searchName(d).str();
556  TextStream t;
557  for (size_t i=0;i<s.length();i++)
558  {
559  if (isIdJS(s[i]))
560  {
561  t << s[i];
562  }
563  else // escape non-identifier characters
564  {
565  static const char *hex = "0123456789ABCDEF";
566  unsigned char uc = static_cast<unsigned char>(s[i]);
567  t << '_';
568  t << hex[uc>>4];
569  t << hex[uc&0xF];
570  }
571  }
572 
573  return convertUTF8ToLower(t.str());
574 }

引用了 convertUTF8ToLower(), hex, isIdJS(), searchName(), TextStream::str() , 以及 QCString::str().

被这些函数引用 SymbolGroupContext::Private::id() , 以及 writeJavaScriptSearchIndex().

◆ searchName()

QCString searchName ( const Definition d)

在文件 searchindex.cpp546 行定义.

547 {
548  return d->definitionType()==Definition::TypeGroup ? QCString(toGroupDef(d)->groupTitle()) :
549  d->definitionType()==Definition::TypePage ? toPageDef(d)->title() :
550  d->localName();
551 }

引用了 Definition::definitionType(), Definition::localName(), PageDef::title(), toGroupDef(), toPageDef(), Definition::TypeGroup , 以及 Definition::TypePage.

被这些函数引用 SymbolGroupContext::Private::name(), SymbolGroupListContext::Private::Private(), searchId() , 以及 writeJavaScriptSearchIndex().

◆ writeInt()

static void writeInt ( std::ostream &  f,
size_t  index 
)
static

在文件 searchindex.cpp246 行定义.

247 {
248  f.put(static_cast<int>(index>>24));
249  f.put(static_cast<int>((index>>16)&0xff));
250  f.put(static_cast<int>((index>>8)&0xff));
251  f.put(static_cast<int>(index&0xff));
252 }

被这些函数引用 SearchIndex::write().

◆ writeJavaScriptSearchIndex()

void writeJavaScriptSearchIndex ( )

在文件 searchindex.cpp905 行定义.

906 {
907  // write index files
908  QCString searchDirName = Config_getString(HTML_OUTPUT)+"/search";
909 
910  for (auto &sii : g_searchIndexInfo)
911  {
912  int p=0;
913  for (const auto &kv : sii.symbolMap)
914  {
915  int cnt = 0;
916  QCString baseName;
917  baseName.sprintf("%s_%x",sii.name.data(),p);
918 
919  QCString fileName = searchDirName + "/"+baseName+Doxygen::htmlFileExtension;
920  QCString dataFileName = searchDirName + "/"+baseName+".js";
921 
922  std::ofstream t(fileName.str(), std::ofstream::out | std::ofstream::binary);
923  std::ofstream ti(dataFileName.str(), std::ofstream::out | std::ofstream::binary);
924  if (t.is_open() && ti.is_open())
925  {
926  {
927  t << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\""
928  " \"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
929  t << "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
930  t << "<head><title></title>\n";
931  t << "<meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>\n";
932  t << "<meta name=\"generator\" content=\"Doxygen " << getDoxygenVersion() << "\"/>\n";
933  t << "<link rel=\"stylesheet\" type=\"text/css\" href=\"search.css\"/>\n";
934  t << "<script type=\"text/javascript\" src=\"" << baseName << ".js\"></script>\n";
935  t << "<script type=\"text/javascript\" src=\"search.js\"></script>\n";
936  t << "</head>\n";
937  t << "<body class=\"SRPage\">\n";
938  t << "<div id=\"SRIndex\">\n";
939  t << "<div class=\"SRStatus\" id=\"Loading\">" << theTranslator->trLoading() << "</div>\n";
940  t << "<div id=\"SRResults\"></div>\n"; // here the results will be inserted
941  t << "<script type=\"text/javascript\">\n";
942  t << "/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */\n";
943  t << "createResults();\n"; // this function will insert the results
944  t << "/* @license-end */\n";
945  t << "</script>\n";
946  t << "<div class=\"SRStatus\" id=\"Searching\">"
947  << theTranslator->trSearching() << "</div>\n";
948  t << "<div class=\"SRStatus\" id=\"NoMatches\">"
949  << theTranslator->trNoMatches() << "</div>\n";
950 
951  t << "<script type=\"text/javascript\">\n";
952  t << "/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */\n";
953  t << "document.getElementById(\"Loading\").style.display=\"none\";\n";
954  t << "document.getElementById(\"NoMatches\").style.display=\"none\";\n";
955  t << "var searchResults = new SearchResults(\"searchResults\");\n";
956  t << "searchResults.Search();\n";
957  t << "window.addEventListener(\"message\", function(event) {\n";
958  t << " if (event.data == \"take_focus\") {\n";
959  t << " var elem = searchResults.NavNext(0);\n";
960  t << " if (elem) elem.focus();\n";
961  t << " }\n";
962  t << "});\n";
963  t << "/* @license-end */\n";
964  t << "</script>\n";
965  t << "</div>\n"; // SRIndex
966  t << "</body>\n";
967  t << "</html>\n";
968  }
969 
970  ti << "var searchData=\n";
971  // format
972  // searchData[] = array of items
973  // searchData[x][0] = id
974  // searchData[x][1] = [ name + child1 + child2 + .. ]
975  // searchData[x][1][0] = name as shown
976  // searchData[x][1][y+1] = info for child y
977  // searchData[x][1][y+1][0] = url
978  // searchData[x][1][y+1][1] = 1 => target="_parent"
979  // searchData[x][1][y+1][2] = scope
980 
981  ti << "[\n";
982  bool firstEntry=TRUE;
983 
984  int childCount=0;
985  QCString lastName;
986  const Definition *prevScope = 0;
987  for (auto it = kv.second.begin(); it!=kv.second.end();)
988  {
989  const Definition *d = *it;
990  QCString sname = searchName(d);
991  QCString id = searchId(d);
992 
993  if (sname!=lastName) // this item has a different search word
994  {
995  if (!firstEntry)
996  {
997  ti << "]]]";
998  ti << ",\n";
999  }
1000  firstEntry=FALSE;
1001 
1002  ti << " ['" << id << "_" << cnt++ << "',['" << convertToXML(sname) << "',[";
1003  childCount=0;
1004  prevScope=0;
1005  }
1006 
1007  ++it;
1008  const Definition *scope = d->getOuterScope();
1009  const Definition *next = it!=kv.second.end() ? *it : 0;
1010  const Definition *nextScope = 0;
1011  const MemberDef *md = toMemberDef(d);
1012  if (next) nextScope = next->getOuterScope();
1013  QCString anchor = d->anchor();
1014 
1015  if (childCount>0)
1016  {
1017  ti << "],[";
1018  }
1019  ti << "'" << externalRef("../",d->getReference(),TRUE)
1021  if (!anchor.isEmpty())
1022  {
1023  ti << "#" << anchor;
1024  }
1025  ti << "',";
1026 
1027  static bool extLinksInWindow = Config_getBool(EXT_LINKS_IN_WINDOW);
1028  if (!extLinksInWindow || d->getReference().isEmpty())
1029  {
1030  ti << "1,";
1031  }
1032  else
1033  {
1034  ti << "0,";
1035  }
1036 
1037  if (lastName!=sname && (next==0 || searchName(next)!=sname)) // unique name
1038  {
1040  {
1041  ti << "'" << convertToXML(d->getOuterScope()->name()) << "'";
1042  }
1043  else if (md)
1044  {
1045  const FileDef *fd = md->getBodyDef();
1046  if (fd==0) fd = md->getFileDef();
1047  if (fd)
1048  {
1049  ti << "'" << convertToXML(fd->localName()) << "'";
1050  }
1051  }
1052  else
1053  {
1054  ti << "''";
1055  }
1056  }
1057  else // multiple entries with the same name
1058  {
1059  bool found=FALSE;
1060  bool overloadedFunction = ((prevScope!=0 && scope==prevScope) ||
1061  (scope && scope==nextScope)) && md && (md->isFunction() || md->isSlot());
1062  QCString prefix;
1063  if (md) prefix=convertToXML(md->localName());
1064  if (overloadedFunction) // overloaded member function
1065  {
1066  prefix+=convertToXML(md->argsString());
1067  // show argument list to disambiguate overloaded functions
1068  }
1069  else if (md) // unique member function
1070  {
1071  prefix+="()"; // only to show it is a function
1072  }
1073  QCString name;
1075  {
1076  name = convertToXML((toClassDef(d))->displayName());
1077  found = TRUE;
1078  }
1080  {
1081  name = convertToXML((toNamespaceDef(d))->displayName());
1082  found = TRUE;
1083  }
1084  else if (scope==0 || scope==Doxygen::globalScope) // in global scope
1085  {
1086  if (md)
1087  {
1088  const FileDef *fd = md->getBodyDef();
1089  if (fd==0) fd = md->resolveAlias()->getFileDef();
1090  if (fd)
1091  {
1092  if (!prefix.isEmpty()) prefix+=":&#160;";
1093  name = prefix + convertToXML(fd->localName());
1094  found = TRUE;
1095  }
1096  }
1097  }
1098  else if (md && (md->resolveAlias()->getClassDef() || md->resolveAlias()->getNamespaceDef()))
1099  // member in class or namespace scope
1100  {
1101  SrcLangExt lang = md->getLanguage();
1102  name = convertToXML(d->getOuterScope()->qualifiedName())
1103  + getLanguageSpecificSeparator(lang) + prefix;
1104  found = TRUE;
1105  }
1106  else if (scope) // some thing else? -> show scope
1107  {
1108  name = prefix + convertToXML(scope->name());
1109  found = TRUE;
1110  }
1111  if (!found) // fallback
1112  {
1113  name = prefix + "("+theTranslator->trGlobalNamespace()+")";
1114  }
1115 
1116  ti << "'" << name << "'";
1117 
1118  prevScope = scope;
1119  childCount++;
1120  }
1121  lastName = sname;
1122  }
1123  if (!firstEntry)
1124  {
1125  ti << "]]]\n";
1126  }
1127  ti << "];\n";
1128  }
1129  else
1130  {
1131  err("Failed to open file '%s' for writing...\n",qPrint(fileName));
1132  }
1133  p++;
1134  }
1135  }
1136 
1137  {
1138  std::ofstream t(searchDirName.str()+"/searchdata.js",
1139  std::ofstream::out | std::ofstream::binary);
1140  if (t.is_open())
1141  {
1142  t << "var indexSectionsWithContent =\n";
1143  t << "{\n";
1144  int j=0;
1145  for (const auto &sii : g_searchIndexInfo)
1146  {
1147  if (!sii.symbolMap.empty())
1148  {
1149  if (j>0) t << ",\n";
1150  t << " " << j << ": \"";
1151 
1152  for (const auto &kv : sii.symbolMap)
1153  {
1154  if ( kv.first == "\"" ) t << "\\";
1155  t << kv.first;
1156  }
1157  t << "\"";
1158  j++;
1159  }
1160  }
1161  if (j>0) t << "\n";
1162  t << "};\n\n";
1163  t << "var indexSectionNames =\n";
1164  t << "{\n";
1165  j=0;
1166  for (const auto &sii : g_searchIndexInfo)
1167  {
1168  if (!sii.symbolMap.empty())
1169  {
1170  if (j>0) t << ",\n";
1171  t << " " << j << ": \"" << sii.name << "\"";
1172  j++;
1173  }
1174  }
1175  if (j>0) t << "\n";
1176  t << "};\n\n";
1177  t << "var indexSectionLabels =\n";
1178  t << "{\n";
1179  j=0;
1180  for (const auto &sii : g_searchIndexInfo)
1181  {
1182  if (!sii.symbolMap.empty())
1183  {
1184  if (j>0) t << ",\n";
1185  t << " " << j << ": \"" << convertToXML(sii.getText()) << "\"";
1186  j++;
1187  }
1188  }
1189  if (j>0) t << "\n";
1190  t << "};\n\n";
1191  }
1192  ResourceMgr::instance().copyResource("search.js",searchDirName);
1193  }
1194 
1195  {
1196  QCString noMatchesFileName =searchDirName+"/nomatches"+Doxygen::htmlFileExtension;
1197  std::ofstream t(noMatchesFileName.str(), std::ofstream::out | std::ofstream::binary);
1198  if (t.is_open())
1199  {
1200  t << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" "
1201  "\"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
1202  t << "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
1203  t << "<head><title></title>\n";
1204  t << "<meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>\n";
1205  t << "<link rel=\"stylesheet\" type=\"text/css\" href=\"search.css\"/>\n";
1206  t << "<script type=\"text/javascript\" src=\"search.js\"></script>\n";
1207  t << "</head>\n";
1208  t << "<body class=\"SRPage\">\n";
1209  t << "<div id=\"SRIndex\">\n";
1210  t << "<div class=\"SRStatus\" id=\"NoMatches\">"
1211  << theTranslator->trNoMatches() << "</div>\n";
1212  t << "</div>\n";
1213  t << "</body>\n";
1214  t << "</html>\n";
1215  }
1216  }
1217 
1218  Doxygen::indexList->addStyleSheetFile("search/search.js");
1219 }

引用了 addHtmlExtensionIfMissing(), IndexList::addStyleSheetFile(), Definition::anchor(), MemberDef::argsString(), Config_getBool, Config_getString, convertToXML(), ResourceMgr::copyResource(), Definition::definitionType(), err(), externalRef(), FALSE, g_searchIndexInfo, Definition::getBodyDef(), MemberDef::getClassDef(), MemberDef::getFileDef(), Definition::getLanguage(), getLanguageSpecificSeparator(), MemberDef::getNamespaceDef(), Definition::getOuterScope(), Definition::getOutputFileBase(), Definition::getReference(), Doxygen::globalScope, Doxygen::htmlFileExtension, Doxygen::indexList, ResourceMgr::instance(), QCString::isEmpty(), MemberDef::isFunction(), MemberDef::isSlot(), Definition::localName(), Definition::name(), qPrint(), Definition::qualifiedName(), MemberDef::resolveAlias(), searchId(), searchName(), QCString::sprintf(), QCString::str(), theTranslator, toClassDef(), toMemberDef(), toNamespaceDef(), Translator::trGlobalNamespace(), Translator::trLoading(), Translator::trNoMatches(), Translator::trSearching(), TRUE, Definition::TypeClass , 以及 Definition::TypeNamespace.

被这些函数引用 generateOutput().

◆ writeString()

static void writeString ( std::ostream &  f,
const QCString s 
)
static

在文件 searchindex.cpp254 行定义.

255 {
256  uint l = s.length();
257  for (uint i=0;i<l;i++) f.put(s[i]);
258  f.put(0);
259 }

引用了 QCString::length().

被这些函数引用 SearchIndex::write().

变量说明

◆ g_searchIndexInfo

std::array<SearchIndexInfo,NUM_SEARCH_INDICES> g_searchIndexInfo
static

◆ numIndexEntries

const size_t numIndexEntries = 256*256

在文件 searchindex.cpp56 行定义.

被这些函数引用 SearchIndex::SearchIndex() , 以及 SearchIndex::write().

SEARCH_INDEX_EVENTS
#define SEARCH_INDEX_EVENTS
Definition: searchindex.cpp:592
ResourceMgr::copyResource
bool copyResource(const QCString &name, const QCString &targetDir) const
Copies a registered resource to a given target directory
Definition: resourcemgr.cpp:180
MemberDef::isTypedef
virtual bool isTypedef() const =0
ResourceMgr::instance
static ResourceMgr & instance()
Returns the one and only instance of this class
Definition: resourcemgr.cpp:32
SEARCH_INDEX_ALL
#define SEARCH_INDEX_ALL
Definition: searchindex.cpp:577
SEARCH_INDEX_RELATED
#define SEARCH_INDEX_RELATED
Definition: searchindex.cpp:593
toGroupDef
GroupDef * toGroupDef(Definition *d)
Definition: groupdef.cpp:1766
Doxygen::mainPage
static std::unique_ptr< PageDef > mainPage
Definition: doxygen.h:83
MemberDef::argsString
virtual QCString argsString() const =0
Definition::TypeMember
@ TypeMember
Definition: definition.h:90
convertUTF8ToLower
std::string convertUTF8ToLower(const std::string &input)
Converts the input string into a lower case version, also taking into account non-ASCII characters th...
Definition: utf8.cpp:187
Definition
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
MemberDef::isSignal
virtual bool isSignal() const =0
SEARCH_INDEX_FUNCTIONS
#define SEARCH_INDEX_FUNCTIONS
Definition: searchindex.cpp:584
NamespaceDef
An abstract interface of a namespace symbol.
Definition: namespacedef.h:54
SEARCH_INDEX_NAMESPACES
#define SEARCH_INDEX_NAMESPACES
Definition: searchindex.cpp:582
QCString::length
uint length() const
Returns the length of the string, not counting the 0-terminator.
Definition: qcstring.h:147
SEARCH_INDEX_CLASSES
#define SEARCH_INDEX_CLASSES
Definition: searchindex.cpp:578
Doxygen::conceptLinkedMap
static ConceptLinkedMap * conceptLinkedMap
Definition: doxygen.h:80
SEARCH_INDEX_ENUMS
#define SEARCH_INDEX_ENUMS
Definition: searchindex.cpp:589
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
Doxygen::pageLinkedMap
static PageLinkedMap * pageLinkedMap
Definition: doxygen.h:82
Doxygen::indexList
static IndexList * indexList
Definition: doxygen.h:114
Definition::TypePage
@ TypePage
Definition: definition.h:93
SEARCH_INDEX_INTERFACES
#define SEARCH_INDEX_INTERFACES
Definition: searchindex.cpp:579
IndexList::addStyleSheetFile
void addStyleSheetFile(const QCString &name)
Definition: index.h:107
Translator::trGlobalNamespace
virtual QCString trGlobalNamespace()=0
ClassDef::Interface
@ Interface
Definition: classdef.h:110
toMemberDef
MemberDef * toMemberDef(Definition *d)
Definition: memberdef.cpp:6088
SrcLangExt
SrcLangExt
Language as given by extension
Definition: types.h:41
Doxygen::globalScope
static NamespaceDefMutable * globalScope
Definition: doxygen.h:102
SEARCH_INDEX_DICTIONARIES
#define SEARCH_INDEX_DICTIONARIES
Definition: searchindex.cpp:588
QCString::str
std::string str() const
Definition: qcstring.h:442
SEARCH_INDEX_TYPEDEFS
#define SEARCH_INDEX_TYPEDEFS
Definition: searchindex.cpp:586
Definition::TypeGroup
@ TypeGroup
Definition: definition.h:91
SEARCH_INDEX_GROUPS
#define SEARCH_INDEX_GROUPS
Definition: searchindex.cpp:595
err
void err(const char *fmt,...)
Definition: message.cpp:203
FileDef::isLinkable
virtual bool isLinkable() const =0
TextStream
Text streaming class that buffers data.
Definition: textstream.h:33
Translator::trNoMatches
virtual QCString trNoMatches()=0
MemberDef::isDictionary
virtual bool isDictionary() const =0
MemberDef::isProperty
virtual bool isProperty() const =0
SearchIndexExternal
Definition: searchindex.h:98
SEARCH_INDEX_PAGES
#define SEARCH_INDEX_PAGES
Definition: searchindex.cpp:596
Definition::getLanguage
virtual SrcLangExt getLanguage() const =0
Returns the programming language this definition was written in.
MemberDef::isSequence
virtual bool isSequence() const =0
toPageDef
PageDef * toPageDef(Definition *d)
Definition: pagedef.cpp:408
MemberDef::isLinkable
virtual bool isLinkable() const =0
ClassDef::templateMaster
virtual const ClassDef * templateMaster() const =0
Returns the template master of which this class is an instance.
GroupDef
A model of a group of symbols.
Definition: groupdef.h:49
Doxygen::inputNameLinkedMap
static FileNameLinkedMap * inputNameLinkedMap
Definition: doxygen.h:88
SEARCH_INDEX_DEFINES
#define SEARCH_INDEX_DEFINES
Definition: searchindex.cpp:594
uint
unsigned uint
Definition: qcstring.h:40
Definition::getBodyDef
virtual const FileDef * getBodyDef() const =0
SEARCH_INDEX_CONCEPTS
#define SEARCH_INDEX_CONCEPTS
Definition: searchindex.cpp:597
Definition::qualifiedName
virtual QCString qualifiedName() const =0
addHtmlExtensionIfMissing
QCString addHtmlExtensionIfMissing(const QCString &fName)
Definition: util.cpp:5275
MemberDef
A model of a class/file/namespace member symbol.
Definition: memberdef.h:45
Definition::TypeNamespace
@ TypeNamespace
Definition: definition.h:89
ClassDef
A abstract class representing of a compound symbol.
Definition: classdef.h:103
Definition::TypePackage
@ TypePackage
Definition: definition.h:92
MemberDef::isFriend
virtual bool isFriend() const =0
Doxygen::functionNameLinkedMap
static MemberNameLinkedMap * functionNameLinkedMap
Definition: doxygen.h:94
uchar
unsigned char uchar
Definition: qcstring.h:38
isIdJS
bool isIdJS(int c)
Definition: util.h:176
MemberDef::isDefine
virtual bool isDefine() const =0
MemberDef::isVariable
virtual bool isVariable() const =0
Definition::TypeFile
@ TypeFile
Definition: definition.h:88
MemberDef::isSlot
virtual bool isSlot() const =0
searchName
QCString searchName(const Definition *d)
Definition: searchindex.cpp:546
theTranslator
Translator * theTranslator
Definition: language.cpp:156
Definition::name
virtual QCString name() const =0
Doxygen::groupLinkedMap
static GroupLinkedMap * groupLinkedMap
Definition: doxygen.h:96
Definition::TypeConcept
@ TypeConcept
Definition: definition.h:95
MemberDef::resolveAlias
virtual MemberDef * resolveAlias()=0
MemberDef::getClassDef
virtual const ClassDef * getClassDef() const =0
getUTF8CharAt
std::string getUTF8CharAt(const std::string &input, size_t pos)
Returns the UTF8 character found at byte position pos in the input string.
Definition: utf8.cpp:127
getLanguageSpecificSeparator
QCString getLanguageSpecificSeparator(SrcLangExt lang, bool classScope)
Returns the scope separator to use given the programming language lang
Definition: util.cpp:6545
MemberDef::isFunction
virtual bool isFunction() const =0
SEARCH_INDEX_STRUCTS
#define SEARCH_INDEX_STRUCTS
Definition: searchindex.cpp:580
TRUE
#define TRUE
Definition: qcstring.h:36
Definition::TypeDir
@ TypeDir
Definition: definition.h:94
Definition::getOutputFileBase
virtual QCString getOutputFileBase() const =0
MemberDef::getNamespaceDef
virtual const NamespaceDef * getNamespaceDef() const =0
Translator::trSearching
virtual QCString trSearching()=0
SearchIndex
Definition: searchindex.h:81
ClassDef::Struct
@ Struct
Definition: classdef.h:108
TextStream::str
std::string str() const
Return the contents of the buffer as a std::string object
Definition: textstream.h:208
toClassDef
ClassDef * toClassDef(Definition *d)
Definition: classdef.cpp:4907
searchId
QCString searchId(const Definition *d)
Definition: searchindex.cpp:553
Definition::TypeClass
@ TypeClass
Definition: definition.h:87
Definition::definitionType
virtual DefType definitionType() const =0
MemberDef::isForeign
virtual bool isForeign() const =0
g_searchIndexInfo
static std::array< SearchIndexInfo, NUM_SEARCH_INDICES > g_searchIndexInfo
Definition: searchindex.cpp:599
GroupDef::isLinkable
virtual bool isLinkable() const =0
Definition::getReference
virtual QCString getReference() const =0
SEARCH_INDEX_ENUMVALUES
#define SEARCH_INDEX_ENUMVALUES
Definition: searchindex.cpp:590
Doxygen::searchIndex
static SearchIndexIntf * searchIndex
Definition: doxygen.h:105
Doxygen::memberNameLinkedMap
static MemberNameLinkedMap * memberNameLinkedMap
Definition: doxygen.h:93
NamespaceDef::isLinkable
virtual bool isLinkable() const =0
Definition::anchor
virtual QCString anchor() const =0
SEARCH_INDEX_FILES
#define SEARCH_INDEX_FILES
Definition: searchindex.cpp:583
Config_getBool
#define Config_getBool(name)
Definition: config.h:33
toNamespaceDef
NamespaceDef * toNamespaceDef(Definition *d)
Definition: namespacedef.cpp:1541
Doxygen::htmlFileExtension
static QCString htmlFileExtension
Definition: doxygen.h:103
MemberDef::isEnumerate
virtual bool isEnumerate() const =0
hex
static const char * hex
Definition: htmldocvisitor.cpp:65
Definition::getOuterScope
virtual Definition * getOuterScope() const =0
MemberDef::isEnumValue
virtual bool isEnumValue() const =0
SEARCH_INDEX_SEQUENCES
#define SEARCH_INDEX_SEQUENCES
Definition: searchindex.cpp:587
SEARCH_INDEX_EXCEPTIONS
#define SEARCH_INDEX_EXCEPTIONS
Definition: searchindex.cpp:581
SEARCH_INDEX_PROPERTIES
#define SEARCH_INDEX_PROPERTIES
Definition: searchindex.cpp:591
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
MemberDef::getFileDef
virtual const FileDef * getFileDef() const =0
Config_getString
#define Config_getString(name)
Definition: config.h:32
Doxygen::namespaceLinkedMap
static NamespaceLinkedMap * namespaceLinkedMap
Definition: doxygen.h:97
convertToXML
QCString convertToXML(const QCString &s, bool keepEntities)
Definition: util.cpp:3948
FileDef
A model of a file symbol.
Definition: filedef.h:73
externalRef
QCString externalRef(const QCString &relPath, const QCString &ref, bool href)
Definition: util.cpp:6334
ClassDef::Exception
@ Exception
Definition: classdef.h:113
Doxygen::classLinkedMap
static ClassLinkedMap * classLinkedMap
Definition: doxygen.h:78
MemberDef::isRelated
virtual bool isRelated() const =0
MemberDef::typeString
virtual QCString typeString() const =0
Definition::localName
virtual QCString localName() const =0
ClassDef::isLinkable
virtual bool isLinkable() const =0
return TRUE iff a link to this class is possible (either within this project, or as a cross-reference...
SEARCH_INDEX_VARIABLES
#define SEARCH_INDEX_VARIABLES
Definition: searchindex.cpp:585
addMemberToSearchIndex
static void addMemberToSearchIndex(const MemberDef *md)
Definition: searchindex.cpp:631
MemberDef::isEvent
virtual bool isEvent() const =0
QCString::sprintf
QCString & sprintf(const char *format,...)
Definition: qcstring.cpp:24
Translator::trLoading
virtual QCString trLoading()=0
MemberDef::getGroupDef
virtual const GroupDef * getGroupDef() const =0
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108