MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / SerializePrettyRDFSchema

Function SerializePrettyRDFSchema

xmpsdk/src/XMPMeta-Serialize.cpp:589–666  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

587// </rdf:Description>
588
589static void
590SerializePrettyRDFSchema ( const XMP_VarString & treeName,
591 const XMP_Node * schemaNode,
592 XMP_VarString & outputStr,
593 XMP_OptionBits options,
594 XMP_StringPtr newline,
595 XMP_StringPtr indentStr,
596 XMP_Index baseIndent )
597{
598 XMP_Assert ( schemaNode->options & kXMP_SchemaNode );
599 XMP_Assert ( schemaNode->qualifiers.empty() );
600
601 // Write the rdf:Description start tag with the namespace declarations.
602
603 XMP_Index level;
604 for ( level = baseIndent+2; level > 0; --level ) outputStr += indentStr;
605 outputStr += kRDF_SchemaStart;
606 outputStr += '"';
607 outputStr += treeName;
608 outputStr += '"';
609
610 size_t totalLen = 8; // Start at 8 for "xml:rdf:".
611 XMP_cStringMapPos currPos = sNamespacePrefixToURIMap->begin();
612 XMP_cStringMapPos endPos = sNamespacePrefixToURIMap->end();
613 for ( ; currPos != endPos; ++currPos ) totalLen += currPos->first.size();
614
615 XMP_VarString usedNS;
616 usedNS.reserve ( totalLen );
617 usedNS = "xml:rdf:";
618 DeclareUsedNamespaces ( schemaNode, usedNS, outputStr, newline, indentStr, baseIndent+4 );
619
620 outputStr += ">";
621 outputStr += newline;
622
623 // Write alias comments, if wanted.
624
625 if ( options & kXMP_WriteAliasComments ) { // *** Hoist into a routine, used for Plain XMP also.
626
627 #if 0 // *** Buggy, disable for now.
628
629 XMP_cAliasMapPos aliasPos = sRegisteredAliasMap->begin();
630 XMP_cAliasMapPos aliasEnd = sRegisteredAliasMap->end();
631
632 for ( ; aliasPos != aliasEnd; ++aliasPos ) {
633
634 size_t nsPos = aliasPos->first.find ( schemaNode->value );
635 if ( nsPos == XMP_VarString::npos ) continue;
636 XMP_Assert ( nsPos == 0 );
637
638 for ( level = baseIndent+3; level > 0; --level ) outputStr += indentStr;
639
640 outputStr += "<!-- ";
641 outputStr += aliasPos->first;
642 outputStr += " is aliased to ";
643 for ( size_t step = 1, stepLim = aliasPos->second.size(); step != stepLim; ++step ) {
644 outputStr += aliasPos->second[step].step;
645 }
646 outputStr += " -->";

Callers 1

SerializeAsRDFFunction · 0.85

Calls 7

DeclareUsedNamespacesFunction · 0.85
reserveMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected