Doxygen XLinks
by
V: 2511R0
Website: doxygen
Loading...
Searching...
No Matches
expressions.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header-file is part of \dxl - A doxygen post-processor that allows to define smarter
4/// <b>Doxygen</b>-links.
5///
6/// \emoji :copyright: 2025-2026 A-Worx GmbH, Germany.
7/// Published under \ref mainpage_license "Boost Software License".
8//==================================================================================================
9#ifndef HPP_DXL_EXPRESSIONS
10#define HPP_DXL_EXPRESSIONS
11#pragma once
12#include "xlink.hpp"
13#include "ALib.Expressions.H"
14
15namespace dxl {
16
17/// The expression scope used with \dxl expressions of options <c>--list</c> and <c>--format</c>.
18/// Holds a pointer to the #"XLink" in question and its source string.
20{
21 XLink* Xlink; ///<The link to evaluate.
22
23 alib::String Path; ///< The path (either scope- or file path) of the target entity.
24 ///< Created once with identifier \b Path.
25 /// Constructor.
26 /// Sets the expression compiler singleton which is located in an anonymous namespace.
27 DXLScope();
28
29 /// Resets this scope to be read for the next evaluation.
30 void Reset() override { Path= nullptr; Scope::Reset(); }
31};
32
33/// The expression formatter used with \dxl expressions option <c>--format</c>.
34/// The only difference to its parent class #"ExpressionFormatter" is that with construction
35/// it grabs the expression compiler singleton which is located in an anonymous namespace.
37 /// Constructor. Passes the internal compiler singleton to the parent class.
38 /// @param formatString Passed to the constructor of #"ExpressionFormatter".
39 DXLExpressionFormatter( const alib::String& formatString );
40};
41
42/// This class implements an #"alib_mod_expressions;ALib Expression Compiler Plugin"
43/// (internally) and with that enables "run-time expressions" to be evaluated on #"XLink"s.
44///
45/// For quick samples, see manual chapter #"dxl_manual_addfeat_queries"
46///
47/// Such run-time expressions are evaluated when option <c>--list</c> is passed.
48/// Here, an expression that evaluated to a boolean value has to be passed. (Integrals are also
49/// accepted, they are compared to zero). If the result is \c true, the \xl will be printed on
50/// the console together with a list of its source locations.
51///
52/// A second instance where expressions are evaluated are with the option <c>--format</c>.
53/// By using an \alib #"ExpressionFormatter", python-style format strings with expressions in
54/// its placeholder are processed per resulting \xl.
55///
56/// All identifier and function names are defined to be matched case-insensitive and can be
57/// abbreviated along their <em>CamelHumps</em>. This means an identifier called
58///
59/// CamelHumpCounter
60///
61/// can be abbreviated to:
62///
63/// CamelHC
64/// CHCounter
65/// CamHuCo
66/// CHC
67/// chc
68/// cHc
69///
70/// and so on.
71///
72/// # Implemented Expression Features #
73///
74/// # Types: #
75/// <br>
76/// This plug-in introduces the following types to the expression compiler:
77/// - #"Target::Kind;2"
78/// - #"Index::Node;2"
79///
80/// The type #"Target::Kind;2" is auto-cast to built-in expression type \b Integer to allow all
81/// common operators, especially bitwise boolean operators.
82///
83/// # Constants: #
84/// <br>
85/// Type | Name |Min. Abbreviation
86/// --------------------------|-------------------|-----------------
87/// #"Target::Dir;*" |\b Dir | dir
88/// #"Target::File;*" |#"%FTFile" | fil
89/// #"Target::Page;*" |\b Page | page
90/// #"Target::Group;*" |\b Group | g
91/// #"Target::DocAnchor;*" |\b DocAnchor | da
92/// #"Target::Namespace;*" |\b NameSpace | ns
93/// #"Target::Struct;*" |\b Struct | stru
94/// #"Target::Class;*" |\b Class | c
95/// #"Target::Union;*" |\b Union | u
96/// #"Target::Concept;*" |\b ConCept | cc
97/// #"Target::Macro;*" |\b Macro | m
98/// #"Target::Typedef;*" |\b TypeDef | td
99/// #"Target::Variable;*" |\b Variable | v
100/// #"Target::Function;*" |\b Function | f
101/// #"Target::Enumeration;*" |\b Enumeration | e
102/// #"Target::EnumElement;*" |\b EnumValue | ev
103/// #"Target::GenericMember;*"|\b GenericMember | gm
104/// #"Target::RECORD;*" |\b Record | r
105/// #"Target::UNSPECIFIED;*" |\b UnSpecified | us
106///
107/// <br>
108/// # Functions: #
109/// The following functions retrieve values concerning the parsed \xl, its resolved targets,
110/// tag-files and so on. As common with run-time expressions, all functions implementations
111/// duly suppress any error. For example, when a parent of a target is addressed that does not
112/// exist, and this parent is passed to function <b>Name</b>, then, an emtpy string is silently
113/// returned. Functions that return an integer value return \c -1 or \c 0 if erroneous parameters
114/// are passed, dependent on whatever is more appropriate.
115///
116///
117/// ## Functions Retrieving The Basic XLink Values: <br>
118///
119/// Return Type | Name | Min. Abbrev. | Signature | Description
120/// ---------------------|---------------------------| -----|--------------|--------------
121/// String | \b LinkString | ls | \e void | Returns the original link string.
122/// String | \b LinkTarget | lt | \e void | Returns the \xl string excluding the display specification. (In other words: The link string up to the semicolon <c>';'</c>.)
123/// String | \b LinkDisplay | ld | \e void | Returns the display as specified in the \xl. \note The resolved display text is received with function <b>Display</b>.
124/// #"Target::Kind" | \b KindSpec | ks | \e void | Returns the character (as a String) that was given in the link-string to specify the target kind with optional prefix <c>[!tspec]</c>. See manual chapter #"dxl_xl_target_kinds")
125/// Integer | \b CountScopeHints | csh | \e void | Returns the number of scopes-hints provided with the link string.
126/// String | \b ScopeHint | sh | Integer | Returns the name of the n-th parent scope, as specified in the link string.
127/// String | \b CountScope | cs | \e void | Returns the number of scopes provided with the link string.
128/// String | \b Scope | s | Integer | Returns the name of the n-th parent scope, as specified in the link string.
129/// String | \b Identifier | i | \e void | Returns the identifier name as specified in the link string.
130/// Boolean | \b IsResolved | ir | \e void | Returns whether the \xl is uniquely resolved.
131/// Integer | \b CountParaMS | cpm | \e void | Receives the number of function-parameters given with the \xl.
132/// String | \b ParaMeterS | pm | \e void | Receives the function-parameters given with the \xl.
133/// Integer | \b CountTemplateParaMS | ctpm | \e void | Receives the number of template-parameters given with the \xl.
134/// String | \b TemplateParaMS | tpm | \e void | Receives the template-parameters given with the \xl.
135/// Integer | \b CountTemplateSpecParaMS| ctspm| \e void | Receives the number of template-specialization-parameters given with the \xl.
136/// String | \b TemplateSpecParaMS | tspm | \e void | Receives the template-specialization-parameters given with the \xl.
137/// Integer | \b ErrorCode | ec | \e void | Returns the #"XLink::Errors;error- and warning code" of the \xl.
138/// Boolean | \b HasError | he | \e void | Returns whether an error occurred during the \xl assembly.
139/// Boolean | \b HasWarning | hw | \e void | Returns whether a warning was encountered during the \xl assembly.
140/// Boolean | \b IsGood | ig | \e void | Returns whether the \xl is uniquely resolved and no warnings or errors have been found.
141/// Boolean | \b IsScannedHtmlFile | ishf | \e void | Returns \c true if the link targets an HTML file that was not received from the tag-file, but scanned in \b Doxygen's output-folder. See manual section #"dxl_xl_file").
142/// Boolean | \b IsIndirectSourceFile | iihf | \e void | Returns \c true if the link targets the source code of a file directly, which then also targets an HTML-file scanned in \b Doxygen's output-folder. See manual section #"dxl_xl_file").
143/// Boolean | \b IsInherited | ii | \e void | Returns \c true if the link targets a member of a base type, while the derived type is given as its scope. See manual section #"dxl_xl_indirect").
144/// Boolean | \b IsIndirectTypeDefMember| iitdm| \e void | Returns \c true if the link targets a member of an underlying type of a type definition. See manual section #"dxl_xl_indirect").
145/// Boolean | \b IsIndirectTypeDef | iitd | \e void | Returns \c true if the link targets the underlying type of a type definition. See manual section #"dxl_xl_typedefinitions").
146/// String | \b Display | d | \e void | Returns the assembled display string.
147///
148///
149/// ## Functions On The Resolved Target Node: <br>
150/// Return Type | Name | Min. Abbrev. | Signature | Description
151/// ---------------------|---------------------------| -----|--------------|--------------
152/// Index::Node | \b %Target | t | \e void | Returns the #"Index::Node" of the target-entity.
153/// #"Target::Kind" | \b Kind | k | \e void | Returns the kind of the resolved target entity.
154/// Integer | \b Depth | dep | \e void | Returns the depth of the target node. With source entities this is the scope-depth, with folders and files, the depth in the filesystem- as far as doxygen is told to consider the parents.
155/// String | \b Name | n | \e void | Returns the name of the target entity.
156/// String | \b Name | n | Index::Node| Returns the name of the given cursor.
157/// Index::Node | \b Parent | p | \e void | Returns the parent of the target-entity.
158/// Index::Node | \b Parent | p | Index::Node| Returns the parent of the given cursor.
159/// Index::Node | \b Parent | p | Integer | Returns the n-th parent of the target-entity.
160/// String | \b Path | path | \e void | Returns the path-string of the target-entity. With files and folders <c>'/'</c> is used as the separation character, with code-entities <c>"::"</c> is used.
161/// String | \b Path | path | Index::Node| Returns the path-string of the given cursor. (Pass "Target", like in: <em>"Path(Target)"</em> or <em>"Path(Parent(Target))"</em>.)
162/// Integer | \b CountParaMS | cpm | Index::Node| Receives the number of function-parameters of the target node. (Pass "Target", like in: <em>"CParams(Target)"</em>.)
163/// String | \b ParaMeterS | pm | Index::Node| Receives the function-parameters of the target node. (Pass "Target", like in: <em>"Params(Target)"</em>.)
164/// Integer | \b CountTemplateParaMS | ctpm | Index::Node| Receives the number of template-parameters of the target node. (Pass "Target", like in: <em>"CTParms(Target)"</em>.)
165/// String | \b TemplateParaMS | tpm | Index::Node| Receives the template-parameters of the target node. (Pass "Target", like in: <em>"TParams(Target)"</em>.)
166/// Integer | \b CountTemplateSpecParaMS| ctspm| Index::Node| Receives the number of template-specialization-parameters of the target node. (Pass "Target", like in: <em>"CTSParams(Target)"</em>.)
167/// String | \b TemplateSpecParaMS | tspm | Index::Node| Receives the template-specialization-parameters of the target node. (Pass "Target", like in: <em>"TSParams(Target)"</em>.)
168///
169/// ## Functions Concerning Source-, HTML- and Tag-Files: <br>
170/// Return Type | Name | Min. Abbrev. | Signature | Description
171/// ---------------------|---------------------------| -----|--------------|--------------
172/// Integer | \b CountSourceLocationS | csl | \e void | Receives the number of source-locations that a \xl was found at. \note Two \xls in sources are different if their source string is different - even if they resolve to the same target.
173/// Integer | \b CountHtmlLocationS | chl | \e void | Receives the number of (replaced) HTML-locations that a \xl was found at. \note This number is often higher than the number of source-locations, because \b Doxygen places the same documentation text (which includes the \xl!) in different areas.
174/// String | \b TagFilePath | tfp | \e void | Receives the path of the tag file that defined the resolved target.
175/// String | \b TagFilePath | tfp | Index::Node| Receives the path of the tag file that defined the given node.
176/// String | \b TagFileName | tfn | \e void | Receives the file-portion of the path of the tag file that defined the resolved target.
177/// String | \b TagFileName | tfn | Index::Node| Receives the file-portion of the path of the tag file that defined the given node.
178/// Integer | \b TagFileLine | tfl | \e void | Receives the line number in the tag file that defined the resolved target.
179/// Integer | \b TagFileLine | tfl | Index::Node| Receives the line number in the tag file that defined the given node.
180/// String | \b HtmlFile | hf | \e void | Receives the name of the HTML-file that documents the target.
181/// String | \b HtmlFile | hf | Index::Node| Receives the name of the HTML-file that documents the given node.
182/// String | \b HtmlAnchor | ha | \e void | Receives the anchor within the HTML-file that documents the target. (Not all entities have an anchor. For example namespace, classes, do not have one, because they have an own dedicated page.)
183/// String | \b HtmlAnchor | ha | Index::Node| Receives the anchor within the HTML-file that documents the given node.
184///
186{
187 protected:
188 DXLScope* scope; ///< The scope used with this filter.
189 alib::expressions::Expression expression; ///< The compiled expression.
190
191 public:
192 /// Constructor. Compiles the given expression.
193 /// @param expressionString The expression string.
194 DXLExpression(const alib::String& expressionString );
195
196 /// Destructor.
198
199 /// @return The expression string given with construction (in a normalized fashion!).
200 alib::String GetExpressionString() { return expression->GetNormalizedString(); }
201
202 /// @return The expression string after all optimizations have been performed.
203 alib::String GetOptimizedString() { return expression->GetOptimizedString(); }
204
205 /// @return The result-type of the expression - as a \b Box: that's how \alib_expressions
206 /// represents types!
207 alib::Box ResultType() { return expression->ResultType(); }
208
209 /// @return \c true if the expression evaluates to a constant value (the same result for
210 /// any \xl), \c false otherwise.
211 alib::Box IsConstant() { return expression->IsConstant(); }
212
213 /// The filter method.
214 /// @param xLink The link to evaluate.
215 /// @return The result of the expression when evaluated with the scope of the given \b XLink
216 /// and its search string.
217 bool Includes( XLink* xLink );
218};
219
220} // namespace [dxl]
221
222#endif // HPP_DXL_EXPRESSIONS
alib::Box IsConstant()
alib::String GetExpressionString()
alib::Box ResultType()
DXLScope * scope
The scope used with this filter.
~DXLExpression()
Destructor.
bool Includes(XLink *xLink)
DXLExpression(const alib::String &expressionString)
alib::expressions::Expression expression
The compiled expression.
alib::String GetOptimizedString()
boxing::Box Box
strings::TString< character > String
todox
Definition doxyfile.cpp:20
DXLExpressionFormatter(const alib::String &formatString)
void Reset() override
Resets this scope to be read for the next evaluation.
XLink * Xlink
The link to evaluate.
alib::String Path