<div class="line"> <span class="comment">// The XMP property container</span></div>
<div class="line"> <a name="_a0"></a><a class="code" href="doc/classExiv2_1_1XmpData.html" title="A container for XMP data. This is a top-level class of the Exiv2 library.">Exiv2::XmpData</a> xmpData;</div>
<div class="line"> <span class="comment">// In addition, there is a dedicated assignment operator for Exiv2::Value</span></div>
<div class="line"> <a name="_a2"></a><a class="code" href="doc/classExiv2_1_1XmpTextValue.html" title="Value type suitable for simple XMP properties and XMP nodes of complex types which are not parsed int...">Exiv2::XmpTextValue</a> val(<span class="stringliteral">"Seven"</span>);</div>
<div class="line"> <span class="keyword">const</span> <a name="_a3"></a><a class="code" href="doc/classExiv2_1_1Value.html" title="Common interface for all types of values used with metadata.">Exiv2::Value</a> &getv1 = xmpData[<span class="stringliteral">"Xmp.dc.one"</span>].value();</div>
<div class="line"> assert(isEqual(getv1.<a name="a4"></a><a class="code" href="doc/classExiv2_1_1Value.html#a22d257caa6c1ffe6416ce02de7bd8c1c" title="Convert the n-th component of the value to a float. The behaviour of this method may be undefined if ...">toFloat</a>(), -1)); </div>
<div class="line"> assert(getv1.<a name="a5"></a><a class="code" href="doc/classExiv2_1_1Value.html#a161550b3ef31b3a14b1d75149ba9ba71" title="Check the ok status indicator. After a to<Type> conversion, this indicator shows whether the conversi...">ok</a>());</div>
<div class="line"> assert(getv1.<a name="a6"></a><a class="code" href="doc/classExiv2_1_1Value.html#a595a4cb549bec8c19d290ca3e95a2678" title="Convert the n-th component of the value to a Rational. The behaviour of this method may be undefined ...">toRational</a>() == <a class="code" href="doc/namespaceExiv2.html#a95756f3f7fa19103f83addf5fa088a30" title="8 byte signed rational type.">Exiv2::Rational</a>(-1, 1));</div>
<div class="line"> assert(getv1.<a class="code" href="doc/classExiv2_1_1Value.html#a161550b3ef31b3a14b1d75149ba9ba71" title="Check the ok status indicator. After a to<Type> conversion, this indicator shows whether the conversi...">ok</a>());</div>
<div class="line"></div>
<div class="line"> <span class="keyword">const</span> <a class="code" href="doc/classExiv2_1_1Value.html" title="Common interface for all types of values used with metadata.">Exiv2::Value</a> &getv2 = xmpData[<span class="stringliteral">"Xmp.dc.two"</span>].value();</div>
<div class="line"> <span class="keyword">const</span> <a class="code" href="doc/classExiv2_1_1Value.html" title="Common interface for all types of values used with metadata.">Exiv2::Value</a> &getv3 = xmpData[<span class="stringliteral">"Xmp.dc.three"</span>].value();</div>
<div class="line"> assert(isEqual(getv3.<a class="code" href="doc/classExiv2_1_1Value.html#a22d257caa6c1ffe6416ce02de7bd8c1c" title="Convert the n-th component of the value to a float. The behaviour of this method may be undefined if ...">toFloat</a>(), 5.0f/7.0f)); </div>
<div class="line"> assert(getv3.<a class="code" href="doc/classExiv2_1_1Value.html#a161550b3ef31b3a14b1d75149ba9ba71" title="Check the ok status indicator. After a to<Type> conversion, this indicator shows whether the conversi...">ok</a>());</div>
<div class="line"> assert(getv3.<a name="a7"></a><a class="code" href="doc/classExiv2_1_1Value.html#a4530a3fc3e2305cf994de5476f46f953" title="Convert the n-th component of the value to a long. The behaviour of this method may be undefined if t...">toLong</a>() == 0); <span class="comment">// long(5.0 / 7.0) </span></div>
<div class="line"> assert(getv3.<a class="code" href="doc/classExiv2_1_1Value.html#a161550b3ef31b3a14b1d75149ba9ba71" title="Check the ok status indicator. After a to<Type> conversion, this indicator shows whether the conversi...">ok</a>());</div>
<div class="line"> assert(getv3.<a class="code" href="doc/classExiv2_1_1Value.html#a595a4cb549bec8c19d290ca3e95a2678" title="Convert the n-th component of the value to a Rational. The behaviour of this method may be undefined ...">toRational</a>() == <a class="code" href="doc/namespaceExiv2.html#a95756f3f7fa19103f83addf5fa088a30" title="8 byte signed rational type.">Exiv2::Rational</a>(5, 7));</div>
<div class="line"> assert(getv3.<a class="code" href="doc/classExiv2_1_1Value.html#a161550b3ef31b3a14b1d75149ba9ba71" title="Check the ok status indicator. After a to<Type> conversion, this indicator shows whether the conversi...">ok</a>());</div>
<div class="line"> </div>
<div class="line"> <span class="keyword">const</span> <a class="code" href="doc/classExiv2_1_1Value.html" title="Common interface for all types of values used with metadata.">Exiv2::Value</a> &getv6 = xmpData[<span class="stringliteral">"Xmp.dc.six"</span>].value();</div>
<div class="line"> <span class="keyword">const</span> <a class="code" href="doc/classExiv2_1_1Value.html" title="Common interface for all types of values used with metadata.">Exiv2::Value</a> &getv7 = xmpData[<span class="stringliteral">"Xmp.dc.seven"</span>].value();</div>
<div class="line"> getv7.toLong(); <span class="comment">// this should fail</span></div>
<div class="line"> assert(!getv7.ok()); </div>
<div class="line"></div>
<div class="line"> <span class="keyword">const</span> <a class="code" href="doc/classExiv2_1_1Value.html" title="Common interface for all types of values used with metadata.">Exiv2::Value</a> &getv8 = xmpData[<span class="stringliteral">"Xmp.dc.eight"</span>].value();</div>
<div class="line"> <span class="comment">// Deleting an XMP property</span></div>
<div class="line"> <a class="code" href="doc/classExiv2_1_1XmpData.html#a6ad054efbea675843895e3f74c3c1923" title="XmpMetadata iterator type.">Exiv2::XmpData::iterator</a> pos = xmpData.<a name="a8"></a><a class="code" href="doc/classExiv2_1_1XmpData.html#af4d4e63ed5641dbc6e211b880f6d0990" title="Find the first Xmpdatum with the given key, return an iterator to it.">findKey</a>(<a name="_a9"></a><a class="code" href="doc/classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.dc.eight"</span>));</div>
<div class="line"> <span class="keywordflow">if</span> (pos == xmpData.<a name="a10"></a><a class="code" href="doc/classExiv2_1_1XmpData.html#a1db4d5a92a7ec0694da08a7dee58faac" title="End of the metadata.">end</a>()) <span class="keywordflow">throw</span> <a name="_a11"></a><a class="code" href="doc/classExiv2_1_1BasicError.html" title="Simple error class used for exceptions. An output operator is provided to print errors to a stream...">Exiv2::Error</a>(1, <span class="stringliteral">"Key not found"</span>);</div>
<div class="line"> xmpData.<a name="a12"></a><a class="code" href="doc/classExiv2_1_1XmpData.html#aa608042a71623e7dac640c135cb768e6" title="Delete the Xmpdatum at iterator position pos, return the position of the next Xmpdatum.">erase</a>(pos);</div>
<div class="line"> <span class="comment">// Exiv2 has specialized values for simple XMP properties, arrays of simple</span></div>
<div class="line"> <span class="comment">// properties and language alternatives.</span></div>
<div class="line"></div>
<div class="line"> <span class="comment">// Add a simple XMP property in a known namespace </span></div>
<div class="line"> <a class="code" href="doc/classExiv2_1_1Value.html#a0f62e585b82c97738858b743e60dff21" title="Shortcut for a Value auto pointer.">Exiv2::Value::AutoPtr</a> v = <a name="a13"></a><a class="code" href="doc/classExiv2_1_1Value.html#ad6ff043921cd1a5c399a9a4fc8257006" title="A (simple) factory to create a Value type.">Exiv2::Value::create</a>(<a name="a14"></a><a class="code" href="doc/namespaceExiv2.html#a5153319711f35fe81cbc13f4b852450ca77cea60f60ef2c6f0f986137c5404c02" title="XMP text type.">Exiv2::xmpText</a>);</div>
<div class="line"> xmpData.<a name="a15"></a><a class="code" href="doc/classExiv2_1_1XmpData.html#a8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value...">add</a>(<a class="code" href="doc/classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.dc.format"</span>), v.get());</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Add an ordered array of text values.</span></div>
<div class="line"> v = <a class="code" href="doc/classExiv2_1_1Value.html#ad6ff043921cd1a5c399a9a4fc8257006" title="A (simple) factory to create a Value type.">Exiv2::Value::create</a>(<a name="a16"></a><a class="code" href="doc/namespaceExiv2.html#a5153319711f35fe81cbc13f4b852450ca969c20e44455272599e3a273471546e8" title="XMP sequence type.">Exiv2::xmpSeq</a>); <span class="comment">// or xmpBag or xmpAlt.</span></div>
<div class="line"> v->read(<span class="stringliteral">"1) The first creator"</span>); <span class="comment">// The sequence in which the array</span></div>
<div class="line"> v->read(<span class="stringliteral">"2) The second creator"</span>); <span class="comment">// elements are added is their</span></div>
<div class="line"> v->read(<span class="stringliteral">"3) And another one"</span>); <span class="comment">// order in the array.</span></div>
<div class="line"> xmpData.<a class="code" href="doc/classExiv2_1_1XmpData.html#a8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value...">add</a>(<a class="code" href="doc/classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.dc.creator"</span>), v.get());</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Add a language alternative property</span></div>
<div class="line"> v = <a class="code" href="doc/classExiv2_1_1Value.html#ad6ff043921cd1a5c399a9a4fc8257006" title="A (simple) factory to create a Value type.">Exiv2::Value::create</a>(<a name="a17"></a><a class="code" href="doc/namespaceExiv2.html#a5153319711f35fe81cbc13f4b852450ca52dce1d022dd8927bc651d2e51dc1bcd" title="XMP language alternative type.">Exiv2::langAlt</a>);</div>
<div class="line"> v->read(<span class="stringliteral">"lang=de-DE Hallo, Welt"</span>); <span class="comment">// The default doesn't need a </span></div>
<div class="line"> xmpData.<a class="code" href="doc/classExiv2_1_1XmpData.html#a8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value...">add</a>(<a class="code" href="doc/classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.dc.description"</span>), v.get());</div>
<div class="line"></div>
<div class="line"> <span class="comment">// According to the XMP specification, Xmp.tiff.ImageDescription is an</span></div>
<div class="line"> <span class="comment">// alias for Xmp.dc.description. Exiv2 treats an alias just like any</span></div>
<div class="line"> <span class="comment">// other property and leaves it to the application to implement specific</span></div>
<div class="line"> <span class="comment">// behaviour if desired.</span></div>
<div class="line"> <span class="comment">// There are no specialized values for structures, qualifiers and nested</span></div>
<div class="line"> <span class="comment">// types. However, these can be added by using an XmpTextValue and a path as</span></div>
<div class="line"> <span class="comment">// the key.</span></div>
<div class="line"></div>
<div class="line"> <span class="comment">// Add a structure</span></div>
<div class="line"> <a class="code" href="doc/classExiv2_1_1XmpTextValue.html" title="Value type suitable for simple XMP properties and XMP nodes of complex types which are not parsed int...">Exiv2::XmpTextValue</a> tv(<span class="stringliteral">"16"</span>);</div>
<div class="line"> xmpData.<a class="code" href="doc/classExiv2_1_1XmpData.html#a8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value...">add</a>(<a class="code" href="doc/classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpDM.videoFrameSize/stDim:w"</span>), &tv);</div>
<div class="line"> xmpData.<a class="code" href="doc/classExiv2_1_1XmpData.html#a8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value...">add</a>(<a class="code" href="doc/classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpDM.videoFrameSize/stDim:h"</span>), &tv);</div>
<div class="line"> xmpData.<a class="code" href="doc/classExiv2_1_1XmpData.html#a8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value...">add</a>(<a class="code" href="doc/classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpDM.videoFrameSize/stDim:unit"</span>), &tv);</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Add an element with a qualifier (using the namespace registered above)</span></div>
<div class="line"> xmpData.<a class="code" href="doc/classExiv2_1_1XmpData.html#a8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value...">add</a>(<a class="code" href="doc/classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.dc.creator[2]/?ns:role"</span>), &tv);</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Add an array of structures</span></div>
<div class="line"> tv.read(<span class="stringliteral">""</span>); <span class="comment">// Clear the value</span></div>
<div class="line"> xmpData.<a class="code" href="doc/classExiv2_1_1XmpData.html#a8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value...">add</a>(<a class="code" href="doc/classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpBJ.JobRef"</span>), &tv); <span class="comment">// Set the array type.</span></div>
<div class="line"> xmpData.<a class="code" href="doc/classExiv2_1_1XmpData.html#a8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value...">add</a>(<a class="code" href="doc/classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpBJ.JobRef[1]/stJob:name"</span>), &tv);</div>
<div class="line"> xmpData.<a class="code" href="doc/classExiv2_1_1XmpData.html#a8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value...">add</a>(<a class="code" href="doc/classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpBJ.JobRef[1]/stJob:role"</span>), &tv);</div>
<div class="line"> xmpData.<a class="code" href="doc/classExiv2_1_1XmpData.html#a8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value...">add</a>(<a class="code" href="doc/classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpBJ.JobRef[2]/stJob:name"</span>), &tv);</div>
<div class="line"> xmpData.<a class="code" href="doc/classExiv2_1_1XmpData.html#a8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones) the value...">add</a>(<a class="code" href="doc/classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpBJ.JobRef[2]/stJob:role"</span>), &tv);</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Add a creator contact info structure</span></div>
<div class="line"> <span class="keywordflow">if</span> (0 != <a name="a22"></a><a class="code" href="doc/classExiv2_1_1XmpParser.html#afad88c80404f9f35b687b33fe9ea9c63" title="Encode (serialize) XMP metadata from xmpData into a string xmpPacket. The XMP packet returned in the ...">Exiv2::XmpParser::encode</a>(xmpPacket, xmpData)) {</div>
<div class="line"> <span class="keywordflow">throw</span> <a name="a23"></a><a class="code" href="doc/namespaceExiv2.html#accd3e49cafe9db52c1e0e6f648753cae" title="Error class used for exceptions (std::string based)">Exiv2::Error</a>(1, <span class="stringliteral">"Failed to serialize XMP data"</span>);</div>
<div class="line"><span class="keywordflow">catch</span> (<a name="_a25"></a><a class="code" href="doc/classExiv2_1_1AnyError.html" title="Error class interface. Allows the definition and use of a hierarchy of error classes which can all be...">Exiv2::AnyError</a>& e) {</div>