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

Function ParseSOSFile

IO/EnSight/vtkEnSightSOSGoldReader.cxx:226–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224 }
225
226 bool ParseSOSFile(const char* filename)
227 {
228 this->CaseFileNames.clear();
229 if (!this->SOSFile.SetFileNamePattern(filename, true))
230 {
231 vtkGenericWarningMacro("SOS file " << filename << " could not be opened");
232 return false;
233 }
234 this->FilePath = vtksys::SystemTools::GetParentDirectory(filename);
235
236 bool foundServersSection = false;
237 int numServers = 0;
238
239 auto result = this->SOSFile.ReadNextLine();
240 while (result.first)
241 {
242 std::string& line = result.second;
243 if (line.find("FORMAT") != std::string::npos)
244 {
245 // nothing to do here
246 }
247 else if (line.find("type") != std::string::npos)
248 {
249 if (line.find("master_server") == std::string::npos ||
250 line.find("gold") == std::string::npos)
251 {
252 vtkGenericWarningMacro("vtkEnSightSOSGoldReader only reads SOS files for Gold format");
253 return false;
254 }
255 }
256 else if (line.find("SERVERS") != std::string::npos)
257 {
258 foundServersSection = true;
259 }
260 else if (foundServersSection && line.find("number of servers") != std::string::npos)
261 {
262 auto pos = line.find(':');
263 auto value = line.substr(pos + 1);
264 sanitize(value);
265 VTK_FROM_CHARS_IF_ERROR_RETURN(value, numServers, false);
266 }
267 else if (foundServersSection && line.find("casefile") != std::string::npos)
268 {
269 auto lineParts = vtksys::SystemTools::SplitString(result.second, ':');
270 if (lineParts.size() != 2)
271 {
272 vtkGenericWarningMacro("line " << result.second << " could not be read properly");
273 return false;
274 }
275 sanitize(lineParts[1]);
276 this->CaseFileNames.push_back(lineParts[1]);
277 }
278 result = this->SOSFile.ReadNextLine();
279 }
280
281 if (this->CaseFileNames.size() != static_cast<size_t>(numServers))
282 {
283 vtkGenericWarningMacro(

Callers

nothing calls this directly

Calls 8

SplitStringFunction · 0.85
SetFileNamePatternMethod · 0.80
ReadNextLineMethod · 0.80
sanitizeFunction · 0.70
clearMethod · 0.45
findMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected