Doxygen
Toggle main menu visibility
Loading...
Searching...
No Matches
linkifytext.h
Go to the documentation of this file.
1
/******************************************************************************
2
*
3
* Copyright (C) 1997-2026 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
#ifndef LINKIFYTEXT_H
17
#define LINKIFYTEXT_H
18
19
#include <string_view>
20
#include <vector>
21
22
#include "
construct.h
"
23
24
class
ArgumentList
;
25
class
Definition
;
26
class
DString
;
27
class
FileDef
;
28
29
/** Abstract interface for a hyperlinked text fragment. */
30
class
TextGeneratorIntf
31
{
32
public
:
33
ABSTRACT_BASE_CLASS
(
TextGeneratorIntf
)
34
35
virtual
void
writeString
(
std
::string_view,
bool
) const = 0;
36
virtual
void
writeBreak
(
int
indent) const = 0;
37
virtual
void
writeLink
(const
DString
&extRef,const
DString
&file,
38
const
DString
&anchor,
std
::string_view text
39
) const = 0;
40
};
41
42
//--------------------------------------------------------------------
43
44
struct
LinkifyTextOptions
45
{
46
public
:
47
// === getters for optional params
48
const
Definition
*
scope
()
const
{
return
m_scope
; }
49
const
FileDef
*
fileScope
()
const
{
return
m_fileScope
; }
50
const
Definition
*
self
()
const
{
return
m_self
; }
51
const
ArgumentList
*
argumentList
()
const
{
return
m_al
; }
52
const
std::vector<const ArgumentList *> &
templateArgumentLists
()
const
{
return
m_tals
; }
53
bool
autoBreak
()
const
{
return
m_autoBreak
; }
54
bool
external
()
const
{
return
m_external
; }
55
bool
keepSpaces
()
const
{
return
m_keepSpaces
; }
56
int
indentLevel
()
const
{
return
m_indentLevel
; }
57
size_t
breakThreshold
()
const
{
return
m_breakThreshold
; }
58
59
// === setters for optional params
60
LinkifyTextOptions
&
setScope
(
const
Definition
*
scope
)
61
{
m_scope
=
scope
;
return
*
this
; }
62
63
LinkifyTextOptions
&
setFileScope
(
const
FileDef
*
fileScope
)
64
{
m_fileScope
=
fileScope
;
return
*
this
; }
65
66
LinkifyTextOptions
&
setSelf
(
const
Definition
*
self
)
67
{
m_self
=
self
;
return
*
this
;}
68
69
LinkifyTextOptions
&
setArgumentList
(
const
ArgumentList
*al)
70
{
m_al
= al;
return
*
this
; }
71
72
// template parameters declared in the given list are never linked
73
LinkifyTextOptions
&
addTemplateArgumentList
(
const
ArgumentList
*tal)
74
{
m_tals
.push_back(tal);
return
*
this
; }
75
76
LinkifyTextOptions
&
setAutoBreak
(
bool
autoBreak
)
77
{
m_autoBreak
=
autoBreak
;
return
*
this
; }
78
79
LinkifyTextOptions
&
setExternal
(
bool
external
)
80
{
m_external
=
external
;
return
*
this
; }
81
82
LinkifyTextOptions
&
setKeepSpaces
(
bool
keepSpaces
)
83
{
m_keepSpaces
=
keepSpaces
;
return
*
this
; }
84
85
LinkifyTextOptions
&
setIndentLevel
(
int
indentLevel
)
86
{
m_indentLevel
=
indentLevel
;
return
*
this
; }
87
88
LinkifyTextOptions
&
setBreakThreshold
(
size_t
breakThreshold
)
89
{
m_breakThreshold
=
breakThreshold
;
return
*
this
; }
90
91
private
:
92
// optional params with defaults
93
const
Definition
*
m_scope
=
nullptr
;
94
const
FileDef
*
m_fileScope
=
nullptr
;
95
const
Definition
*
m_self
=
nullptr
;
96
const
ArgumentList
*
m_al
=
nullptr
;
97
std::vector<const ArgumentList *>
m_tals
;
98
bool
m_autoBreak
=
false
;
99
bool
m_external
=
true
;
100
bool
m_keepSpaces
=
false
;
101
int
m_indentLevel
= 0;
102
size_t
m_breakThreshold
= 30;
103
};
104
105
//--------------------------------------------------------------------
106
107
void
linkifyText
(
const
TextGeneratorIntf
&ol,
108
const
DString
&text,
109
const
LinkifyTextOptions
&options
110
);
111
112
#endif
// LINKIFYTEXT_H
ArgumentList
This class represents an function or template argument list.
Definition
arguments.h:66
DString
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition
dstring.h:84
Definition
The common base class of all entity definitions found in the sources.
Definition
definition.h:77
FileDef
A model of a file symbol.
Definition
filedef.h:97
TextGeneratorIntf
Abstract interface for a hyperlinked text fragment.
Definition
linkifytext.h:31
TextGeneratorIntf::writeString
virtual void writeString(std::string_view, bool) const =0
TextGeneratorIntf::writeBreak
virtual void writeBreak(int indent) const =0
TextGeneratorIntf::writeLink
virtual void writeLink(const DString &extRef, const DString &file, const DString &anchor, std::string_view text) const =0
construct.h
ABSTRACT_BASE_CLASS
#define ABSTRACT_BASE_CLASS(cls)
Macro to implement rule of 5 for an abstract base class.
Definition
construct.h:20
linkifyText
void linkifyText(const TextGeneratorIntf &ol, const DString &text, const LinkifyTextOptions &options)
Definition
linkifytext.cpp:115
std
Definition
dstring.h:913
LinkifyTextOptions
Definition
linkifytext.h:45
LinkifyTextOptions::setScope
LinkifyTextOptions & setScope(const Definition *scope)
Definition
linkifytext.h:60
LinkifyTextOptions::m_breakThreshold
size_t m_breakThreshold
Definition
linkifytext.h:102
LinkifyTextOptions::m_fileScope
const FileDef * m_fileScope
Definition
linkifytext.h:94
LinkifyTextOptions::m_indentLevel
int m_indentLevel
Definition
linkifytext.h:101
LinkifyTextOptions::setAutoBreak
LinkifyTextOptions & setAutoBreak(bool autoBreak)
Definition
linkifytext.h:76
LinkifyTextOptions::m_self
const Definition * m_self
Definition
linkifytext.h:95
LinkifyTextOptions::setSelf
LinkifyTextOptions & setSelf(const Definition *self)
Definition
linkifytext.h:66
LinkifyTextOptions::indentLevel
int indentLevel() const
Definition
linkifytext.h:56
LinkifyTextOptions::setFileScope
LinkifyTextOptions & setFileScope(const FileDef *fileScope)
Definition
linkifytext.h:63
LinkifyTextOptions::external
bool external() const
Definition
linkifytext.h:54
LinkifyTextOptions::m_al
const ArgumentList * m_al
Definition
linkifytext.h:96
LinkifyTextOptions::setIndentLevel
LinkifyTextOptions & setIndentLevel(int indentLevel)
Definition
linkifytext.h:85
LinkifyTextOptions::argumentList
const ArgumentList * argumentList() const
Definition
linkifytext.h:51
LinkifyTextOptions::setArgumentList
LinkifyTextOptions & setArgumentList(const ArgumentList *al)
Definition
linkifytext.h:69
LinkifyTextOptions::scope
const Definition * scope() const
Definition
linkifytext.h:48
LinkifyTextOptions::addTemplateArgumentList
LinkifyTextOptions & addTemplateArgumentList(const ArgumentList *tal)
Definition
linkifytext.h:73
LinkifyTextOptions::self
const Definition * self() const
Definition
linkifytext.h:50
LinkifyTextOptions::m_external
bool m_external
Definition
linkifytext.h:99
LinkifyTextOptions::setKeepSpaces
LinkifyTextOptions & setKeepSpaces(bool keepSpaces)
Definition
linkifytext.h:82
LinkifyTextOptions::m_keepSpaces
bool m_keepSpaces
Definition
linkifytext.h:100
LinkifyTextOptions::m_tals
std::vector< const ArgumentList * > m_tals
Definition
linkifytext.h:97
LinkifyTextOptions::breakThreshold
size_t breakThreshold() const
Definition
linkifytext.h:57
LinkifyTextOptions::keepSpaces
bool keepSpaces() const
Definition
linkifytext.h:55
LinkifyTextOptions::fileScope
const FileDef * fileScope() const
Definition
linkifytext.h:49
LinkifyTextOptions::m_scope
const Definition * m_scope
Definition
linkifytext.h:93
LinkifyTextOptions::templateArgumentLists
const std::vector< const ArgumentList * > & templateArgumentLists() const
Definition
linkifytext.h:52
LinkifyTextOptions::m_autoBreak
bool m_autoBreak
Definition
linkifytext.h:98
LinkifyTextOptions::setExternal
LinkifyTextOptions & setExternal(bool external)
Definition
linkifytext.h:79
LinkifyTextOptions::autoBreak
bool autoBreak() const
Definition
linkifytext.h:53
LinkifyTextOptions::setBreakThreshold
LinkifyTextOptions & setBreakThreshold(size_t breakThreshold)
Definition
linkifytext.h:88
src
linkifytext.h
Generated by
1.19.0