Geant4-11
Public Member Functions | Private Attributes
G4PhysicalVolumesSearchScene::Matcher Class Reference

Public Member Functions

G4bool Match (const G4String &)
 
 Matcher (const G4String &requiredMatch)
 

Private Attributes

G4bool fRegexFlag
 
G4String fRequiredMatch
 

Detailed Description

Definition at line 96 of file G4PhysicalVolumesSearchScene.hh.

Constructor & Destructor Documentation

◆ Matcher()

G4PhysicalVolumesSearchScene::Matcher::Matcher ( const G4String requiredMatch)

Definition at line 85 of file G4PhysicalVolumesSearchScene.cc.

86: fRegexFlag(false)
87{
88 if (requiredMatch.size()) {
89 size_t last = requiredMatch.size() - 1;
90 // If required name begins and ends with '/', treat as a regular expression.
91 // 0 causes a conversion ambiguity that upsets the Windows compiler, so use 0U.
92 if (requiredMatch[0U] == '/' && requiredMatch[last] == '/') {
93 if (last > 1) { // Non-null regexp
94 // regex match required
95 fRegexFlag = true;
96 // Extract the required regex
97 fRequiredMatch = requiredMatch.substr(1,last-1);
98 }
99 } else {
100 // Exact match required
101 fRequiredMatch = requiredMatch;
102 }
103 }
104 if (fRequiredMatch.empty()) {
106 ("G4PhysicalVolumesSearchScene::Matcher::Matcher",
107 "modeling0013", JustWarning, "Required match is null");
108 }
109}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35

References fRegexFlag, fRequiredMatch, G4Exception(), and JustWarning.

Member Function Documentation

◆ Match()

G4bool G4PhysicalVolumesSearchScene::Matcher::Match ( const G4String s)

Definition at line 111 of file G4PhysicalVolumesSearchScene.cc.

115{
116 G4bool found = false;
117 if (fRequiredMatch.size()) {
118 if (fRegexFlag) { // Use extracted regex
119 std::regex requiredRegex(fRequiredMatch);
120 std::cmatch match;
121 std::regex_search(s.c_str(), match, requiredRegex);
122 if (match.size() > 0) found = true;
123 } else { // Require complete match
124 if (s == fRequiredMatch) found = true;
125 }
126 }
127 return found;
128}
static constexpr double s
Definition: G4SIunits.hh:154
bool G4bool
Definition: G4Types.hh:86

References s.

Referenced by G4PhysicalVolumesSearchScene::ProcessVolume().

Field Documentation

◆ fRegexFlag

G4bool G4PhysicalVolumesSearchScene::Matcher::fRegexFlag
private

Definition at line 104 of file G4PhysicalVolumesSearchScene.hh.

Referenced by Matcher().

◆ fRequiredMatch

G4String G4PhysicalVolumesSearchScene::Matcher::fRequiredMatch
private

Definition at line 105 of file G4PhysicalVolumesSearchScene.hh.

Referenced by Matcher().


The documentation for this class was generated from the following files: