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

Function AddNodeOffspring

xmpsdk/src/XMPIterator.cpp:112–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110// Add the immediate children and qualifiers to an IterNode.
111
112static void
113AddNodeOffspring ( IterInfo & info, IterNode & iterParent, const XMP_Node * xmpParent )
114{
115 XMP_VarString currPath ( iterParent.fullPath );
116 size_t leafOffset = iterParent.fullPath.size();
117
118 if ( (! xmpParent->qualifiers.empty()) && (! (info.options & kXMP_IterOmitQualifiers)) ) {
119
120 #if TraceIterators
121 printf ( " Adding qualifiers of %s\n", currPath.c_str() );
122 #endif
123
124 currPath += "/?"; // All qualifiers are named and use paths like "Prop/?Qual".
125 leafOffset += 2;
126
127 for ( size_t qualNum = 0, qualLim = xmpParent->qualifiers.size(); qualNum != qualLim; ++qualNum ) {
128 const XMP_Node * xmpQual = xmpParent->qualifiers[qualNum];
129 currPath += xmpQual->name;
130 iterParent.qualifiers.push_back ( IterNode ( xmpQual->options, currPath, leafOffset ) );
131 currPath.erase ( leafOffset );
132 #if TraceIterators
133 printf ( " %s\n", xmpQual->name.c_str() );
134 #endif
135 }
136
137 leafOffset -= 2;
138 currPath.erase ( leafOffset );
139
140 }
141
142 if ( ! xmpParent->children.empty() ) {
143
144 #if TraceIterators
145 printf ( " Adding children of %s\n", currPath.c_str() );
146 #endif
147
148 XMP_Assert ( xmpParent->options & kXMP_PropCompositeMask );
149
150 if ( xmpParent->options & kXMP_PropValueIsStruct ) {
151 currPath += '/';
152 leafOffset += 1;
153 }
154
155 for ( size_t childNum = 0, childLim = xmpParent->children.size(); childNum != childLim; ++childNum ) {
156 const XMP_Node * xmpChild = xmpParent->children[childNum];
157 if ( ! (xmpParent->options & kXMP_PropValueIsArray) ) {
158 currPath += xmpChild->name;
159 } else {
160 char buffer [32]; // AUDIT: Using sizeof(buffer) below for snprintf length is safe.
161 snprintf ( buffer, sizeof(buffer), "[%lu]", static_cast<unsigned long>(childNum+1) ); // ! XPath indices are one-based.
162 currPath += buffer;
163 }
164 iterParent.children.push_back ( IterNode ( xmpChild->options, currPath, leafOffset ) );
165 currPath.erase ( leafOffset );
166 #if TraceIterators
167 printf ( " %s\n", (iterParent.children.back().fullPath.c_str() + leafOffset) );
168 #endif
169 }

Callers 2

GetNextXMPNodeFunction · 0.85
XMPIteratorMethod · 0.85

Calls 5

IterNodeClass · 0.85
c_strMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected