MCPcopy Create free account
hub / github.com/Kitware/VTK / extractFileName

Function extractFileName

IO/EnSight/core/EnSightDataSet.cxx:97–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97bool extractFileName(std::string& line, std::string& filename)
98{
99 // need to handle:
100 // space in the filename, in which case it must be surrounded by quotes
101 // removing trailing whitespace
102 // note we may also have some kind of option present after the filename in line
103 char quotes = '\"';
104 auto quoteBegin = line.find(quotes);
105 if (quoteBegin == std::string::npos)
106 {
107 // no quotes - filename cannot contain spaces, so we can use regex
108 return extractLinePart(GetFileNameRegEx(), line, filename);
109 }
110
111 // we have quotes, we know where the filename starts and ends
112 auto quoteEnd = line.find(quotes, quoteBegin + 1);
113 if (quoteEnd == std::string::npos)
114 {
115 vtkGenericWarningMacro("when extracting filename, unmatched quotes were found");
116 return false;
117 }
118
119 filename = line.substr(quoteBegin + 1, quoteEnd - quoteBegin - 1);
120 line = line.substr(quoteEnd + 1);
121
122 return true;
123}
124
125void sanitize(std::string& str)
126{

Callers 4

ParseGeometrySectionMethod · 0.85
ParseVariableSectionMethod · 0.85
ParseTimeSectionMethod · 0.85

Calls 2

extractLinePartFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected