Doxygen
Loading...
Searching...
No Matches
SearchTerm Struct Reference

Searchable term. More...

#include <src/searchindex_js.h>

Collaboration diagram for SearchTerm:

Public Types

using LinkInfo = std::variant<std::monostate,const Definition *,const SectionInfo *>

Public Member Functions

 SearchTerm (const QCString &w, const Definition *d)
 SearchTerm (const QCString &w, const SectionInfo *s)
QCString termEncoded () const
 encoded version of the search term

Public Attributes

QCString word
 lower case word that is indexed (e.g. name of a symbol, or word from a title)
QCString title
 title to show in the output for this search result
LinkInfo info
 definition to link to

Private Member Functions

void makeTitle ()

Detailed Description

Searchable term.

Definition at line 42 of file searchindex_js.h.

Member Typedef Documentation

◆ LinkInfo

using SearchTerm::LinkInfo = std::variant<std::monostate,const Definition *,const SectionInfo *>

Definition at line 44 of file searchindex_js.h.

Constructor & Destructor Documentation

◆ SearchTerm() [1/2]

SearchTerm::SearchTerm ( const QCString & w,
const Definition * d )
inline

Definition at line 45 of file searchindex_js.h.

45: word(w.str()), info(d) { makeTitle(); }
const std::string & str() const
Definition qcstring.h:537
QCString word
lower case word that is indexed (e.g. name of a symbol, or word from a title)
LinkInfo info
definition to link to

References info, makeTitle(), and word.

◆ SearchTerm() [2/2]

SearchTerm::SearchTerm ( const QCString & w,
const SectionInfo * s )
inline

Definition at line 46 of file searchindex_js.h.

46: word(w.str()), info(s) { makeTitle(); }

References info, makeTitle(), and word.

Member Function Documentation

◆ makeTitle()

void SearchTerm::makeTitle ( )
private

Definition at line 80 of file searchindex_js.cpp.

81{
82 if (std::holds_alternative<const Definition *>(info))
83 {
84 const Definition *def = std::get<const Definition *>(info);
86 title = type==Definition::TypeGroup ? convertTitleToHtml(def,def->getDefFileName(),def->getDefLine(),toGroupDef(def)->groupTitle()) :
87 type==Definition::TypePage ? convertTitleToHtml(def,def->getDefFileName(),def->getDefLine(),toPageDef(def)->title()) :
88 def->localName();
89 }
90 else if (std::holds_alternative<const SectionInfo *>(info))
91 {
92 const SectionInfo *si = std::get<const SectionInfo *>(info);
93 title = convertTitleToHtml(si->definition(),si->fileName(),si->lineNr(),si->title());
94 }
95 else
96 {
97 assert(false);
98 }
99}
virtual QCString getDefFileName() const =0
virtual int getDefLine() const =0
virtual DefType definitionType() const =0
Definition * definition() const
Definition section.h:76
QCString fileName() const
Definition section.h:73
int lineNr() const
Definition section.h:72
QCString title() const
Definition section.h:69
GroupDef * toGroupDef(Definition *d)
PageDef * toPageDef(Definition *d)
Definition pagedef.cpp:487
static QCString convertTitleToHtml(const Definition *scope, const QCString &fileName, int lineNr, const QCString &title)
QCString title
title to show in the output for this search result

References convertTitleToHtml(), SectionInfo::definition(), Definition::definitionType(), SectionInfo::fileName(), Definition::getDefFileName(), Definition::getDefLine(), info, SectionInfo::lineNr(), Definition::localName(), title, SectionInfo::title(), toGroupDef(), toPageDef(), Definition::TypeGroup, and Definition::TypePage.

Referenced by SearchTerm(), and SearchTerm().

◆ termEncoded()

QCString SearchTerm::termEncoded ( ) const

encoded version of the search term

Definition at line 101 of file searchindex_js.cpp.

102{
103 TextStream t;
104 for (size_t i=0;i<word.length();i++)
105 {
106 if (isIdJS(word.at(i)))
107 {
108 t << word.at(i);
109 }
110 else // escape non-identifier characters
111 {
112 static const char *hex = "0123456789ABCDEF";
113 unsigned char uc = static_cast<unsigned char>(word.at(i));
114 t << '_';
115 t << hex[uc>>4];
116 t << hex[uc&0xF];
117 }
118 }
119
120 return convertUTF8ToLower(t.str());
121}
std::string str() const
Return the contents of the buffer as a std::string object.
Definition textstream.h:229
static constexpr auto hex
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
bool isIdJS(int c)
Definition util.h:212

References convertUTF8ToLower(), hex, isIdJS(), TextStream::str(), and word.

Member Data Documentation

◆ info

LinkInfo SearchTerm::info

definition to link to

Definition at line 49 of file searchindex_js.h.

Referenced by makeTitle(), SearchTerm(), and SearchTerm().

◆ title

QCString SearchTerm::title

title to show in the output for this search result

Definition at line 48 of file searchindex_js.h.

Referenced by makeTitle().

◆ word

QCString SearchTerm::word

lower case word that is indexed (e.g. name of a symbol, or word from a title)

Definition at line 47 of file searchindex_js.h.

Referenced by SearchTerm(), SearchTerm(), and termEncoded().


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