| 95 | } |
| 96 | |
| 97 | bool 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 | |
| 125 | void sanitize(std::string& str) |
| 126 | { |
no test coverage detected