Doxygen
Toggle main menu visibility
Loading...
Searching...
No Matches
searchindex_js.h
Go to the documentation of this file.
1
/******************************************************************************
2
*
3
* Copyright (C) 1997-2022 by Dimitri van Heesch.
4
*
5
* Permission to use, copy, modify, and distribute this software and its
6
* documentation under the terms of the GNU General Public License is hereby
7
* granted. No representations are made about the suitability of this software
8
* for any purpose. It is provided "as is" without express or implied warranty.
9
* See the GNU General Public License for more details.
10
*
11
* Documents produced by Doxygen are derivative works derived from the
12
* input used in their production; they are not affected by this license.
13
*
14
*/
15
16
/** @file
17
* @brief Javascript based search engine.
18
*/
19
20
#ifndef SEARCHINDEX_JS_H
21
#define SEARCHINDEX_JS_H
22
23
#include <array>
24
#include <functional>
25
#include <map>
26
#include <string>
27
#include <variant>
28
#include <vector>
29
30
#include "
dstring.h
"
31
32
#define NUM_SEARCH_INDICES 22
33
34
class
SectionInfo
;
35
class
Definition
;
36
37
//DString searchId(const Definition *d);
38
DString
searchName
(
const
Definition
*d);
39
40
//! Searchable term
41
struct
SearchTerm
42
{
43
using
LinkInfo
= std::variant<std::monostate,const Definition *,const SectionInfo *>;
44
SearchTerm
(
const
DString
&w,
const
Definition
*d) :
word
(w.str()),
info
(d) {
makeTitle
(); }
45
SearchTerm
(
const
DString
&w,
const
SectionInfo
*s) :
word
(w.str()),
info
(s) {
makeTitle
(); }
46
DString
word
;
//!< lower case word that is indexed (e.g. name of a symbol, or word from a title)
47
DString
title
;
//!< title to show in the output for this search result
48
LinkInfo
info
;
//!< definition to link to
49
DString
termEncoded
()
const
;
//!< encoded version of the search term
50
private
:
51
void
makeTitle
();
52
};
53
54
//! List of search terms
55
using
SearchIndexList
= std::vector<SearchTerm>;
56
57
//! Map of search terms for a given starting letter
58
using
SearchIndexMap
= std::map<std::string,SearchIndexList>;
// key is starting letter of a term (UTF-8).
59
60
//! Table entry to allow filtering the search results per category
61
struct
SearchIndexInfo
62
{
63
void
add
(
const
SearchTerm
&
term
);
64
DString
name
;
65
std::function<
DString
()>
getText
;
66
SearchIndexMap
symbolMap
;
67
};
68
69
void
createJavaScriptSearchIndex
();
70
void
writeJavaScriptSearchIndex
();
71
const
std::array<SearchIndexInfo,NUM_SEARCH_INDICES> &
getSearchIndices
();
72
73
#endif
DString
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition
dstring.h:88
DString::DString
DString()=default
Definition
The common base class of all entity definitions found in the sources.
Definition
definition.h:77
SectionInfo
class that provide information about a section.
Definition
section.h:58
dstring.h
term
#define term(fmt,...)
Definition
message.h:137
createJavaScriptSearchIndex
void createJavaScriptSearchIndex()
Definition
searchindex_js.cpp:334
getSearchIndices
const std::array< SearchIndexInfo, NUM_SEARCH_INDICES > & getSearchIndices()
Definition
searchindex_js.cpp:870
writeJavaScriptSearchIndex
void writeJavaScriptSearchIndex()
Definition
searchindex_js.cpp:799
SearchIndexList
std::vector< SearchTerm > SearchIndexList
List of search terms.
Definition
searchindex_js.h:55
searchName
DString searchName(const Definition *d)
SearchIndexMap
std::map< std::string, SearchIndexList > SearchIndexMap
Map of search terms for a given starting letter.
Definition
searchindex_js.h:58
SearchIndexInfo
Table entry to allow filtering the search results per category.
Definition
searchindex_js.h:62
SearchIndexInfo::add
void add(const SearchTerm &term)
Definition
searchindex_js.cpp:863
SearchIndexInfo::getText
std::function< DString()> getText
Definition
searchindex_js.h:65
SearchIndexInfo::symbolMap
SearchIndexMap symbolMap
Definition
searchindex_js.h:66
SearchIndexInfo::name
DString name
Definition
searchindex_js.h:64
SearchTerm
Searchable term.
Definition
searchindex_js.h:42
SearchTerm::word
DString word
lower case word that is indexed (e.g. name of a symbol, or word from a title)
Definition
searchindex_js.h:46
SearchTerm::SearchTerm
SearchTerm(const DString &w, const SectionInfo *s)
Definition
searchindex_js.h:45
SearchTerm::LinkInfo
std::variant< std::monostate, const Definition *, const SectionInfo * > LinkInfo
Definition
searchindex_js.h:43
SearchTerm::info
LinkInfo info
definition to link to
Definition
searchindex_js.h:48
SearchTerm::SearchTerm
SearchTerm(const DString &w, const Definition *d)
Definition
searchindex_js.h:44
SearchTerm::title
DString title
title to show in the output for this search result
Definition
searchindex_js.h:47
SearchTerm::makeTitle
void makeTitle()
Definition
searchindex_js.cpp:43
SearchTerm::termEncoded
DString termEncoded() const
encoded version of the search term
Definition
searchindex_js.cpp:64
src
searchindex_js.h
Generated by
1.19.0