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

Method PrintCharacterData

Common/DataModel/vtkXMLDataElement.cxx:344–388  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Limits the width of a stream of character data, by inserting new lines and indenting properly.

Source from the content-addressed store, hash-verified

342// Limits the width of a stream of character data,
343// by inserting new lines and indenting properly.
344void vtkXMLDataElement::PrintCharacterData(ostream& os, vtkIndent indent)
345{
346 // anything to do?
347 if (this->CharacterData == nullptr || strcmp(this->CharacterData, "") == 0)
348 {
349 return;
350 }
351 // No special format just dump what we have.
352 if (this->CharacterDataWidth < 1)
353 {
354 os << indent;
355 vtkXMLDataElement::PrintWithEscapedData(os, this->CharacterData);
356 os << endl;
357 }
358 // Treat as space/line delimited fields limiting
359 // the number of field per line.
360 else
361 {
362 istringstream issCharacterData(this->CharacterData);
363
364 string characterDataToken;
365 issCharacterData >> characterDataToken;
366 os << indent;
367 vtkXMLDataElement::PrintWithEscapedData(os, characterDataToken.c_str());
368
369 int it = 0;
370 while (issCharacterData.good())
371 {
372 if ((it % this->CharacterDataWidth) == (this->CharacterDataWidth - 1))
373 {
374 os << endl << indent;
375 }
376 else
377 {
378 os << " ";
379 }
380
381 issCharacterData >> characterDataToken;
382 vtkXMLDataElement::PrintWithEscapedData(os, characterDataToken.c_str());
383 ++it;
384 }
385
386 os << endl;
387 }
388}
389
390//------------------------------------------------------------------------------
391// print out data while replacing XML special characters <, >, &, ", ' with

Callers 1

PrintXMLMethod · 0.95

Calls 2

c_strMethod · 0.45
goodMethod · 0.45

Tested by

no test coverage detected