Doxygen
SearchIndexExternal类 参考

#include <searchindex.h>

+ 类 SearchIndexExternal 继承关系图:
+ SearchIndexExternal 的协作图:

struct  Private
 

Public 成员函数

 SearchIndexExternal ()
 
void setCurrentDoc (const Definition *ctx, const QCString &anchor, bool isSourceFile)
 
void addWord (const QCString &word, bool hiPriority)
 
void write (const QCString &file)
 
- Public 成员函数 继承自 SearchIndexIntf
 SearchIndexIntf (Kind k)
 
virtual ~SearchIndexIntf ()
 
Kind kind () const
 

Private 属性

std::unique_ptr< Privatep
 

额外继承的成员函数

- Public 类型 继承自 SearchIndexIntf
enum  Kind { Internal, External }
 

详细描述

在文件 searchindex.h98 行定义.

构造及析构函数说明

◆ SearchIndexExternal()

SearchIndexExternal::SearchIndexExternal ( )

在文件 searchindex.cpp410 行定义.

410  : SearchIndexIntf(External), p(std::make_unique<Private>())
411 {
412 }

成员函数说明

◆ addWord()

void SearchIndexExternal::addWord ( const QCString word,
bool  hiPriority 
)
virtual

实现了 SearchIndexIntf.

在文件 searchindex.cpp497 行定义.

498 {
499  if (word.isEmpty() || !isId(word[0]) || p->current==0) return;
500  GrowBuf *pText = hiPriority ? &p->current->importantText : &p->current->normalText;
501  if (pText->getPos()>0) pText->addChar(' ');
502  pText->addStr(word);
503  //printf("addWord %s\n",word);
504 }

引用了 GrowBuf::addChar(), GrowBuf::addStr(), GrowBuf::getPos(), QCString::isEmpty(), isId() , 以及 p.

◆ setCurrentDoc()

void SearchIndexExternal::setCurrentDoc ( const Definition ctx,
const QCString anchor,
bool  isSourceFile 
)
virtual

实现了 SearchIndexIntf.

在文件 searchindex.cpp471 行定义.

472 {
473  static QCString extId = stripPath(Config_getString(EXTERNAL_SEARCH_ID));
474  QCString baseName = isSourceFile ? (toFileDef(ctx))->getSourceFileBase() : ctx->getOutputFileBase();
475  QCString url = addHtmlExtensionIfMissing(baseName);
476  if (!anchor.isEmpty()) url+=QCString("#")+anchor;
477  QCString key = extId+";"+url;
478 
479  auto it = p->docEntries.find(key.str());
480  if (it == p->docEntries.end())
481  {
482  SearchDocEntry e;
483  e.type = isSourceFile ? QCString("source") : definitionToName(ctx);
484  e.name = ctx->qualifiedName();
486  {
487  e.args = (toMemberDef(ctx))->argsString();
488  }
489  e.extId = extId;
490  e.url = url;
491  it = p->docEntries.insert({key.str(),e}).first;
492  //printf("searchIndexExt %s : %s\n",qPrint(e->name),qPrint(e->url));
493  }
494  p->current = &it->second;
495 }

引用了 addHtmlExtensionIfMissing(), SearchDocEntry::args, Config_getString, definitionToName(), Definition::definitionType(), SearchDocEntry::extId, Definition::getOutputFileBase(), QCString::isEmpty(), SearchDocEntry::name, p, Definition::qualifiedName(), QCString::str(), stripPath(), toFileDef(), toMemberDef(), SearchDocEntry::type, Definition::TypeMember , 以及 SearchDocEntry::url.

◆ write()

void SearchIndexExternal::write ( const QCString file)
virtual

实现了 SearchIndexIntf.

在文件 searchindex.cpp506 行定义.

