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 alib::expressions { class Compiler; struct Expression;}
16namespace dxl {
17
18/// The expression scope used with \dxl expressions of options <c>--list</c> and <c>--format</c>.
19/// Holds a pointer to the #"XLink" in question and its source string.
21{
22 XLink* Xlink; ///<The link to evaluate.
23
24 alib::String Path; ///< The path (either scope- or file path) of the target entity.
25 ///< Created once with identifier \b Path.
26 /// Constructor.
27 /// Sets the expression compiler singleton which is located in an anonymous namespace.
28 DXLScope();
29
30 /// Resets this scope to be read for the next evaluation.
31 void Reset() override {
32 Path= nullptr;
33 Scope::Reset();
34 }
35
36};
37
38/// The expression formatter used with \dxl expressions option <c>--format</c>.
39/// The only difference to its parent class #"ExpressionFormatter" is that with construction
40/// it grabs the expression compiler singleton which is located in an anonymous namespace.
42 /// Constructor. Passes the internal compiler singleton to the parent class.
43 /// @param formatString Passed to the constructor of #"ExpressionFormatter".
44 DXLExpressionFormatter( const alib::String& formatString );
45};
46
47/// This class implements an #"alib_mod_expressions;ALib Expression Compiler Plugin"
48/// (internally) and with that enables "run-time expressions" to be evaluated on #"XLink"s.
49///
50/// For quick samples, see manual chapter #"dxl_manual_addfeat_queries"
51///
52/// Such run-time expressions are evaluated when option <c>--list</c> is passed.
53/// Here, an expression that evaluated to a boolean value has to be passed. (Integrals are also
54/// accepted, they are compared to zero). If the result is \c true, the \xl will be printed on
55/// the console together with a list of its source locations.
56///
57/// A second instance where expressions are evaluated are with the option <c>--format</c>.
58/// By using an \alib #"ExpressionFormatter", python-style format strings with expressions in
59/// its placeholder are processed per resulting \xl.
60///
61/// All identifier and function names are defined to be matched case-insensitive and can be
62/// abbreviated along their <em>CamelHumps</em>. This means an identifier called
63///
64/// CamelHumpCounter
65///
66/// can be abbreviated to:
67///
68/// CamelHC
69/// CHCounter
70/// CamHuCo
71/// CHC
72/// chc
73/// cHc
74///
75/// and so on.
76///
77/// # Implemented Expression Features #
78///
79/// # Types: #
80/// <br>
81/// This plug-in introduces the following types to the expression compiler:
82/// - #"Target::Kind;2"
83/// - #"Index::Node;2"
84///
85/// The type #"Target::Kind;2" is auto-cast to built-in expression type \b Integer to allow all
86/// common operators, especially bitwise boolean operators.
87///
88/// # Constants: #
89/// <br>
90/// Type | Name |Min. Abbreviation
91/// --------------------------|-------------------|-----------------
92/// #"Target::Dir;*" |\b Dir | dir
93/// #"Target::File;*" |\b File | fil
94/// #"Target::Page;*" |\b Page | page
95/// #"Target::Group;*" |\b Group | g
96/// #"Target::DocAnchor;*" |\b DocAnchor | da
97/// #"Target::Namespace;*" |\b NameSpace | ns
98/// #"Target::Struct;*" |\b Struct | stru
99/// #"Target::Class;*" |\b Class | c
100/// #"Target::Union;*" |\b Union | u
101/// #"Target::Concept;*" |\b ConCept | cc
102/// #"Target::Macro;*" |\b Macro | m
103/// #"Target::Typedef;*" |\b TypeDef | td
104/// #"Target::Variable;*" |\b Variable | v
105/// #"Target::Function;*" |\b Function | f
106/// #"Target::Enumeration;*" |\b Enumeration | e
107/// #"Target::EnumElement;*" |\b EnumValue | ev
108/// #"Target::GenericMember;*"|\b GenericMember | gm
109/// #"Target::RECORD;*" |\b Record | r
110/// #"Target::UNSPECIFIED;*" |\b UnSpecified | us
111///
112/// <br>
113/// # Functions: #
114/// The following functions retrieve values concerning the parsed \xl, its resolved targets,
115/// tag-files and so on. As common with run-time expressions, all functions implementations
116/// duly suppress any error. For example, when a parent of a target is addressed that does not
117/// exist, and this parent is passed to function <b>Name</b>, then, an emtpy string is silently
118/// returned. Functions that return an integer value return \c -1 or \c 0 if erroneous parameters
119/// are passed, dependent on whatever is more appropriate.
120///
121///
122/// ## Functions Retrieving The Basic XLink Values: <br>
123///
124/// Return Type | Name | Min. Abbrev. | Signature | Description
125/// ---------------------|---------------------------| -----|--------------|--------------
126/// String | \b LinkString | ls | \e void | Returns the original link string.
127/// 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>.)
128/// 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>.
129/// #"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")
130/// Integer | \b CountScopeHints | csh | \e void | Returns the number of scopes-hints provided with the link string.
131/// String | \b ScopeHint | sh | Integer | Returns the name of the n-th parent scope, as specified in the link string.
132/// String | \b CountScope | cs | \e void | Returns the number of scopes provided with the link string.
133/// String | \b Scope | s | Integer | Returns the name of the n-th parent scope, as specified in the link string.
134/// String | \b Identifier | i | \e void | Returns the identifier name as specified in the link string.
135/// Boolean | \b IsResolved | ir | \e void | Returns whether the \xl is uniquely resolved.
136/// Integer | \b CountParaMS | cpm | \e void | Receives the number of function-parameters given with the \xl.
137/// String | \b ParaMeterS | pm | \e void | Receives the function-parameters given with the \xl.
138/// Integer | \b CountTemplateParaMS | ctpm | \e void | Receives the number of template-parameters given with the \xl.
139/// String | \b TemplateParaMS | tpm | \e void | Receives the template-parameters given with the \xl.
140/// Integer | \b CountTemplateSpecParaMS| ctspm| \e void | Receives the number of template-specialization-parameters given with the \xl.
141/// String | \b TemplateSpecParaMS | tspm | \e void | Receives the template-specialization-parameters given with the \xl.
142/// Integer | \b ErrorCode | ec | \e void | Returns the #"XLink::Errors;error- and warning code" of the \xl.
143/// Boolean | \b HasError | he | \e void | Returns whether an error occurred during the \xl assembly.
144/// Boolean | \b HasWarning | hw | \e void | Returns whether a warning was encountered during the \xl assembly.
145/// Boolean | \b IsGood | ig | \e void | Returns whether the \xl is uniquely resolved and no warnings or errors have been found.
146/// 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").
147/// 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").
148/// 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").
149/// 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").
150/// 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").
151/// String | \b Display | d | \e void | Returns the assembled display string.
152///
153///
154/// ## Functions On The Resolved Target Node: <br>
155/// Return Type | Name | Min. Abbrev. | Signature | Description
156/// ---------------------|---------------------------| -----|--------------|--------------
157/// Index::Node | \b %Target | t | \e void | Returns the #"Index::Node" of the target-entity.
158/// #"Target::Kind" | \b Kind | k | \e void | Returns the kind of the resolved target entity.
159/// 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.
160/// String | \b Name | n | \e void | Returns the name of the target entity.
161/// String | \b Name | n | Index::Node| Returns the name of the given cursor.
162/// Index::Node | \b Parent | p | \e void | Returns the parent of the target-entity.
163/// Index::Node | \b Parent | p | Index::Node| Returns the parent of the given cursor.
164/// Index::Node | \b Parent | p | Integer | Returns the n-th parent of the target-entity.
165/// 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.
166/// 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>.)
167/// Integer | \b CountParaMS | cpm | Index::Node| Receives the number of function-parameters of the target node. (Pass "Target", like in: <em>"CParams(Target)"</em>.)
168/// String | \b ParaMeterS | pm | Index::Node| Receives the function-parameters of the target node. (Pass "Target", like in: <em>"Params(Target)"</em>.)
169/// Integer | \b CountTemplateParaMS | ctpm | Index::Node| Receives the number of template-parameters of the target node. (Pass "Target", like in: <em>"CTParms(Target)"</em>.)
170/// String | \b TemplateParaMS | tpm | Index::Node| Receives the template-parameters of the target node. (Pass "Target", like in: <em>"TParams(Target)"</em>.)
171/// 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>.)
172/// String | \b TemplateSpecParaMS | tspm | Index::Node| Receives the template-specialization-parameters of the target node. (Pass "Target", like in: <em>"TSParams(Target)"</em>.)
173///
174/// ## Functions Concerning Source-, HTML- and Tag-Files: <br>
175/// Return Type | Name | Min. Abbrev. | Signature | Description
176/// ---------------------|---------------------------| -----|--------------|--------------
177/// 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.
178/// 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.
179/// String | \b TagFilePath | tfp | \e void | Receives the path of the tag file that defined the resolved target.
180/// String | \b TagFilePath | tfp | Index::Node| Receives the path of the tag file that defined the given node.
181/// String | \b TagFileName | tfn | \e void | Receives the file-portion of the path of the tag file that defined the resolved target.
182/// String | \b TagFileName | tfn | Index::Node| Receives the file-portion of the path of the tag file that defined the given node.
183/// Integer | \b TagFileLine | tfl | \e void | Receives the line number in the tag file that defined the resolved target.
184/// Integer | \b TagFileLine | tfl | Index::Node| Receives the line number in the tag file that defined the given node.
185/// String | \b HtmlFile | hf | \e void | Receives the name of the HTML-file that documents the target.
186/// String | \b HtmlFile | hf | Index::Node| Receives the name of the HTML-file that documents the given node.
187/// 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.)
188/// String | \b HtmlAnchor | ha | Index::Node| Receives the anchor within the HTML-file that documents the given node.
189///
191{
192 protected:
193 DXLScope* scope; ///< The scope used with this filter.
194 alib::expressions::Expression expression; ///< The compiled expression.
195
196 public:
197 /// Constructor. Compiles the given expression.
198 /// @param expressionString The expression string.
199 DXLExpression(const alib::String& expressionString );
200
201 /// Destructor.
203
204 /// @return The expression string given with construction (in a normalized fashion!).
205 alib::String GetExpressionString() { return expression->GetNormalizedString(); }
206
207 /// @return The expression string after all optimizations have been performed.
208 alib::String GetOptimizedString() { return expression->GetOptimizedString(); }
209
210 /// @return The result-type of the expression - as a \b Box: that's how \alib_expressions
211 /// represents types!
212 alib::Box ResultType() { return expression->ResultType(); }
213
214 /// @return \c true if the expression evaluates to a constant value (the same result for
215 /// any \xl), \c false otherwise.
216 alib::Box IsConstant() { return expression->IsConstant(); }
217
218 /// The filter method.
219 /// @param xLink The link to evaluate.
220 /// @return The result of the expression when evaluated with the scope of the given \b XLink
221 /// and its search string.
222 bool Includes( XLink* xLink );
223};
224
225} // namespace [dxl]
226
227#endif // HPP_DXL_EXPRESSIONS
228
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