Ast.PreprocInclude Class
Namespace: Ast
Superclasses: AstNodeProperties
Represents the preproc_include nodes in the syntax tree of your code
Since R2026a
Description
The PQL class Cpp.PreprocInclude represents the node preproc_include in the syntax tree of your code.
#include <iostream>
#include "myheader.h"
#define AN_INCLUDE "<cstdint>"
#include AN_INCLUDE
int main() {
std::cout << "hello\n";
return 0;
}The three #include lines generate preproc_include nodes in the tree. Each directive in the demo corresponds to a Cpp.PreprocInclude node.
Predicates
| Type | Raisable | Printable |
|---|---|---|
PreprocInclude
| Yes | No |
This class defines these predicates that act on the objects of this class. In addition, objects of this class can access the predicates defined by the base class AstNodeProperties. An object of this class is an object of AstNodeProperties class.
| Predicates | Description | Example |
|---|---|---|
is(required PreprocInclude &include)
| Matches a preproc_include node and returns it as
include so you can inspect it. | This PQL defect checks for any defect includeFound =
when
Cpp.PreprocInclude.is(&inc)
and inc.nodeText(&txt)
raise "Found include: \"{txt}\""
on incIn this C++ code the defect finds each
#include <iostream>
#include "myheader.h"
int main() { return 0; } |
cast(Cpp.Node.Node node, required PreprocInclude &cast)
| Checks whether a Cpp.Node.Node is a
preproc_include and if so returns it as a
PreprocInclude. | This PQL defect checks for nodes that can be converted to
defect includeViaNode =
when
Cpp.Node.is(&n,&,&,&)
and Cpp.PreprocInclude.cast(n, &cast)
and cast.path(&p)
and p.nodeText(&txt)
raise "Cast to PreprocInclude matched path: \"{txt}\""
on castIn this C++ code the defect finds
a
#include "myheader.h"
int main() { return 0; } |
isa(Cpp.Node.Node node)
| Returns true when the given Cpp.Node.Node is a
preproc_include. Useful for negation or guards. | This PQL defect checks whether a generic node is a
defect notInclude =
when
Cpp.Node.is(&n,&,&,&)
and not Cpp.PreprocInclude.isa(n)
raise "Node is not a PreprocInclude"
on nIn this C++ code the defect reports all nodes that
are not
#include <iostream>
int main() { return 0; } |
path(PreprocInclude self, Cpp.Node.Node &child)
| Finds the path inside the include and returns it as
child. | This PQL defect checks for the string or token that represents the
include path inside a
defect includePathNode =
when
Cpp.PreprocInclude.is(&inc)
and inc.path(&p)
and p.nodeText(&txt)
raise "Include path node text: \"{txt}\""
on pIn this C++ code the defect extracts the
#include "myheader.h"
int main() { return 0; } |
isSystemInclude(PreprocInclude self)
| Returns true when the include uses angle brackets (system header) such as
<...>. | This PQL defect checks for system style defect systemInclude =
when
Cpp.PreprocInclude.is(&inc)
and inc.isSystemInclude()
and inc.pathString(&f)
and f == "iostream"
raise "System include: \"{f}\""
on incIn this C++ code the defect finds the
#include <iostream>
int main() { return 0; } |
isUserInclude(PreprocInclude self)
| Returns true when the include uses double quotes (user header) such as "..." . | This PQL defect checks for user style defect userInclude =
when
Cpp.PreprocInclude.is(&inc)
and inc.isUserInclude()
and inc.pathString(&f)
and f == "myheader.h"
raise "User include: \"{f}\""
on incIn this C++ code the defect finds the
#include "myheader.h"
int main() { return 0; } |
pathString(PreprocInclude self, required Lang.String &file)
| Extracts the include file name as a plain string without surrounding
<> or "". | This PQL defect checks the normalized include name for comparison or filtering. defect includeNameCheck =
when
Cpp.PreprocInclude.is(&inc)
and inc.pathString(&name)
and name == "cstdint"
raise "Include name is cstdint"
on incIn this C++ code the defect will match a
#include <cstdint>
int main() { return 0; } |
Version History
Introduced in R2026a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)