<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Exiv2: xmpsample.cpp</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.9 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li><a href="files.html"><span>Files</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> <li> <form action="search.php" method="get"> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td><label> <u>S</u>earch for </label></td> <td><input type="text" name="query" value="" size="20" accesskey="s"/></td> </tr> </table> </form> </li> </ul> </div> </div> <div class="contents"> <h1>xmpsample.cpp</h1>Sample usage of high-level XMP classes.<p> <div class="fragment"><pre class="fragment"><span class="comment">// ***************************************************************** -*- C++ -*-</span> <span class="comment">// xmpsample.cpp, $Rev: 1479 $</span> <span class="comment">// Sample/test for high level XMP classes. See also addmoddel.cpp</span> <span class="preprocessor">#include <exiv2/xmp.hpp></span> <span class="preprocessor">#include <exiv2/error.hpp></span> <span class="preprocessor">#include <string></span> <span class="preprocessor">#include <iostream></span> <span class="preprocessor">#include <iomanip></span> <span class="preprocessor">#include <cassert></span> <span class="preprocessor">#include <cmath></span> <span class="keywordtype">bool</span> isEqual(<span class="keywordtype">float</span> a, <span class="keywordtype">float</span> b) { <span class="keywordtype">double</span> d = std::fabs(a - b); <span class="keywordflow">return</span> d < 0.00001; } <span class="keywordtype">int</span> main() <span class="keyword">try</span> { <span class="comment">// The XMP property container</span> <a name="_a0"></a><a class="code" href="classExiv2_1_1XmpData.html" title="A container for XMP data. This is a top-level class of the Exiv2 library.">Exiv2::XmpData</a> xmpData; <span class="comment">// -------------------------------------------------------------------------</span> <span class="comment">// Teaser: Setting XMP properties doesn't get much easier than this:</span> xmpData[<span class="stringliteral">"Xmp.dc.source"</span>] = <span class="stringliteral">"xmpsample.cpp"</span>; <span class="comment">// a simple text value</span> xmpData[<span class="stringliteral">"Xmp.dc.subject"</span>] = <span class="stringliteral">"Palmtree"</span>; <span class="comment">// an array item</span> xmpData[<span class="stringliteral">"Xmp.dc.subject"</span>] = <span class="stringliteral">"Rubbertree"</span>; <span class="comment">// add a 2nd array item</span> <span class="comment">// a language alternative with two entries and without default</span> xmpData[<span class="stringliteral">"Xmp.dc.title"</span>] = <span class="stringliteral">"lang=de-DE Sonnenuntergang am Strand"</span>; xmpData[<span class="stringliteral">"Xmp.dc.title"</span>] = <span class="stringliteral">"lang=en-US Sunset on the beach"</span>; <span class="comment">// -------------------------------------------------------------------------</span> <span class="comment">// Any properties can be set provided the namespace is known. Values of any</span> <span class="comment">// type can be assigned to an Xmpdatum, if they have an output operator. The</span> <span class="comment">// default XMP value type for unknown properties is a simple text value.</span> xmpData[<span class="stringliteral">"Xmp.dc.one"</span>] = -1; xmpData[<span class="stringliteral">"Xmp.dc.two"</span>] = 3.1415; xmpData[<span class="stringliteral">"Xmp.dc.three"</span>] = <a name="a1"></a><a class="code" href="namespaceExiv2.html#95756f3f7fa19103f83addf5fa088a30" title="8 byte signed rational type.">Exiv2::Rational</a>(5, 7); xmpData[<span class="stringliteral">"Xmp.dc.four"</span>] = uint16_t(255); xmpData[<span class="stringliteral">"Xmp.dc.five"</span>] = int32_t(256); xmpData[<span class="stringliteral">"Xmp.dc.six"</span>] = <span class="keyword">false</span>; <span class="comment">// In addition, there is a dedicated assignment operator for Exiv2::Value</span> <a name="_a2"></a><a class="code" href="classExiv2_1_1XmpTextValue.html" title="Value type suitable for simple XMP properties and XMP nodes of complex types which...">Exiv2::XmpTextValue</a> val(<span class="stringliteral">"Seven"</span>); xmpData[<span class="stringliteral">"Xmp.dc.seven"</span>] = val; xmpData[<span class="stringliteral">"Xmp.dc.eight"</span>] = <span class="keyword">true</span>; <span class="comment">// Extracting values</span> assert(xmpData[<span class="stringliteral">"Xmp.dc.one"</span>].toLong() == -1); assert(xmpData[<span class="stringliteral">"Xmp.dc.one"</span>].value().ok()); <span class="keyword">const</span> <a name="_a3"></a><a class="code" href="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(); assert(isEqual(getv1.<a name="a4"></a><a class="code" href="classExiv2_1_1Value.html#22d257caa6c1ffe6416ce02de7bd8c1c" title="Convert the n-th component of the value to a float. The behaviour of this method...">toFloat</a>(), -1)); assert(getv1.<a name="a5"></a><a class="code" href="classExiv2_1_1Value.html#161550b3ef31b3a14b1d75149ba9ba71" title="Check the ok status indicator. After a to&lt;Type&gt; conversion, this indicator...">ok</a>()); assert(getv1.<a name="a6"></a><a class="code" href="classExiv2_1_1Value.html#595a4cb549bec8c19d290ca3e95a2678" title="Convert the n-th component of the value to a Rational. The behaviour of this method...">toRational</a>() == <a class="code" href="namespaceExiv2.html#95756f3f7fa19103f83addf5fa088a30" title="8 byte signed rational type.">Exiv2::Rational</a>(-1, 1)); assert(getv1.<a class="code" href="classExiv2_1_1Value.html#161550b3ef31b3a14b1d75149ba9ba71" title="Check the ok status indicator. After a to&lt;Type&gt; conversion, this indicator...">ok</a>()); <span class="keyword">const</span> <a class="code" href="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(); assert(isEqual(getv2.toFloat(), 3.1415f)); assert(getv2.ok()); assert(getv2.toLong() == 3); assert(getv2.ok()); <a class="code" href="namespaceExiv2.html#95756f3f7fa19103f83addf5fa088a30" title="8 byte signed rational type.">Exiv2::Rational</a> R = getv2.toRational(); assert(getv2.ok()); assert(isEqual(static_cast<float>(R.first) / R.second, 3.1415f )); <span class="keyword">const</span> <a class="code" href="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(); assert(isEqual(getv3.<a class="code" href="classExiv2_1_1Value.html#22d257caa6c1ffe6416ce02de7bd8c1c" title="Convert the n-th component of the value to a float. The behaviour of this method...">toFloat</a>(), 5.0f/7.0f)); assert(getv3.<a class="code" href="classExiv2_1_1Value.html#161550b3ef31b3a14b1d75149ba9ba71" title="Check the ok status indicator. After a to&lt;Type&gt; conversion, this indicator...">ok</a>()); assert(getv3.<a name="a7"></a><a class="code" href="classExiv2_1_1Value.html#4530a3fc3e2305cf994de5476f46f953" title="Convert the n-th component of the value to a long. The behaviour of this method may...">toLong</a>() == 0); <span class="comment">// long(5.0 / 7.0) </span> assert(getv3.<a class="code" href="classExiv2_1_1Value.html#161550b3ef31b3a14b1d75149ba9ba71" title="Check the ok status indicator. After a to&lt;Type&gt; conversion, this indicator...">ok</a>()); assert(getv3.<a class="code" href="classExiv2_1_1Value.html#595a4cb549bec8c19d290ca3e95a2678" title="Convert the n-th component of the value to a Rational. The behaviour of this method...">toRational</a>() == <a class="code" href="namespaceExiv2.html#95756f3f7fa19103f83addf5fa088a30" title="8 byte signed rational type.">Exiv2::Rational</a>(5, 7)); assert(getv3.<a class="code" href="classExiv2_1_1Value.html#161550b3ef31b3a14b1d75149ba9ba71" title="Check the ok status indicator. After a to&lt;Type&gt; conversion, this indicator...">ok</a>()); <span class="keyword">const</span> <a class="code" href="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(); assert(getv6.toLong() == 0); assert(getv6.ok()); assert(getv6.toFloat() == 0.0); assert(getv6.ok()); assert(getv6.toRational() == <a class="code" href="namespaceExiv2.html#95756f3f7fa19103f83addf5fa088a30" title="8 byte signed rational type.">Exiv2::Rational</a>(0, 1)); assert(getv6.ok()); <span class="keyword">const</span> <a class="code" href="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(); getv7.toLong(); <span class="comment">// this should fail</span> assert(!getv7.ok()); <span class="keyword">const</span> <a class="code" href="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(); assert(getv8.toLong() == 1); assert(getv8.ok()); assert(getv8.toFloat() == 1.0); assert(getv8.ok()); assert(getv8.toRational() == <a class="code" href="namespaceExiv2.html#95756f3f7fa19103f83addf5fa088a30" title="8 byte signed rational type.">Exiv2::Rational</a>(1, 1)); assert(getv8.ok()); <span class="comment">// Deleting an XMP property</span> <a class="code" href="classExiv2_1_1XmpData.html#6ad054efbea675843895e3f74c3c1923" title="XmpMetadata iterator type.">Exiv2::XmpData::iterator</a> pos = xmpData.<a name="a8"></a><a class="code" href="classExiv2_1_1XmpData.html#91864d348037f21fedb7c0591180b37d" title="Find the first Xmpdatum with the given key, return an iterator to it.">findKey</a>(<a name="_a9"></a><a class="code" href="classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.dc.eight"</span>)); <span class="keywordflow">if</span> (pos == xmpData.<a name="a10"></a><a class="code" href="classExiv2_1_1XmpData.html#232b8897f5d90a6bc087d7d010e80b92" title="End of the metadata.">end</a>()) <span class="keywordflow">throw</span> <a name="_a11"></a><a class="code" href="classExiv2_1_1Error.html" title="Simple error class used for exceptions. An output operator is provided to print errors...">Exiv2::Error</a>(1, <span class="stringliteral">"Key not found"</span>); xmpData.<a name="a12"></a><a class="code" href="classExiv2_1_1XmpData.html#6c7f21d38928596ead01c988ea3e62d2" title="Delete the Xmpdatum at iterator position pos, return the position of the next Xmpdatum...">erase</a>(pos); <span class="comment">// -------------------------------------------------------------------------</span> <span class="comment">// Exiv2 has specialized values for simple XMP properties, arrays of simple</span> <span class="comment">// properties and language alternatives.</span> <span class="comment">// Add a simple XMP property in a known namespace </span> <a class="code" href="classExiv2_1_1Value.html#0f62e585b82c97738858b743e60dff21" title="Shortcut for a Value auto pointer.">Exiv2::Value::AutoPtr</a> v = <a name="a13"></a><a class="code" href="classExiv2_1_1Value.html#d6ff043921cd1a5c399a9a4fc8257006" title="A (simple) factory to create a Value type.">Exiv2::Value::create</a>(<a name="a14"></a><a class="code" href="namespaceExiv2.html#5153319711f35fe81cbc13f4b852450c77cea60f60ef2c6f0f986137c5404c02" title="XMP text type.">Exiv2::xmpText</a>); v->read(<span class="stringliteral">"image/jpeg"</span>); xmpData.<a name="a15"></a><a class="code" href="classExiv2_1_1XmpData.html#8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones)...">add</a>(<a class="code" href="classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.dc.format"</span>), v.get()); <span class="comment">// Add an ordered array of text values.</span> v = <a class="code" href="classExiv2_1_1Value.html#d6ff043921cd1a5c399a9a4fc8257006" title="A (simple) factory to create a Value type.">Exiv2::Value::create</a>(<a name="a16"></a><a class="code" href="namespaceExiv2.html#5153319711f35fe81cbc13f4b852450c969c20e44455272599e3a273471546e8" title="XMP sequence type.">Exiv2::xmpSeq</a>); <span class="comment">// or xmpBag or xmpAlt.</span> v->read(<span class="stringliteral">"1) The first creator"</span>); <span class="comment">// The sequence in which the array</span> v->read(<span class="stringliteral">"2) The second creator"</span>); <span class="comment">// elements are added is their</span> v->read(<span class="stringliteral">"3) And another one"</span>); <span class="comment">// order in the array.</span> xmpData.<a class="code" href="classExiv2_1_1XmpData.html#8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones)...">add</a>(<a class="code" href="classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.dc.creator"</span>), v.get()); <span class="comment">// Add a language alternative property</span> v = <a class="code" href="classExiv2_1_1Value.html#d6ff043921cd1a5c399a9a4fc8257006" title="A (simple) factory to create a Value type.">Exiv2::Value::create</a>(<a name="a17"></a><a class="code" href="namespaceExiv2.html#5153319711f35fe81cbc13f4b852450c52dce1d022dd8927bc651d2e51dc1bcd" title="XMP language alternative type.">Exiv2::langAlt</a>); v->read(<span class="stringliteral">"lang=de-DE Hallo, Welt"</span>); <span class="comment">// The default doesn't need a </span> v->read(<span class="stringliteral">"Hello, World"</span>); <span class="comment">// qualifier</span> xmpData.<a class="code" href="classExiv2_1_1XmpData.html#8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones)...">add</a>(<a class="code" href="classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.dc.description"</span>), v.get()); <span class="comment">// According to the XMP specification, Xmp.tiff.ImageDescription is an</span> <span class="comment">// alias for Xmp.dc.description. Exiv2 treats an alias just like any</span> <span class="comment">// other property and leaves it to the application to implement specific</span> <span class="comment">// behaviour if desired.</span> xmpData[<span class="stringliteral">"Xmp.tiff.ImageDescription"</span>] = <span class="stringliteral">"TIFF image description"</span>; xmpData[<span class="stringliteral">"Xmp.tiff.ImageDescription"</span>] = <span class="stringliteral">"lang=de-DE TIFF Bildbeschreibung"</span>; <span class="comment">// -------------------------------------------------------------------------</span> <span class="comment">// Register a namespace which Exiv2 doesn't know yet. This is only needed</span> <span class="comment">// when properties are added manually. If the XMP metadata is read from an</span> <span class="comment">// image, namespaces are decoded and registered at the same time.</span> <a name="a18"></a><a class="code" href="classExiv2_1_1XmpProperties.html#e58ee081625b7924563e93a1ba184fec" title="Register namespace ns with preferred prefix prefix.">Exiv2::XmpProperties::registerNs</a>(<span class="stringliteral">"myNamespace/"</span>, <span class="stringliteral">"ns"</span>); <span class="comment">// -------------------------------------------------------------------------</span> <span class="comment">// Add a property in the new custom namespace.</span> xmpData[<span class="stringliteral">"Xmp.ns.myProperty"</span>] = <span class="stringliteral">"myValue"</span>; <span class="comment">// -------------------------------------------------------------------------</span> <span class="comment">// There are no specialized values for structures, qualifiers and nested</span> <span class="comment">// types. However, these can be added by using an XmpTextValue and a path as</span> <span class="comment">// the key.</span> <span class="comment">// Add a structure</span> <a class="code" href="classExiv2_1_1XmpTextValue.html" title="Value type suitable for simple XMP properties and XMP nodes of complex types which...">Exiv2::XmpTextValue</a> tv(<span class="stringliteral">"16"</span>); xmpData.<a class="code" href="classExiv2_1_1XmpData.html#8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones)...">add</a>(<a class="code" href="classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpDM.videoFrameSize/stDim:w"</span>), &tv); tv.read(<span class="stringliteral">"9"</span>); xmpData.<a class="code" href="classExiv2_1_1XmpData.html#8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones)...">add</a>(<a class="code" href="classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpDM.videoFrameSize/stDim:h"</span>), &tv); tv.read(<span class="stringliteral">"inch"</span>); xmpData.<a class="code" href="classExiv2_1_1XmpData.html#8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones)...">add</a>(<a class="code" href="classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpDM.videoFrameSize/stDim:unit"</span>), &tv); <span class="comment">// Add an element with a qualifier (using the namespace registered above)</span> xmpData[<span class="stringliteral">"Xmp.dc.publisher"</span>] = <span class="stringliteral">"James Bond"</span>; <span class="comment">// creates an unordered array</span> xmpData[<span class="stringliteral">"Xmp.dc.publisher[1]/?ns:role"</span>] = <span class="stringliteral">"secret agent"</span>; <span class="comment">// Add a qualifer to an array element of Xmp.dc.creator (added above)</span> tv.read(<span class="stringliteral">"programmer"</span>); xmpData.<a class="code" href="classExiv2_1_1XmpData.html#8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones)...">add</a>(<a class="code" href="classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.dc.creator[2]/?ns:role"</span>), &tv); <span class="comment">// Add an array of structures</span> tv.read(<span class="stringliteral">""</span>); <span class="comment">// Clear the value</span> tv.setXmpArrayType(Exiv2::XmpValue::xaBag); xmpData.<a class="code" href="classExiv2_1_1XmpData.html#8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones)...">add</a>(<a class="code" href="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> tv.setXmpArrayType(Exiv2::XmpValue::xaNone); tv.read(<span class="stringliteral">"Birthday party"</span>); xmpData.<a class="code" href="classExiv2_1_1XmpData.html#8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones)...">add</a>(<a class="code" href="classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpBJ.JobRef[1]/stJob:name"</span>), &tv); tv.read(<span class="stringliteral">"Photographer"</span>); xmpData.<a class="code" href="classExiv2_1_1XmpData.html#8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones)...">add</a>(<a class="code" href="classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpBJ.JobRef[1]/stJob:role"</span>), &tv); tv.read(<span class="stringliteral">"Wedding ceremony"</span>); xmpData.<a class="code" href="classExiv2_1_1XmpData.html#8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones)...">add</a>(<a class="code" href="classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpBJ.JobRef[2]/stJob:name"</span>), &tv); tv.read(<span class="stringliteral">"Best man"</span>); xmpData.<a class="code" href="classExiv2_1_1XmpData.html#8ce28ae5c68a30b8e646c7ddfed75843" title="Add an Xmpdatum from the supplied key and value pair. This method copies (clones)...">add</a>(<a class="code" href="classExiv2_1_1XmpKey.html" title="Concrete keys for XMP metadata.">Exiv2::XmpKey</a>(<span class="stringliteral">"Xmp.xmpBJ.JobRef[2]/stJob:role"</span>), &tv); <span class="comment">// -------------------------------------------------------------------------</span> <span class="comment">// Output XMP properties</span> <span class="keywordflow">for</span> (<a class="code" href="classExiv2_1_1XmpData.html#9c0a6575296f3da8bfc200091da40f2e" title="XmpMetadata const iterator type.">Exiv2::XmpData::const_iterator</a> md = xmpData.<a name="a19"></a><a class="code" href="classExiv2_1_1XmpData.html#b79f31eb811252976d01f2e69fa063a2" title="Begin of the metadata.">begin</a>(); md != xmpData.<a class="code" href="classExiv2_1_1XmpData.html#232b8897f5d90a6bc087d7d010e80b92" title="End of the metadata.">end</a>(); ++md) { std::cout << std::setfill(<span class="charliteral">' '</span>) << std::left << std::setw(44) << md->key() << <span class="stringliteral">" "</span> << std::setw(9) << std::setfill(<span class="charliteral">' '</span>) << std::left << md->typeName() << <span class="stringliteral">" "</span> << std::dec << std::setw(3) << std::setfill(<span class="charliteral">' '</span>) << std::right << md->count() << <span class="stringliteral">" "</span> << std::dec << md->value() << std::endl; } <span class="comment">// -------------------------------------------------------------------------</span> <span class="comment">// Serialize the XMP data and output the XMP packet</span> <a name="a20"></a><a class="code" href="namespaceExiv2.html#5153319711f35fe81cbc13f4b852450c2d79fb07c9ec891f281968dad43c1e25" title="IPTC string type.">std::string</a> xmpPacket; <span class="keywordflow">if</span> (0 != <a name="a21"></a><a class="code" href="classExiv2_1_1XmpParser.html#39ca42868bff6886b42cf322fb40e7c8" title="Encode (serialize) XMP metadata from xmpData into a string xmpPacket. The XMP packet...">Exiv2::XmpParser::encode</a>(xmpPacket, xmpData)) { <span class="keywordflow">throw</span> <a class="code" href="classExiv2_1_1Error.html" title="Simple error class used for exceptions. An output operator is provided to print errors...">Exiv2::Error</a>(1, <span class="stringliteral">"Failed to serialize XMP data"</span>); } std::cout << xmpPacket << <span class="stringliteral">"\n"</span>; <span class="comment">// Cleanup</span> <a name="a22"></a><a class="code" href="classExiv2_1_1XmpParser.html#e6c0f4a9eeef2aed456346a206981b4c" title="Terminate the XMP Toolkit and unregister custom namespaces.">Exiv2::XmpParser::terminate</a>(); <span class="keywordflow">return</span> 0; } <span class="keywordflow">catch</span> (<a name="_a23"></a><a class="code" href="classExiv2_1_1AnyError.html" title="Error class interface. Allows the definition and use of a hierarchy of error classes...">Exiv2::AnyError</a>& e) { std::cout << <span class="stringliteral">"Caught Exiv2 exception '"</span> << e << <span class="stringliteral">"'\n"</span>; <span class="keywordflow">return</span> -1; } </pre></div> </div> <hr size="1"><address style="text-align: right;"><small>Generated on Thu Jun 25 15:17:11 2009 for Exiv2 by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address> </body> </html>