Classes | Public Member Functions | Private Attributes | List of all members
SearchIndexExternal Class Reference

#include <searchindex.h>

Inheritance diagram for SearchIndexExternal:
SearchIndexIntf

Classes

struct  Private
 

Public Member Functions

 SearchIndexExternal ()
 
 ~SearchIndexExternal ()
 
void setCurrentDoc (Definition *ctx, const char *anchor, bool isSourceFile)
 
void addWord (const char *word, bool hiPriority)
 
void write (const char *file)
 
- Public Member Functions inherited from SearchIndexIntf
 SearchIndexIntf (Kind k)
 
virtual ~SearchIndexIntf ()
 
Kind kind () const
 

Private Attributes

Privatep
 

Additional Inherited Members

- Public Types inherited from SearchIndexIntf
enum  Kind { Internal, External }
 

Detailed Description

Definition at line 100 of file searchindex.h.

Constructor & Destructor Documentation

SearchIndexExternal::SearchIndexExternal ( )

Definition at line 432 of file searchindex.cpp.

433 {
436  p->current=0;
437 }
Definition: types.h:26
void setAutoDelete(bool val)
Definition: sortdict.h:222
SDict< SearchDocEntry > docEntries
SearchIndexIntf(Kind k)
Definition: searchindex.h:73
const bool TRUE
Definition: qglobal.h:371
SearchIndexExternal::~SearchIndexExternal ( )

Definition at line 439 of file searchindex.cpp.

440 {
441  //printf("p->docEntries.count()=%d\n",p->docEntries.count());
442  delete p;
443 }

Member Function Documentation

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

Implements SearchIndexIntf.

Definition at line 527 of file searchindex.cpp.

528 {
529  if (word==0 || !isId(*word) || p->current==0) return;
530  GrowBuf *pText = hiPriority ? &p->current->importantText : &p->current->normalText;
531  if (pText->getPos()>0) pText->addChar(' ');
532  pText->addStr(word);
533  //printf("addWord %s\n",word);
534 }
void addStr(const char *s)
Definition: growbuf.h:19
void addChar(char c)
Definition: growbuf.h:16
GrowBuf normalText
bool isId(int c)
Definition: util.h:224
int getPos() const
Definition: growbuf.h:39
union ptb::content::word::word word
GrowBuf importantText
void SearchIndexExternal::setCurrentDoc ( Definition ctx,
const char *  anchor,
bool  isSourceFile 
)
virtual

Implements SearchIndexIntf.

Definition at line 500 of file searchindex.cpp.

501 {
502  QCString extId = stripPath(Config_getString("EXTERNAL_SEARCH_ID"));
503  QCString baseName = isSourceFile ? ((FileDef*)ctx)->getSourceFileBase() : ctx->getOutputFileBase();
505  if (anchor) url+=QCString("#")+anchor;
506  QCString key = extId+";"+url;
507 
508  p->current = p->docEntries.find(key);
509  //printf("setCurrentDoc(url=%s,isSourceFile=%d) current=%p\n",url.data(),isSourceFile,p->current);
510  if (!p->current)
511  {
513  e->type = isSourceFile ? QCString("source") : definitionToName(ctx);
514  e->name = ctx->qualifiedName();
516  {
517  e->args = ((MemberDef*)ctx)->argsString();
518  }
519  e->extId = extId;
520  e->url = url;
521  p->current = e;
522  p->docEntries.append(key,e);
523  //printf("searchIndexExt %s : %s\n",e->name.data(),e->url.data());
524  }
525 }
static QCString htmlFileExtension
Definition: doxygen.h:130
static QCString stripPath(const QCString &s)
Definition: tagreader.cpp:1287
virtual QCString getOutputFileBase() const =0
void append(const char *key, const T *d)
Definition: sortdict.h:135
virtual DefType definitionType() const =0
const double e
def key(type, name=None)
Definition: graph.py:13
static QCString definitionToName(Definition *ctx)
#define Config_getString(val)
Definition: config.cpp:660
virtual QCString qualifiedName() const
SDict< SearchDocEntry > docEntries
static QCString baseName
Definition: scanner.cpp:10890
T * find(const char *key)
Definition: sortdict.h:232
void SearchIndexExternal::write ( const char *  file)
virtual

Implements SearchIndexIntf.

Definition at line 536 of file searchindex.cpp.

537 {
538  QFile f(fileName);
539  if (f.open(IO_WriteOnly))
540  {
541  FTextStream t(&f);
542  t << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
543  t << "<add>" << endl;
546  for (it.toFirst();(doc=it.current());++it)
547  {
548  doc->normalText.addChar(0); // make sure buffer ends with a 0 terminator
549  doc->importantText.addChar(0); // make sure buffer ends with a 0 terminator
550  t << " <doc>" << endl;
551  t << " <field name=\"type\">" << doc->type << "</field>" << endl;
552  t << " <field name=\"name\">" << convertToXML(doc->name) << "</field>" << endl;
553  if (!doc->args.isEmpty())
554  {
555  t << " <field name=\"args\">" << convertToXML(doc->args) << "</field>" << endl;
556  }
557  if (!doc->extId.isEmpty())
558  {
559  t << " <field name=\"tag\">" << convertToXML(doc->extId) << "</field>" << endl;
560  }
561  t << " <field name=\"url\">" << convertToXML(doc->url) << "</field>" << endl;
562  t << " <field name=\"keywords\">" << convertToXML(doc->importantText.get()) << "</field>" << endl;
563  t << " <field name=\"text\">" << convertToXML(doc->normalText.get()) << "</field>" << endl;
564  t << " </doc>" << endl;
565  }
566  t << "</add>" << endl;
567  }
568  else
569  {
570  err("Failed to open file %s for writing!\n",fileName);
571  }
572 }
QCString convertToXML(const char *s)
Definition: util.cpp:5717
bool isEmpty() const
Definition: qcstring.h:189
#define IO_WriteOnly
Definition: qiodevice.h:62
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
Definition: sortdict.h:73
void addChar(char c)
Definition: growbuf.h:16
fileName
Definition: dumpTree.py:9
GrowBuf normalText
void err(const char *fmt,...)
Definition: message.cpp:226
SDict< SearchDocEntry > docEntries
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
const char * get()
Definition: growbuf.h:38
QCString doc
QTextStream & endl(QTextStream &s)
GrowBuf importantText

Member Data Documentation

Private* SearchIndexExternal::p
private

Definition at line 110 of file searchindex.h.


The documentation for this class was generated from the following files: