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 DString &w, const Definition *d)
 SearchTerm (const DString &w, const SectionInfo *s)
DString termEncoded () const
 encoded version of the search term

Public Attributes

DString word
 lower case word that is indexed (e.g. name of a symbol, or word from a title)
DString 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 41 of file searchindex_js.h.

Member Typedef Documentation

◆ LinkInfo

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

Definition at line 43 of file searchindex_js.h.

Constructor & Destructor Documentation

◆ SearchTerm() [1/2]

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

Definition at line 44 of file searchindex_js.h.

44: word(w.str()), info(d) { makeTitle(); }
const std::string & str() const
Definition dstring.h:649
DString 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.

Referenced by addMemberToSearchIndex(), and createJavaScriptSearchIndex().

◆ SearchTerm() [2/2]

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

Definition at line 45 of file searchindex_js.h.

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

References info, makeTitle(), and word.

Member Function Documentation

◆ makeTitle()

void SearchTerm::makeTitle ( )
private

Definition at line 43 of file searchindex_js.cpp.

44{
45 if (std::holds_alternative<const Definition *>(info))
46 {
47 const Definition *def = std::get<const Definition *>(info);
49 title = type==Definition::TypeGroup ? parseCommentAsHtml(def,nullptr,toGroupDef(def)->groupTitle(),def->getDefFileName(),def->getDefLine()) :
50 type==Definition::TypePage ? parseCommentAsHtml(def,nullptr,toPageDef(def)->title(),def->getDefFileName(),def->getDefLine()) :
51 def->localName();
52 }
53 else if (std::holds_alternative<const SectionInfo *>(info))
54 {
55 const SectionInfo *si = std::get<const SectionInfo *>(info);
56 title = parseCommentAsHtml(si->definition(),nullptr,si->title(),si->fileName(),si->lineNr());
57 }
58 else
59 {
60 assert(false);
61 }
62}
virtual DString getDefFileName() const =0
virtual int getDefLine() const =0
virtual DefType definitionType() const =0
DString fileName() const
Definition section.h:74
Definition * definition() const
Definition section.h:77
int lineNr() const
Definition section.h:73
DString title() const
Definition section.h:70
DString parseCommentAsHtml(const Definition *scope, const MemberDef *member, const DString &doc, const DString &fileName, int lineNr)
GroupDef * toGroupDef(Definition *d)
PageDef * toPageDef(Definition *d)
Definition pagedef.cpp:653
DString title
title to show in the output for this search result

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

Referenced by SearchTerm(), and SearchTerm().

◆ termEncoded()

DString SearchTerm::termEncoded ( ) const

encoded version of the search term

Definition at line 64 of file searchindex_js.cpp.

65{
66 TextStream t;
67
68 for (size_t i=0;i<word.length();i++)
69 {
70 char c = word.at(i);
71 if (c<0 || isalnum(c))
72 {
73 t << word.at(i);
74 }
75 else // escape non-identifier characters
76 {
77 static const char *hex = "0123456789ABCDEF";
78 unsigned char uc = static_cast<unsigned char>(word.at(i));
79 t << '_';
80 t << hex[uc>>4];
81 t << hex[uc&0xF];
82 }
83 }
84
85 return convertUTF8ToLower(t.str());
86}
char & at(size_t i)
Returns a reference to the character at index i.
Definition dstring.h:690
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition dstring.h:155
std::string str() const
Return the contents of the buffer as a std::string object.
Definition textstream.h:232
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:188

References DString::at(), convertUTF8ToLower(), DString::length(), TextStream::str(), and word.

Member Data Documentation

◆ info

LinkInfo SearchTerm::info

definition to link to

Definition at line 48 of file searchindex_js.h.

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

◆ title

DString SearchTerm::title

title to show in the output for this search result

Definition at line 47 of file searchindex_js.h.

Referenced by makeTitle().

◆ word

DString SearchTerm::word

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

Definition at line 46 of file searchindex_js.h.

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


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