507 {
508  std::ofstream t(fileName.str(),std::ofstream::out | std::ofstream::binary);
509  if (t.is_open())
510  {
511  t << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
512  t << "<add>\n";
513  for (auto &kv : p->docEntries)
514  {
515  SearchDocEntry &doc = kv.second;
516  doc.normalText.addChar(0); // make sure buffer ends with a 0 terminator
517  doc.importantText.addChar(0); // make sure buffer ends with a 0 terminator
518  t << " <doc>\n";
519  t << " <field name=\"type\">" << doc.type << "</field>\n";
520  t << " <field name=\"name\">" << convertToXML(doc.name) << "</field>\n";
521  if (!doc.args.isEmpty())
522  {
523  t << " <field name=\"args\">" << convertToXML(doc.args) << "</field>\n";
524  }
525  if (!doc.extId.isEmpty())
526  {
527  t << " <field name=\"tag\">" << convertToXML(doc.extId) << "</field>\n";
528  }
529  t << " <field name=\"url\">" << convertToXML(doc.url) << "</field>\n";
530  t << " <field name=\"keywords\">" << convertToXML(doc.importantText.get()) << "</field>\n";
531  t << " <field name=\"text\">" << convertToXML(doc.normalText.get()) << "</field>\n";
532  t << " </doc>\n";
533  }
534  t << "</add>\n";
535  }
536  else
537  {
538  err("Failed to open file %s for writing!\n",qPrint(fileName));
539  }
540 }

引用了 GrowBuf::addChar(), SearchDocEntry::args, convertToXML(), err(), SearchDocEntry::extId, GrowBuf::get(), SearchDocEntry::importantText, QCString::isEmpty(), SearchDocEntry::name, SearchDocEntry::normalText, p, qPrint(), QCString::str(), SearchDocEntry::type , 以及 SearchDocEntry::url.

类成员变量说明

◆ p

std::unique_ptr<Private> SearchIndexExternal::p
private

在文件 searchindex.h107 行定义.

被这些函数引用 addWord(), setCurrentDoc() , 以及 write().


该类的文档由以下文件生成:
SearchDocEntry::url
QCString url
Definition: searchindex.cpp:399
SearchDocEntry::normalText
GrowBuf normalText
Definition: searchindex.cpp:401
SearchDocEntry::args
QCString args
Definition: searchindex.cpp:397
Definition::TypeMember
@ TypeMember
Definition: definition.h:90
SearchIndexExternal::p
std::unique_ptr< Private > p
Definition: searchindex.h:107
GrowBuf::get
char * get()
Definition: growbuf.h:94
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
toMemberDef
MemberDef * toMemberDef(Definition *d)
Definition: memberdef.cpp:6088
QCString::str
std::string str() const
Definition: qcstring.h:442
err
void err(const char *fmt,...)
Definition: message.cpp:203
GrowBuf::addStr
void addStr(const QCString &s)
Definition: growbuf.h:57
GrowBuf::addChar
void addChar(char c)
Definition: growbuf.h:54
GrowBuf
Class representing a string buffer optimised for growing.
Definition: growbuf.h:12
SearchDocEntry::name
QCString name
Definition: searchindex.cpp:396
Definition::qualifiedName
virtual QCString qualifiedName() const =0
SearchDocEntry::importantText
GrowBuf importantText
Definition: searchindex.cpp:400
addHtmlExtensionIfMissing
QCString addHtmlExtensionIfMissing(const QCString &fName)
Definition: util.cpp:5275
isId
bool isId(int c)
Definition: util.h:172
GrowBuf::getPos
uint getPos() const
Definition: growbuf.h:96
stripPath
QCString stripPath(const QCString &s)
Definition: util.cpp:5318
SearchDocEntry::type
QCString type
Definition: searchindex.cpp:395
Definition::definitionType
virtual DefType definitionType() const =0
SearchDocEntry
Definition: searchindex.cpp:393
definitionToName
static QCString definitionToName(const Definition *ctx)
Definition: searchindex.cpp:414
SearchIndexIntf::External
@ External
Definition: searchindex.h:70
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
Config_getString
#define Config_getString(name)
Definition: config.h:32
SearchIndexIntf::SearchIndexIntf
SearchIndexIntf(Kind k)
Definition: searchindex.h:71
convertToXML
QCString convertToXML(const QCString &s, bool keepEntities)
Definition: util.cpp:3948
toFileDef
FileDef * toFileDef(Definition *d)
Definition: filedef.cpp:1778
SearchDocEntry::extId
QCString extId
Definition: searchindex.cpp:398
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108