MCPcopy Create free account
hub / github.com/PDAL/PDAL / writeXml

Method writeXml

plugins/e57/libE57Format/src/StructureNodeImpl.cpp:381–450  ·  view source on GitHub ↗

??? use visitor?

Source from the content-addressed store, hash-verified

379
380//??? use visitor?
381void StructureNodeImpl::writeXml( ImageFileImplSharedPtr imf, CheckedFile &cf, int indent,
382 const char *forcedFieldName )
383{
384 // don't checkImageFileOpen
385
386 ustring fieldName;
387 if ( forcedFieldName != nullptr )
388 {
389 fieldName = forcedFieldName;
390 }
391 else
392 {
393 fieldName = elementName_;
394 }
395
396 cf << space( indent ) << "<" << fieldName << " type=\"Structure\"";
397
398 const int numSpaces = indent + static_cast<int>( fieldName.length() ) + 2;
399
400 // If this struct is the root for the E57 file, add name space declarations. Note the prototype
401 // of a CompressedVector is a separate tree, so don't want to write out namespaces if not the
402 // ImageFile root
403 if ( isRoot() && shared_from_this() == imf->root() )
404 {
405 bool gotDefaultNamespace = false;
406 for ( size_t i = 0; i < imf->extensionsCount(); i++ )
407 {
408 const char *xmlnsExtension;
409 if ( imf->extensionsPrefix( i ).empty() )
410 {
411 gotDefaultNamespace = true;
412 xmlnsExtension = "xmlns";
413 }
414 else
415 {
416 xmlnsExtension = "xmlns:";
417 }
418
419 const int index = static_cast<int>( i );
420
421 cf << "\n"
422 << space( numSpaces ) << xmlnsExtension << imf->extensionsPrefix( index ) << "=\""
423 << imf->extensionsUri( index ) << "\"";
424 }
425
426 // If user didn't explicitly declare a default namespace, use the current E57 standard one.
427 if ( !gotDefaultNamespace )
428 {
429 cf << "\n" << space( numSpaces ) << "xmlns=\"" << VERSION_1_0_URI << "\"";
430 }
431 }
432 if ( !children_.empty() )
433 {
434 cf << ">\n";
435
436 // Write all children nested inside Structure element
437 for ( auto &child : children_ )
438 {

Callers

nothing calls this directly

Calls 7

spaceFunction · 0.85
lengthMethod · 0.45
rootMethod · 0.45
extensionsCountMethod · 0.45
emptyMethod · 0.45
extensionsPrefixMethod · 0.45
extensionsUriMethod · 0.45

Tested by

no test coverage detected