Doxygen
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
34class SectionInfo;
35class Definition;
36
37//DString searchId(const Definition *d);
39
40//! Searchable term
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
50private:
51 void makeTitle();
52};
53
54//! List of search terms
55using SearchIndexList = std::vector<SearchTerm>;
56
57//! Map of search terms for a given starting letter
58using 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
62{
63 void add(const SearchTerm &term);
65 std::function<DString()> getText;
67};
68
71const std::array<SearchIndexInfo,NUM_SEARCH_INDICES> &getSearchIndices();
72
73#endif
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:88
DString()=default
The common base class of all entity definitions found in the sources.
Definition definition.h:77
class that provide information about a section.
Definition section.h:58
#define term(fmt,...)
Definition message.h:137
void createJavaScriptSearchIndex()
const std::array< SearchIndexInfo, NUM_SEARCH_INDICES > & getSearchIndices()
void writeJavaScriptSearchIndex()
std::vector< SearchTerm > SearchIndexList
List of search terms.
DString searchName(const Definition *d)
std::map< std::string, SearchIndexList > SearchIndexMap
Map of search terms for a given starting letter.
Table entry to allow filtering the search results per category.
void add(const SearchTerm &term)
std::function< DString()> getText
SearchIndexMap symbolMap
Searchable term.
DString word
lower case word that is indexed (e.g. name of a symbol, or word from a title)
SearchTerm(const DString &w, const SectionInfo *s)
std::variant< std::monostate, const Definition *, const SectionInfo * > LinkInfo
LinkInfo info
definition to link to
SearchTerm(const DString &w, const Definition *d)
DString title
title to show in the output for this search result
DString termEncoded() const
encoded version of the search term