Cpp.RawStringLiteral Class
Namespace: Cpp
Superclasses: AstNodeProperties
Represents the raw_string_literal nodes in the syntax tree of your code
Since R2026a
Description
The PQL class Cpp.RawStringLiteral represents the node raw_string_literal in the syntax tree of your code.
// example.cpp
#include <iostream>
int main() {
const char* s = R"delim(foo\nbar)delim";
std::cout << s << std::endl;
return 0;
}The code contains a C++ raw string literal R"delim(foo\nbar)delim" which corresponds to the raw_string_literal node that Cpp.RawStringLiteral models.
Predicates
| Type | Raisable | Printable |
|---|---|---|
RawStringLiteral
| 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 RawStringLiteral &rsl)
| Matches a raw_string_literal node and binds it to
rsl. Use this to directly select raw string literal
nodes. | This PQL defect checks for any raw string literal in the translation unit. defect raw_string_found =
when
Cpp.RawStringLiteral.is(&rsl)
and rsl.nodeText(&txt)
raise "Found raw string: {txt}"
on rslIn this C++ code the defect finds the raw string
literal
#include <iostream>
int main() {
const char* s = R"delim(foo\nbar)delim";
(void)s;
return 0;
} |
cast(Cpp.Node.Node node, required RawStringLiteral &cast)
| Checks whether a generic Node is specifically a
raw_string_literal and if so binds it to
cast. Use this when you start from a Node
typed value. | This PQL defect checks for nodes that are raw string literals when
starting from a generic
defect cast_to_raw =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.RawStringLiteral.cast(n, &rsl)
and rsl.nodeText(&txt)
raise "Node cast to RawStringLiteral: {txt}"
on rslIn this C++ code the defect converts a generic node
representing the literal into a
const char* s = R"delim(example)delim";
int main() { (void)s; return 0; } |
isa(Cpp.Node.Node node)
| Returns true when the given generic Node is a
raw_string_literal. Use this for boolean checks or
negation. | This PQL defect checks for defect node_is_raw =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.RawStringLiteral.isa(n)
raise "Node is a RawStringLiteral"
on nIn the C++ example the defect finds that the node
corresponding to the literal
const char* s = R"tag(txt)tag";
int main() { (void)s; return 0; } |
delimiter(RawStringLiteral self, Cpp.Node.Node &child)
| Binds the opening delimiter identifier (the token immediately after
R") of the raw string literal to child. Use
this to inspect the delimiter text. | This PQL defect checks for the opening delimiter portion of a raw string literal. defect check_delim =
when
Cpp.RawStringLiteral.is(&rsl)
and rsl.delimiter(&del)
and del.nodeText(&txt)
raise "Opening delimiter: {txt}"
on delIn the C++ code the defect extracts the opening
delimiter
const char* s = R"delim(foo)delim";
int main() { (void)s; return 0; } |
rawStringDelimiter(RawStringLiteral self, Cpp.Node.Node
&child)
| Binds the closing delimiter identifier of the raw string literal to
child. Use this to verify the closing tag. | This PQL defect checks for the closing delimiter portion of a raw string literal. defect check_closing_delim =
when
Cpp.RawStringLiteral.is(&rsl)
and rsl.rawStringDelimiter(&closing)
and closing.nodeText(&txt)
raise "Closing delimiter: {txt}"
on closingIn the C++ example the defect reports the
trailing delimiter
const char* s = R"delim(foo)delim";
int main() { (void)s; return 0; } |
rawStringContent(RawStringLiteral self, Cpp.Node.Node &child)
| Binds the content portion between the parentheses of the raw string literal to
child. Use this to inspect the literal payload. | This PQL defect checks for the content inside a raw string literal. defect check_content =
when
Cpp.RawStringLiteral.is(&rsl)
and rsl.rawStringContent(&content)
and content.nodeText(&txt)
raise "Raw string content: {txt}"
on contentIn the C++ code the defect extracts the content
#include <iostream>
int main() {
const char* s = R"delim(foo\nbar)delim";
(void)s;
return 0;
} |
getEnclosingRawStringLiteral(Cpp.Node.Node child, required RawStringLiteral
&parent)
| Finds the nearest ancestor raw_string_literal node that
encloses the given child node and binds it to
parent. Use this to map inner tokens back to their raw string
literal. | This PQL defect checks for nodes enclosed inside a raw string literal and reports the enclosing literal. defect enclosing_raw =
when
Cpp.Node.is(&inner, &,&,&)
and Cpp.RawStringLiteral.getEnclosingRawStringLiteral(inner, &rsl)
and rsl.nodeText(&txt)
raise "Enclosing raw string: {txt}"
on rslIn the C++ example the defect starts from a token
that is part of the literal content and finds the surrounding raw string literal
const char* s = R"delim(foo)delim"; // 'foo' tokens are enclosed in the raw string literal
int main() { (void)s; return 0; } |
isEnclosedInRawStringLiteral(Cpp.Node.Node child)
| Returns true when the given child node has any
raw_string_literal ancestor. Use this to filter nodes that lie
inside raw string literals. | This PQL defect checks whether a given node resides inside a raw string literal. defect inside_raw_check =
when
Cpp.Node.is(&n, &,&,&)
and Cpp.RawStringLiteral.isEnclosedInRawStringLiteral(n)
raise "Node is inside a raw string literal"
on nIn the C++ code the defect detects that tokens
corresponding to the characters
const char* s = R"delim(foo)delim";
int main() { (void)s; 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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)