#1111: Updated the examples.

v0.27.3
Andreas Huggel 10 years ago
parent 07297295c1
commit de3d89e577

@ -82,18 +82,18 @@ provided to simplify the use of XMP properties.
Note: Unlike Exif and IPTC tags, XMP properties do not have
a tag number.
<h2><a href="examples.html">Examples</a></h2>
<h2><a href="../examples.html">Examples</a></h2>
<p>There are several simple examples that demonstrate the basic use of Exiv2
functionality: <a href="exifprint_8cpp-example.html">Exifprint</a>
functionality: <a href="../examples.html#example1">Exifprint</a>
shows how the Exif data of an image can be read and written to the screen.
<a href="iptcprint_8cpp-example.html">Iptcprint</a> is a similar
<a href="../examples.html#example3">Iptcprint</a> is a similar
example to print IPTC data.
<a href="addmoddel_8cpp-example.html">Addmoddel</a> shows how to
<a href="../examples.html#example2">Addmoddel</a> shows how to
add, modify and delete Exif metadata.
<a href="exifcomment_8cpp-example.html">Exifcomment</a> shows how to
set the exif comment of an image.
<a href="xmpsample_8cpp-example.html">Xmpsample.cpp</a> contains examples
<a href="../examples.html#example5">Xmpsample.cpp</a> contains examples
of how to set various types of XMP properties.
<br>
For more real-world code have a look at the implementation of the

@ -1,6 +1,7 @@
__doctype__
<html lang="en">
__header4__
<body>
__navbar__
@ -218,5 +219,9 @@ Xmp.xmpBJ.JobRef[2]/stJob:role XmpText 8 Best man
</div><!-- /.container -->
__footer__
__bootstrap__
<!-- Custom script to bootstrap (augment) Doxygen-generated HTML -->
<script type="text/javascript" src="doc/doxy-boot.js"></script>
</body>
</html>

@ -1,51 +1,53 @@
<div class="fragment"><pre><span class="comment">// ***************************************************************** -*- C++ -*-</span>
<span class="comment">// exifprint.cpp, $Rev: 2286 $</span>
<span class="comment">// Sample program to print the Exif metadata of an image</span>
<span class="preprocessor">#include &lt;exiv2/exiv2.hpp&gt;</span>
<span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#include &lt;iomanip&gt;</span>
<span class="preprocessor">#include &lt;cassert&gt;</span>
<span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* <span class="keyword">const</span> argv[])
<span class="keyword">try</span> {
<span class="keywordflow">if</span> (argc != 2) {
std::cout &lt;&lt; <span class="stringliteral">"Usage: "</span> &lt;&lt; argv[0] &lt;&lt; <span class="stringliteral">" file\n"</span>;
<span class="keywordflow">return</span> 1;
}
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(argv[1]);
assert(image.get() != 0);
image-&gt;readMetadata();
Exiv2::ExifData &amp;exifData = image-&gt;exifData();
<span class="keywordflow">if</span> (exifData.empty()) {
std::string error(argv[1]);
error += <span class="stringliteral">": No Exif data found in the file"</span>;
<span class="keywordflow">throw</span> Exiv2::Error(1, error);
}
Exiv2::ExifData::const_iterator end = exifData.end();
<span class="keywordflow">for</span> (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
const char* tn = i-&gt;typeName();
std::cout &lt;&lt; std::setw(44) &lt;&lt; std::setfill(<span class="charliteral">' '</span>) &lt;&lt; std::left
&lt;&lt; i-&gt;key() &lt;&lt; <span class="stringliteral">" "</span>
&lt;&lt; <span class="stringliteral">"0x"</span> &lt;&lt; std::setw(4) &lt;&lt; std::setfill(<span class="charliteral">'0'</span>) &lt;&lt; std::right
&lt;&lt; std::hex &lt;&lt; i-&gt;tag() &lt;&lt; <span class="stringliteral">" "</span>
&lt;&lt; std::setw(9) &lt;&lt; std::setfill(<span class="charliteral">' '</span>) &lt;&lt; std::left
&lt;&lt; (tn ? tn : <span class="stringliteral">"Unknown"</span>) &lt;&lt; <span class="stringliteral">" "</span>
&lt;&lt; std::dec &lt;&lt; std::setw(3)
&lt;&lt; std::setfill(<span class="charliteral">' '</span>) &lt;&lt; std::right
&lt;&lt; i-&gt;count() &lt;&lt; <span class="stringliteral">" "</span>
&lt;&lt; std::dec &lt;&lt; i-&gt;value()
&lt;&lt; <span class="stringliteral">"\n"</span>;
}
<span class="keywordflow">return</span> 0;
}
<span class="keywordflow">catch</span> (Exiv2::AnyError&amp; e) {
std::cout &lt;&lt; <span class="stringliteral">"Caught Exiv2 exception '"</span> &lt;&lt; e.what() &lt;&lt; <span class="stringliteral">"'\n"</span>;
<span class="keywordflow">return</span> -1;
}
</pre></div>
<div class="fragment"><div class="line"><span class="comment">// ***************************************************************** -*- C++ -*-</span></div>
<div class="line"><span class="comment">// exifprint.cpp, $Rev: 3090 $</span></div>
<div class="line"><span class="comment">// Sample program to print the Exif metadata of an image</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="doc/exiv2_8hpp.html" title="Include all Exiv2 header files.">exiv2/exiv2.hpp</a>&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;iomanip&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;cassert&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* <span class="keyword">const</span> argv[])</div>
<div class="line"><span class="keyword">try</span> {</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">if</span> (argc != 2) {</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Usage: &quot;</span> &lt;&lt; argv[0] &lt;&lt; <span class="stringliteral">&quot; file\n&quot;</span>;</div>
<div class="line"> <span class="keywordflow">return</span> 1;</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <a class="code" href="doc/classExiv2_1_1Image.html#a89ad3ffe7a4e8a943d267d77843415fb" title="Image auto_ptr type.">Exiv2::Image::AutoPtr</a> image = <a name="a0"></a><a class="code" href="doc/classExiv2_1_1ImageFactory.html#aba929c4ca4a71625d12bcb97bcc28161" title="Create an Image subclass of the appropriate type by reading the specified file. Image type is derived...">Exiv2::ImageFactory::open</a>(argv[1]);</div>
<div class="line"> assert(image.get() != 0);</div>
<div class="line"> image-&gt;readMetadata();</div>
<div class="line"></div>
<div class="line"> <a name="_a1"></a><a class="code" href="doc/classExiv2_1_1ExifData.html" title="A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...">Exiv2::ExifData</a> &amp;exifData = image-&gt;exifData();</div>
<div class="line"> <span class="keywordflow">if</span> (exifData.<a name="a2"></a><a class="code" href="doc/classExiv2_1_1ExifData.html#a4993c68fbb50731014c307852875c731" title="Return true if there is no Exif metadata.">empty</a>()) {</div>
<div class="line"> <a name="a3"></a><a class="code" href="doc/namespaceExiv2.html#a5153319711f35fe81cbc13f4b852450ca2d79fb07c9ec891f281968dad43c1e25" title="IPTC string type.">std::string</a> error(argv[1]);</div>
<div class="line"> error += <span class="stringliteral">&quot;: No Exif data found in the file&quot;</span>;</div>
<div class="line"> <span class="keywordflow">throw</span> <a name="a4"></a><a class="code" href="doc/namespaceExiv2.html#accd3e49cafe9db52c1e0e6f648753cae" title="Error class used for exceptions (std::string based)">Exiv2::Error</a>(1, error);</div>
<div class="line"> }</div>
<div class="line"> <a class="code" href="doc/classExiv2_1_1ExifData.html#a2b8ac7a474d6527c0f3f6a0a9cebef77" title="ExifMetadata const iterator type.">Exiv2::ExifData::const_iterator</a> end = exifData.<a name="a5"></a><a class="code" href="doc/classExiv2_1_1ExifData.html#a9c15177b03489e3d4bb81e9acc1165fe" title="End of the metadata.">end</a>();</div>
<div class="line"> <span class="keywordflow">for</span> (<a class="code" href="doc/classExiv2_1_1ExifData.html#a2b8ac7a474d6527c0f3f6a0a9cebef77" title="ExifMetadata const iterator type.">Exiv2::ExifData::const_iterator</a> i = exifData.<a name="a6"></a><a class="code" href="doc/classExiv2_1_1ExifData.html#a53bce2980ee060fc2da5fe6751f51db9" title="Begin of the metadata.">begin</a>(); i != end; ++i) {</div>
<div class="line"> <span class="keyword">const</span> <span class="keywordtype">char</span>* tn = i-&gt;typeName();</div>
<div class="line"> std::cout &lt;&lt; std::setw(44) &lt;&lt; std::setfill(<span class="charliteral">&#39; &#39;</span>) &lt;&lt; std::left</div>
<div class="line"> &lt;&lt; i-&gt;key() &lt;&lt; <span class="stringliteral">&quot; &quot;</span></div>
<div class="line"> &lt;&lt; <span class="stringliteral">&quot;0x&quot;</span> &lt;&lt; std::setw(4) &lt;&lt; std::setfill(<span class="charliteral">&#39;0&#39;</span>) &lt;&lt; std::right</div>
<div class="line"> &lt;&lt; std::hex &lt;&lt; i-&gt;tag() &lt;&lt; <span class="stringliteral">&quot; &quot;</span></div>
<div class="line"> &lt;&lt; std::setw(9) &lt;&lt; std::setfill(<span class="charliteral">&#39; &#39;</span>) &lt;&lt; std::left</div>
<div class="line"> &lt;&lt; (tn ? tn : <span class="stringliteral">&quot;Unknown&quot;</span>) &lt;&lt; <span class="stringliteral">&quot; &quot;</span></div>
<div class="line"> &lt;&lt; std::dec &lt;&lt; std::setw(3)</div>
<div class="line"> &lt;&lt; std::setfill(<span class="charliteral">&#39; &#39;</span>) &lt;&lt; std::right</div>
<div class="line"> &lt;&lt; i-&gt;count() &lt;&lt; <span class="stringliteral">&quot; &quot;</span></div>
<div class="line"> &lt;&lt; std::dec &lt;&lt; i-&gt;value()</div>
<div class="line"> &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
<div class="line"><span class="comment">//catch (std::exception&amp; e) {</span></div>
<div class="line"><span class="comment">//catch (Exiv2::AnyError&amp; e) {</span></div>
<div class="line"><span class="keywordflow">catch</span> (<a name="_a7"></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>&amp; e) {</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Caught Exiv2 exception &#39;&quot;</span> &lt;&lt; e.<a name="a8"></a><a class="code" href="doc/classExiv2_1_1BasicError.html#a72e9f29e45d6f59125fa3de232641504" title="Return the error message as a C-string. The pointer returned by what() is valid only as long as the B...">what</a>() &lt;&lt; <span class="stringliteral">&quot;&#39;\n&quot;</span>;</div>
<div class="line"> <span class="keywordflow">return</span> -1;</div>
<div class="line">}</div>
</div><!-- fragment -->

@ -1,110 +1,110 @@
<div class="fragment"><pre><span class="comment">// ***************************************************************** -*- C++ -*-</span>
<span class="comment">// addmoddel.cpp, $Rev: 2286 $</span>
<span class="comment">// Sample program showing how to add, modify and delete Exif metadata.</span>
<span class="preprocessor">#include &lt;exiv2/exiv2.hpp&gt;</span>
<span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#include &lt;iomanip&gt;</span>
<span class="preprocessor">#include &lt;cassert&gt;</span>
<span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* <span class="keyword">const</span> argv[])
<span class="keyword">try</span> {
<span class="keywordflow">if</span> (argc != 2) {
std::cout &lt;&lt; <span class="stringliteral">"Usage: "</span> &lt;&lt; argv[0] &lt;&lt; <span class="stringliteral">" file\n"</span>;
<span class="keywordflow">return</span> 1;
}
std::string file(argv[1]);
<span class="comment">// Container for exif metadata. This is an example of creating</span>
<span class="comment">// exif metadata from scratch. If you want to add, modify, delete</span>
<span class="comment">// metadata that exists in an image, start with ImageFactory::open</span>
Exiv2::ExifData exifData;
<span class="comment">// *************************************************************************</span>
<span class="comment">// Add to the Exif data</span>
<span class="comment">// This is the quickest way to add (simple) Exif data. If a metadatum for</span>
<span class="comment">// a given key already exists, its value is overwritten. Otherwise a new</span>
<span class="comment">// tag is added.</span>
exifData[<span class="stringliteral">"Exif.Image.Model"</span>] = <span class="stringliteral">"Test 1"</span>; <span class="comment">// AsciiValue</span>
exifData[<span class="stringliteral">"Exif.Image.SamplesPerPixel"</span>] = uint16_t(162); <span class="comment">// UShortValue</span>
exifData[<span class="stringliteral">"Exif.Image.XResolution"</span>] = int32_t(-2); <span class="comment">// LongValue</span>
exifData[<span class="stringliteral">"Exif.Image.YResolution"</span>] = Exiv2::Rational(-2, 3); <span class="comment">// RationalValue</span>
std::cout &lt;&lt; <span class="stringliteral">"Added a few tags the quick way.\n"</span>;
<span class="comment">// Create a ASCII string value (note the use of create)</span>
Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::asciiString);
<span class="comment">// Set the value to a string</span>
v-&gt;read(<span class="stringliteral">"1999:12:31 23:59:59"</span>);
<span class="comment">// Add the value together with its key to the Exif data container</span>
Exiv2::ExifKey key(<span class="stringliteral">"Exif.Photo.DateTimeOriginal"</span>);
exifData.add(key, v.get());
std::cout &lt;&lt; <span class="stringliteral">"Added key \""</span> &lt;&lt; key &lt;&lt; <span class="stringliteral">"\", value \""</span> &lt;&lt; *v &lt;&lt; <span class="stringliteral">"\"\n"</span>;
<span class="comment">// Now create a more interesting value (without using the create method)</span>
Exiv2::URationalValue::AutoPtr rv(<span class="keyword">new</span> Exiv2::URationalValue);
<span class="comment">// Set two rational components from a string</span>
rv-&gt;read(<span class="stringliteral">"1/2 1/3"</span>);
<span class="comment">// Add more elements through the extended interface of rational value</span>
rv-&gt;value_.push_back(std::make_pair(2,3));
rv-&gt;value_.push_back(std::make_pair(3,4));
<span class="comment">// Add the key and value pair to the Exif data</span>
key = Exiv2::ExifKey(<span class="stringliteral">"Exif.Image.PrimaryChromaticities"</span>);
exifData.add(key, rv.get());
std::cout &lt;&lt; <span class="stringliteral">"Added key \""</span> &lt;&lt; key &lt;&lt; <span class="stringliteral">"\", value \""</span> &lt;&lt; *rv &lt;&lt; <span class="stringliteral">"\"\n"</span>;
<span class="comment">// *************************************************************************</span>
<span class="comment">// Modify Exif data</span>
<span class="comment">// Since we know that the metadatum exists (or we don't mind creating a new</span>
<span class="comment">// tag if it doesn't), we can simply do this:</span>
Exiv2::Exifdatum&amp; tag = exifData[<span class="stringliteral">"Exif.Photo.DateTimeOriginal"</span>];
std::string date = tag.toString();
date.replace(0, 4, <span class="stringliteral">"2000"</span>);
tag.setValue(date);
std::cout &lt;&lt; <span class="stringliteral">"Modified key \""</span> &lt;&lt; key
&lt;&lt; <span class="stringliteral">"\", new value \""</span> &lt;&lt; tag.value() &lt;&lt; <span class="stringliteral">"\"\n"</span>;
<span class="comment">// Alternatively, we can use findKey()</span>
key = Exiv2::ExifKey(<span class="stringliteral">"Exif.Image.PrimaryChromaticities"</span>);
Exiv2::ExifData::iterator pos = exifData.findKey(key);
<span class="keywordflow">if</span> (pos == exifData.end()) <span class="keywordflow">throw</span> Exiv2::Error(1, <span class="stringliteral">"Key not found"</span>);
<span class="comment">// Get a pointer to a copy of the value</span>
v = pos-&gt;getValue();
<span class="comment">// Downcast the Value pointer to its actual type</span>
Exiv2::URationalValue* prv = <span class="keyword">dynamic_cast&lt;</span>Exiv2::URationalValue*<span class="keyword">&gt;</span>(v.release());
<span class="keywordflow">if</span> (prv == 0) <span class="keywordflow">throw</span> Exiv2::Error(1, <span class="stringliteral">"Downcast failed"</span>);
rv = Exiv2::URationalValue::AutoPtr(prv);
<span class="comment">// Modify the value directly through the interface of URationalValue</span>
rv-&gt;value_[2] = std::make_pair(88,77);
<span class="comment">// Copy the modified value back to the metadatum</span>
pos-&gt;setValue(rv.get());
std::cout &lt;&lt; <span class="stringliteral">"Modified key \""</span> &lt;&lt; key
&lt;&lt; <span class="stringliteral">"\", new value \""</span> &lt;&lt; pos-&gt;value() &lt;&lt; <span class="stringliteral">"\"\n"</span>;
<span class="comment">// *************************************************************************</span>
<span class="comment">// Delete metadata from the Exif data container</span>
<span class="comment">// Delete the metadatum at iterator position pos</span>
key = Exiv2::ExifKey(<span class="stringliteral">"Exif.Image.PrimaryChromaticities"</span>);
pos = exifData.findKey(key);
<span class="keywordflow">if</span> (pos == exifData.end()) <span class="keywordflow">throw</span> Exiv2::Error(1, <span class="stringliteral">"Key not found"</span>);
exifData.erase(pos);
std::cout &lt;&lt; <span class="stringliteral">"Deleted key \""</span> &lt;&lt; key &lt;&lt; <span class="stringliteral">"\"\n"</span>;
<span class="comment">// *************************************************************************</span>
<span class="comment">// Finally, write the remaining Exif data to the image file</span>
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(file);
assert(image.get() != 0);
image-&gt;setExifData(exifData);
image-&gt;writeMetadata();
<span class="keywordflow">return</span> 0;
}
<span class="keywordflow">catch</span> (Exiv2::AnyError&amp; e) {
std::cout &lt;&lt; <span class="stringliteral">"Caught Exiv2 exception '"</span> &lt;&lt; e &lt;&lt; <span class="stringliteral">"'\n"</span>;
<span class="keywordflow">return</span> -1;
}
</pre></div>
<div class="fragment"><div class="line"><span class="comment">// ***************************************************************** -*- C++ -*-</span></div>
<div class="line"><span class="comment">// addmoddel.cpp, $Rev: 3353 $</span></div>
<div class="line"><span class="comment">// Sample program showing how to add, modify and delete Exif metadata.</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="doc/exiv2_8hpp.html" title="Include all Exiv2 header files.">exiv2/exiv2.hpp</a>&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;iomanip&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;cassert&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* <span class="keyword">const</span> argv[])</div>
<div class="line"><span class="keyword">try</span> {</div>
<div class="line"> <span class="keywordflow">if</span> (argc != 2) {</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Usage: &quot;</span> &lt;&lt; argv[0] &lt;&lt; <span class="stringliteral">&quot; file\n&quot;</span>;</div>
<div class="line"> <span class="keywordflow">return</span> 1;</div>
<div class="line"> }</div>
<div class="line"> std::string file(argv[1]);</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Container for exif metadata. This is an example of creating</span></div>
<div class="line"> <span class="comment">// exif metadata from scratch. If you want to add, modify, delete</span></div>
<div class="line"> <span class="comment">// metadata that exists in an image, start with ImageFactory::open</span></div>
<div class="line"> <a name="_a1"></a><a class="code" href="doc/classExiv2_1_1ExifData.html" title="A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...">Exiv2::ExifData</a> exifData;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// *************************************************************************</span></div>
<div class="line"> <span class="comment">// Add to the Exif data</span></div>
<div class="line"></div>
<div class="line"> <span class="comment">// This is the quickest way to add (simple) Exif data. If a metadatum for</span></div>
<div class="line"> <span class="comment">// a given key already exists, its value is overwritten. Otherwise a new</span></div>
<div class="line"> <span class="comment">// tag is added.</span></div>
<div class="line"> exifData[<span class="stringliteral">&quot;Exif.Image.Model&quot;</span>] = <span class="stringliteral">&quot;Test 1&quot;</span>; <span class="comment">// AsciiValue</span></div>
<div class="line"> exifData[<span class="stringliteral">&quot;Exif.Image.SamplesPerPixel&quot;</span>] = uint16_t(162); <span class="comment">// UShortValue</span></div>
<div class="line"> exifData[<span class="stringliteral">&quot;Exif.Image.XResolution&quot;</span>] = int32_t(-2); <span class="comment">// LongValue</span></div>
<div class="line"> exifData[<span class="stringliteral">&quot;Exif.Image.YResolution&quot;</span>] = <a name="a2"></a><a class="code" href="doc/namespaceExiv2.html#a95756f3f7fa19103f83addf5fa088a30" title="8 byte signed rational type.">Exiv2::Rational</a>(-2, 3); <span class="comment">// RationalValue</span></div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Added a few tags the quick way.\n&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Create a ASCII string value (note the use of create)</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="a3"></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="a4"></a><a class="code" href="doc/namespaceExiv2.html#a5153319711f35fe81cbc13f4b852450ca773cf6dde5caaabb3dcf9fb161fa7dfd" title="Exif ASCII type, 8-bit byte.">Exiv2::asciiString</a>);</div>
<div class="line"> <span class="comment">// Set the value to a string</span></div>
<div class="line"> v-&gt;read(<span class="stringliteral">&quot;1999:12:31 23:59:59&quot;</span>);</div>
<div class="line"> <span class="comment">// Add the value together with its key to the Exif data container</span></div>
<div class="line"> <a name="_a5"></a><a class="code" href="doc/classExiv2_1_1ExifKey.html" title="Concrete keys for Exif metadata and access to Exif tag reference data.">Exiv2::ExifKey</a> key(<span class="stringliteral">&quot;Exif.Photo.DateTimeOriginal&quot;</span>);</div>
<div class="line"> exifData.<a name="a6"></a><a class="code" href="doc/classExiv2_1_1ExifData.html#a91d231cd1b9fefc311c5166e30ab66eb" title="Add an Exifdatum from the supplied key and value pair. This method copies (clones) key and value...">add</a>(key, v.get());</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Added key \&quot;&quot;</span> &lt;&lt; key &lt;&lt; <span class="stringliteral">&quot;\&quot;, value \&quot;&quot;</span> &lt;&lt; *v &lt;&lt; <span class="stringliteral">&quot;\&quot;\n&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Now create a more interesting value (without using the create method)</span></div>
<div class="line"> <a class="code" href="doc/classExiv2_1_1ValueType.html#a0c76c512468a47f6eac463f4af278a14" title="Shortcut for a ValueType&lt;T&gt; auto pointer.">Exiv2::URationalValue::AutoPtr</a> rv(<span class="keyword">new</span> <a name="_a7"></a><a class="code" href="doc/classExiv2_1_1ValueType.html" title="Template for a Value of a basic type. This is used for unsigned and signed short, long and rationals...">Exiv2::URationalValue</a>);</div>
<div class="line"> <span class="comment">// Set two rational components from a string</span></div>
<div class="line"> rv-&gt;read(<span class="stringliteral">&quot;1/2 1/3&quot;</span>);</div>
<div class="line"> <span class="comment">// Add more elements through the extended interface of rational value</span></div>
<div class="line"> rv-&gt;value_.push_back(std::make_pair(2,3));</div>
<div class="line"> rv-&gt;value_.push_back(std::make_pair(3,4));</div>
<div class="line"> <span class="comment">// Add the key and value pair to the Exif data</span></div>
<div class="line"> key = <a class="code" href="doc/classExiv2_1_1ExifKey.html" title="Concrete keys for Exif metadata and access to Exif tag reference data.">Exiv2::ExifKey</a>(<span class="stringliteral">&quot;Exif.Image.PrimaryChromaticities&quot;</span>);</div>
<div class="line"> exifData.<a class="code" href="doc/classExiv2_1_1ExifData.html#a91d231cd1b9fefc311c5166e30ab66eb" title="Add an Exifdatum from the supplied key and value pair. This method copies (clones) key and value...">add</a>(key, rv.get());</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Added key \&quot;&quot;</span> &lt;&lt; key &lt;&lt; <span class="stringliteral">&quot;\&quot;, value \&quot;&quot;</span> &lt;&lt; *rv &lt;&lt; <span class="stringliteral">&quot;\&quot;\n&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// *************************************************************************</span></div>
<div class="line"> <span class="comment">// Modify Exif data</span></div>
<div class="line"></div>
<div class="line"> <span class="comment">// Since we know that the metadatum exists (or we don&#39;t mind creating a new</span></div>
<div class="line"> <span class="comment">// tag if it doesn&#39;t), we can simply do this:</span></div>
<div class="line"> <a name="_a8"></a><a class="code" href="doc/classExiv2_1_1Exifdatum.html" title="An Exif metadatum, consisting of an ExifKey and a Value and methods to manipulate these...">Exiv2::Exifdatum</a>&amp; tag = exifData[<span class="stringliteral">&quot;Exif.Photo.DateTimeOriginal&quot;</span>];</div>
<div class="line"> std::string date = tag.<a name="a10"></a><a class="code" href="doc/classExiv2_1_1Exifdatum.html#a73d1e5346411c2adf520fec405f2e536" title="Return the value as a string.">toString</a>();</div>
<div class="line"> date.replace(0, 4, <span class="stringliteral">&quot;2000&quot;</span>);</div>
<div class="line"> tag.<a name="a11"></a>setValue(date);</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Modified key \&quot;&quot;</span> &lt;&lt; tag.<a name="a12"></a><a class="code" href="doc/classExiv2_1_1Exifdatum.html#a6651602de3d217dd622d33ab67289c11" title="Return the key of the Exifdatum.">key</a>()</div>
<div class="line"> &lt;&lt; <span class="stringliteral">&quot;\&quot;, new value \&quot;&quot;</span> &lt;&lt; tag.<a name="a13"></a><a class="code" href="doc/classExiv2_1_1Exifdatum.html#ad4a621c1399e02648f1fb1fb550e7a53" title="Return a constant reference to the value.">value</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;\n&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Alternatively, we can use findKey()</span></div>
<div class="line"> key = <a class="code" href="doc/classExiv2_1_1ExifKey.html" title="Concrete keys for Exif metadata and access to Exif tag reference data.">Exiv2::ExifKey</a>(<span class="stringliteral">&quot;Exif.Image.PrimaryChromaticities&quot;</span>);</div>
<div class="line"> <a class="code" href="doc/classExiv2_1_1ExifData.html#a02e2a2acb4cfeb0f7755c1a45f94106f" title="ExifMetadata iterator type.">Exiv2::ExifData::iterator</a> pos = exifData.<a name="a14"></a><a class="code" href="doc/classExiv2_1_1ExifData.html#a96c38cbd300ebdfa05f849864b380690" title="Find the first Exifdatum with the given key, return an iterator to it.">findKey</a>(key);</div>
<div class="line"> <span class="keywordflow">if</span> (pos == exifData.<a name="a15"></a><a class="code" href="doc/classExiv2_1_1ExifData.html#a9c15177b03489e3d4bb81e9acc1165fe" title="End of the metadata.">end</a>()) <span class="keywordflow">throw</span> <a name="_a16"></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">&quot;Key not found&quot;</span>);</div>
<div class="line"> <span class="comment">// Get a pointer to a copy of the value</span></div>
<div class="line"> v = pos-&gt;getValue();</div>
<div class="line"> <span class="comment">// Downcast the Value pointer to its actual type</span></div>
<div class="line"> <a class="code" href="doc/classExiv2_1_1ValueType.html" title="Template for a Value of a basic type. This is used for unsigned and signed short, long and rationals...">Exiv2::URationalValue</a>* prv = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="doc/classExiv2_1_1ValueType.html" title="Template for a Value of a basic type. This is used for unsigned and signed short, long and rationals...">Exiv2::URationalValue</a>*<span class="keyword">&gt;</span>(v.release());</div>
<div class="line"> <span class="keywordflow">if</span> (prv == 0) <span class="keywordflow">throw</span> <a name="a17"></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">&quot;Downcast failed&quot;</span>);</div>
<div class="line"> rv = <a name="a18"></a><a class="code" href="doc/classExiv2_1_1ValueType.html#a0c76c512468a47f6eac463f4af278a14" title="Shortcut for a ValueType&lt;T&gt; auto pointer.">Exiv2::URationalValue::AutoPtr</a>(prv);</div>
<div class="line"> <span class="comment">// Modify the value directly through the interface of URationalValue</span></div>
<div class="line"> rv-&gt;value_[2] = std::make_pair(88,77);</div>
<div class="line"> <span class="comment">// Copy the modified value back to the metadatum</span></div>
<div class="line"> pos-&gt;setValue(rv.get());</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Modified key \&quot;&quot;</span> &lt;&lt; key</div>
<div class="line"> &lt;&lt; <span class="stringliteral">&quot;\&quot;, new value \&quot;&quot;</span> &lt;&lt; pos-&gt;value() &lt;&lt; <span class="stringliteral">&quot;\&quot;\n&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// *************************************************************************</span></div>
<div class="line"> <span class="comment">// Delete metadata from the Exif data container</span></div>
<div class="line"></div>
<div class="line"> <span class="comment">// Delete the metadatum at iterator position pos</span></div>
<div class="line"> key = <a class="code" href="doc/classExiv2_1_1ExifKey.html" title="Concrete keys for Exif metadata and access to Exif tag reference data.">Exiv2::ExifKey</a>(<span class="stringliteral">&quot;Exif.Image.PrimaryChromaticities&quot;</span>);</div>
<div class="line"> pos = exifData.<a class="code" href="doc/classExiv2_1_1ExifData.html#a96c38cbd300ebdfa05f849864b380690" title="Find the first Exifdatum with the given key, return an iterator to it.">findKey</a>(key);</div>
<div class="line"> <span class="keywordflow">if</span> (pos == exifData.<a class="code" href="doc/classExiv2_1_1ExifData.html#a9c15177b03489e3d4bb81e9acc1165fe" title="End of the metadata.">end</a>()) <span class="keywordflow">throw</span> <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">&quot;Key not found&quot;</span>);</div>
<div class="line"> exifData.<a name="a19"></a><a class="code" href="doc/classExiv2_1_1ExifData.html#a710a66ca8be51192c15729c541b72fb5" title="Delete the Exifdatum at iterator position pos, return the position of the next exifdatum. Note that iterators into the metadata, including pos, are potentially invalidated by this call.">erase</a>(pos);</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Deleted key \&quot;&quot;</span> &lt;&lt; key &lt;&lt; <span class="stringliteral">&quot;\&quot;\n&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// *************************************************************************</span></div>
<div class="line"> <span class="comment">// Finally, write the remaining Exif data to the image file</span></div>
<div class="line"> <a class="code" href="doc/classExiv2_1_1Image.html#a89ad3ffe7a4e8a943d267d77843415fb" title="Image auto_ptr type.">Exiv2::Image::AutoPtr</a> image = <a name="a20"></a><a class="code" href="doc/classExiv2_1_1ImageFactory.html#aba929c4ca4a71625d12bcb97bcc28161" title="Create an Image subclass of the appropriate type by reading the specified file. Image type is derived...">Exiv2::ImageFactory::open</a>(file);</div>
<div class="line"> assert(image.get() != 0);</div>
<div class="line"></div>
<div class="line"> image-&gt;setExifData(exifData);</div>
<div class="line"> image-&gt;writeMetadata();</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
<div class="line"><span class="keywordflow">catch</span> (<a name="_a21"></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>&amp; e) {</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Caught Exiv2 exception &#39;&quot;</span> &lt;&lt; e &lt;&lt; <span class="stringliteral">&quot;&#39;\n&quot;</span>;</div>
<div class="line"> <span class="keywordflow">return</span> -1;</div>
<div class="line">}</div>
</div><!-- fragment -->

@ -1,51 +1,51 @@
<div class="fragment"><pre><span class="comment">// ***************************************************************** -*- C++ -*-</span>
<span class="comment">// iptcprint.cpp, $Rev: 2286 $</span>
<span class="comment">// Sample program to print the IPTC metadata of an image</span>
<span class="preprocessor">#include &lt;exiv2/exiv2.hpp&gt;</span>
<span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#include &lt;iomanip&gt;</span>
<span class="preprocessor">#include &lt;cassert&gt;</span>
<span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* <span class="keyword">const</span> argv[])
<span class="keyword">try</span> {
<span class="keywordflow">if</span> (argc != 2) {
std::cout &lt;&lt; <span class="stringliteral">"Usage: "</span> &lt;&lt; argv[0] &lt;&lt; <span class="stringliteral">" file\n"</span>;
<span class="keywordflow">return</span> 1;
}
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(argv[1]);
assert (image.get() != 0);
image-&gt;readMetadata();
Exiv2::IptcData &amp;iptcData = image-&gt;iptcData();
<span class="keywordflow">if</span> (iptcData.empty()) {
std::string error(argv[1]);
error += <span class="stringliteral">": No IPTC data found in the file"</span>;
<span class="keywordflow">throw</span> Exiv2::Error(1, error);
}
Exiv2::IptcData::iterator end = iptcData.end();
<span class="keywordflow">for</span> (Exiv2::IptcData::iterator md = iptcData.begin(); md != end; ++md) {
std::cout &lt;&lt; std::setw(44) &lt;&lt; std::setfill(<span class="charliteral">' '</span>) &lt;&lt; std::left
&lt;&lt; md-&gt;key() &lt;&lt; <span class="stringliteral">" "</span>
&lt;&lt; <span class="stringliteral">"0x"</span> &lt;&lt; std::setw(4) &lt;&lt; std::setfill(<span class="charliteral">'0'</span>) &lt;&lt; std::right
&lt;&lt; std::hex &lt;&lt; md-&gt;tag() &lt;&lt; <span class="stringliteral">" "</span>
&lt;&lt; std::setw(9) &lt;&lt; std::setfill(<span class="charliteral">' '</span>) &lt;&lt; std::left
&lt;&lt; md-&gt;typeName() &lt;&lt; <span class="stringliteral">" "</span>
&lt;&lt; std::dec &lt;&lt; std::setw(3)
&lt;&lt; std::setfill(<span class="charliteral">' '</span>) &lt;&lt; std::right
&lt;&lt; md-&gt;count() &lt;&lt; <span class="stringliteral">" "</span>
&lt;&lt; std::dec &lt;&lt; md-&gt;value()
&lt;&lt; std::endl;
}
<span class="keywordflow">return</span> 0;
}
<span class="keywordflow">catch</span> (Exiv2::AnyError&amp; e) {
std::cout &lt;&lt; <span class="stringliteral">"Caught Exiv2 exception '"</span> &lt;&lt; e &lt;&lt; <span class="stringliteral">"'\n"</span>;
<span class="keywordflow">return</span> -1;
}
</pre></div>
<div class="fragment"><div class="line"><span class="comment">// ***************************************************************** -*- C++ -*-</span></div>
<div class="line"><span class="comment">// iptcprint.cpp, $Rev: 3090 $</span></div>
<div class="line"><span class="comment">// Sample program to print the IPTC metadata of an image</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="doc/exiv2_8hpp.html" title="Include all Exiv2 header files.">exiv2/exiv2.hpp</a>&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;iomanip&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;cassert&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* <span class="keyword">const</span> argv[])</div>
<div class="line"><span class="keyword">try</span> {</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">if</span> (argc != 2) {</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Usage: &quot;</span> &lt;&lt; argv[0] &lt;&lt; <span class="stringliteral">&quot; file\n&quot;</span>;</div>
<div class="line"> <span class="keywordflow">return</span> 1;</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <a class="code" href="doc/classExiv2_1_1Image.html#a89ad3ffe7a4e8a943d267d77843415fb" title="Image auto_ptr type.">Exiv2::Image::AutoPtr</a> image = <a name="a0"></a><a class="code" href="doc/classExiv2_1_1ImageFactory.html#aba929c4ca4a71625d12bcb97bcc28161" title="Create an Image subclass of the appropriate type by reading the specified file. Image type is derived...">Exiv2::ImageFactory::open</a>(argv[1]);</div>
<div class="line"> assert (image.get() != 0);</div>
<div class="line"> image-&gt;readMetadata();</div>
<div class="line"></div>
<div class="line"> <a name="_a1"></a><a class="code" href="doc/classExiv2_1_1IptcData.html" title="A container for IPTC data. This is a top-level class of the Exiv2 library.">Exiv2::IptcData</a> &amp;iptcData = image-&gt;iptcData();</div>
<div class="line"> <span class="keywordflow">if</span> (iptcData.<a name="a2"></a><a class="code" href="doc/classExiv2_1_1IptcData.html#afda626e27ebecd599005c68022db9c1c" title="Return true if there is no IPTC metadata.">empty</a>()) {</div>
<div class="line"> <a name="a3"></a><a class="code" href="doc/namespaceExiv2.html#a5153319711f35fe81cbc13f4b852450ca2d79fb07c9ec891f281968dad43c1e25" title="IPTC string type.">std::string</a> error(argv[1]);</div>
<div class="line"> error += <span class="stringliteral">&quot;: No IPTC data found in the file&quot;</span>;</div>
<div class="line"> <span class="keywordflow">throw</span> <a name="a4"></a><a class="code" href="doc/namespaceExiv2.html#accd3e49cafe9db52c1e0e6f648753cae" title="Error class used for exceptions (std::string based)">Exiv2::Error</a>(1, error);</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <a class="code" href="doc/classExiv2_1_1IptcData.html#a0d53776cd2f36e63fff78c8f142a7caf" title="IptcMetadata iterator type.">Exiv2::IptcData::iterator</a> end = iptcData.<a name="a5"></a><a class="code" href="doc/classExiv2_1_1IptcData.html#a6753e8a713ab2b42a3bdc7b3d9eab401" title="End of the metadata.">end</a>();</div>
<div class="line"> <span class="keywordflow">for</span> (<a class="code" href="doc/classExiv2_1_1IptcData.html#a0d53776cd2f36e63fff78c8f142a7caf" title="IptcMetadata iterator type.">Exiv2::IptcData::iterator</a> md = iptcData.<a name="a6"></a><a class="code" href="doc/classExiv2_1_1IptcData.html#a03385c128b29d262ade837093fddc0d2" title="Begin of the metadata.">begin</a>(); md != end; ++md) {</div>
<div class="line"> std::cout &lt;&lt; std::setw(44) &lt;&lt; std::setfill(<span class="charliteral">&#39; &#39;</span>) &lt;&lt; std::left</div>
<div class="line"> &lt;&lt; md-&gt;key() &lt;&lt; <span class="stringliteral">&quot; &quot;</span></div>
<div class="line"> &lt;&lt; <span class="stringliteral">&quot;0x&quot;</span> &lt;&lt; std::setw(4) &lt;&lt; std::setfill(<span class="charliteral">&#39;0&#39;</span>) &lt;&lt; std::right</div>
<div class="line"> &lt;&lt; std::hex &lt;&lt; md-&gt;tag() &lt;&lt; <span class="stringliteral">&quot; &quot;</span></div>
<div class="line"> &lt;&lt; std::setw(9) &lt;&lt; std::setfill(<span class="charliteral">&#39; &#39;</span>) &lt;&lt; std::left</div>
<div class="line"> &lt;&lt; md-&gt;typeName() &lt;&lt; <span class="stringliteral">&quot; &quot;</span></div>
<div class="line"> &lt;&lt; std::dec &lt;&lt; std::setw(3)</div>
<div class="line"> &lt;&lt; std::setfill(<span class="charliteral">&#39; &#39;</span>) &lt;&lt; std::right</div>
<div class="line"> &lt;&lt; md-&gt;count() &lt;&lt; <span class="stringliteral">&quot; &quot;</span></div>
<div class="line"> &lt;&lt; std::dec &lt;&lt; md-&gt;value()</div>
<div class="line"> &lt;&lt; std::endl;</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
<div class="line"><span class="keywordflow">catch</span> (<a name="_a7"></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>&amp; e) {</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Caught Exiv2 exception &#39;&quot;</span> &lt;&lt; e &lt;&lt; <span class="stringliteral">&quot;&#39;\n&quot;</span>;</div>
<div class="line"> <span class="keywordflow">return</span> -1;</div>
<div class="line">}</div>
</div><!-- fragment -->

@ -1,50 +1,50 @@
<div class="fragment"><pre><span class="comment">// ***************************************************************** -*- C++ -*-</span>
<span class="comment">// iptceasy.cpp, $Rev: 2286 $</span>
<span class="comment">// The quickest way to access, set or modify IPTC metadata.</span>
<span class="preprocessor">#include &lt;exiv2/exiv2.hpp&gt;</span>
<span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#include &lt;iomanip&gt;</span>
<span class="preprocessor">#include &lt;cassert&gt;</span>
<span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* <span class="keyword">const</span> argv[])
<span class="keyword">try</span> {
<span class="keywordflow">if</span> (argc != 2) {
std::cout &lt;&lt; <span class="stringliteral">"Usage: "</span> &lt;&lt; argv[0] &lt;&lt; <span class="stringliteral">" file\n"</span>;
<span class="keywordflow">return</span> 1;
}
std::string file(argv[1]);
Exiv2::IptcData iptcData;
iptcData[<span class="stringliteral">"Iptc.Application2.Headline"</span>] = <span class="stringliteral">"The headline I am"</span>;
iptcData[<span class="stringliteral">"Iptc.Application2.Keywords"</span>] = <span class="stringliteral">"Yet another keyword"</span>;
iptcData[<span class="stringliteral">"Iptc.Application2.DateCreated"</span>] = <span class="stringliteral">"2004-8-3"</span>;
iptcData[<span class="stringliteral">"Iptc.Application2.Urgency"</span>] = uint16_t(1);
iptcData[<span class="stringliteral">"Iptc.Envelope.ModelVersion"</span>] = 42;
iptcData[<span class="stringliteral">"Iptc.Envelope.TimeSent"</span>] = <span class="stringliteral">"14:41:0-05:00"</span>;
iptcData[<span class="stringliteral">"Iptc.Application2.RasterizedCaption"</span>] = <span class="stringliteral">"230 42 34 2 90 84 23 146"</span>;
iptcData[<span class="stringliteral">"Iptc.0x0009.0x0001"</span>] = <span class="stringliteral">"Who am I?"</span>;
Exiv2::StringValue value;
value.read(<span class="stringliteral">"very!"</span>);
iptcData[<span class="stringliteral">"Iptc.Application2.Urgency"</span>] = value;
std::cout &lt;&lt; <span class="stringliteral">"Time sent: "</span> &lt;&lt; iptcData[<span class="stringliteral">"Iptc.Envelope.TimeSent"</span>] &lt;&lt; <span class="stringliteral">"\n"</span>;
<span class="comment">// Open image file</span>
Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(file);
assert (image.get() != 0);
<span class="comment">// Set IPTC data and write it to the file</span>
image-&gt;setIptcData(iptcData);
image-&gt;writeMetadata();
<span class="keywordflow">return</span> 0;
}
<span class="keywordflow">catch</span> (Exiv2::AnyError&amp; e) {
std::cout &lt;&lt; <span class="stringliteral">"Caught Exiv2 exception '"</span> &lt;&lt; e &lt;&lt; <span class="stringliteral">"'\n"</span>;
<span class="keywordflow">return</span> -1;
}
</pre></div>
<div class="fragment"><div class="line"><span class="comment">// ***************************************************************** -*- C++ -*-</span></div>
<div class="line"><span class="comment">// iptceasy.cpp, $Rev: 3090 $</span></div>
<div class="line"><span class="comment">// The quickest way to access, set or modify IPTC metadata.</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="doc/exiv2_8hpp.html" title="Include all Exiv2 header files.">exiv2/exiv2.hpp</a>&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;iomanip&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;cassert&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* <span class="keyword">const</span> argv[])</div>
<div class="line"><span class="keyword">try</span> {</div>
<div class="line"> <span class="keywordflow">if</span> (argc != 2) {</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Usage: &quot;</span> &lt;&lt; argv[0] &lt;&lt; <span class="stringliteral">&quot; file\n&quot;</span>;</div>
<div class="line"> <span class="keywordflow">return</span> 1;</div>
<div class="line"> }</div>
<div class="line"> <a name="a0"></a><a class="code" href="doc/namespaceExiv2.html#a5153319711f35fe81cbc13f4b852450ca2d79fb07c9ec891f281968dad43c1e25" title="IPTC string type.">std::string</a> file(argv[1]);</div>
<div class="line"></div>
<div class="line"> <a name="_a1"></a><a class="code" href="doc/classExiv2_1_1IptcData.html" title="A container for IPTC data. This is a top-level class of the Exiv2 library.">Exiv2::IptcData</a> iptcData;</div>
<div class="line"></div>
<div class="line"> iptcData[<span class="stringliteral">&quot;Iptc.Application2.Headline&quot;</span>] = <span class="stringliteral">&quot;The headline I am&quot;</span>;</div>
<div class="line"> iptcData[<span class="stringliteral">&quot;Iptc.Application2.Keywords&quot;</span>] = <span class="stringliteral">&quot;Yet another keyword&quot;</span>;</div>
<div class="line"> iptcData[<span class="stringliteral">&quot;Iptc.Application2.DateCreated&quot;</span>] = <span class="stringliteral">&quot;2004-8-3&quot;</span>;</div>
<div class="line"> iptcData[<span class="stringliteral">&quot;Iptc.Application2.Urgency&quot;</span>] = uint16_t(1);</div>
<div class="line"> iptcData[<span class="stringliteral">&quot;Iptc.Envelope.ModelVersion&quot;</span>] = 42;</div>
<div class="line"> iptcData[<span class="stringliteral">&quot;Iptc.Envelope.TimeSent&quot;</span>] = <span class="stringliteral">&quot;14:41:0-05:00&quot;</span>;</div>
<div class="line"> iptcData[<span class="stringliteral">&quot;Iptc.Application2.RasterizedCaption&quot;</span>] = <span class="stringliteral">&quot;230 42 34 2 90 84 23 146&quot;</span>;</div>
<div class="line"> iptcData[<span class="stringliteral">&quot;Iptc.0x0009.0x0001&quot;</span>] = <span class="stringliteral">&quot;Who am I?&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <a name="_a2"></a><a class="code" href="doc/classExiv2_1_1StringValue.html" title="Value for string type.">Exiv2::StringValue</a> value;</div>
<div class="line"> value.<a name="a3"></a><a class="code" href="doc/classExiv2_1_1StringValueBase.html#a6882ba90138a30fcf2123c74f928a75e" title="Read the value from buf. This default implementation uses buf as it is.">read</a>(<span class="stringliteral">&quot;very!&quot;</span>);</div>
<div class="line"> iptcData[<span class="stringliteral">&quot;Iptc.Application2.Urgency&quot;</span>] = value;</div>
<div class="line"></div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Time sent: &quot;</span> &lt;&lt; iptcData[<span class="stringliteral">&quot;Iptc.Envelope.TimeSent&quot;</span>] &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Open image file</span></div>
<div class="line"> <a class="code" href="doc/classExiv2_1_1Image.html#a89ad3ffe7a4e8a943d267d77843415fb" title="Image auto_ptr type.">Exiv2::Image::AutoPtr</a> image = <a name="a4"></a><a class="code" href="doc/classExiv2_1_1ImageFactory.html#aba929c4ca4a71625d12bcb97bcc28161" title="Create an Image subclass of the appropriate type by reading the specified file. Image type is derived...">Exiv2::ImageFactory::open</a>(file);</div>
<div class="line"> assert (image.get() != 0);</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Set IPTC data and write it to the file</span></div>
<div class="line"> image-&gt;setIptcData(iptcData);</div>
<div class="line"> image-&gt;writeMetadata();</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
<div class="line"><span class="keywordflow">catch</span> (<a name="_a5"></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>&amp; e) {</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Caught Exiv2 exception &#39;&quot;</span> &lt;&lt; e &lt;&lt; <span class="stringliteral">&quot;&#39;\n&quot;</span>;</div>
<div class="line"> <span class="keywordflow">return</span> -1;</div>
<div class="line">}</div>
</div><!-- fragment -->

@ -1,148 +1,217 @@
<div class="fragment"><pre><span class="comment">// ***************************************************************** -*- C++ -*-</span>
<span class="comment">// xmpsample.cpp, $Rev: 1305+edit $</span>
<span class="comment">// Sample/test for high level XMP classes. See also addmoddel.cpp</span>
<span class="preprocessor">#include &lt;exiv2/exiv2.hpp&gt;</span>
<span class="preprocessor">#include &lt;string&gt;</span>
<span class="preprocessor">#include &lt;iostream&gt;</span>
<span class="preprocessor">#include &lt;iomanip&gt;</span>
<span class="keywordtype">int</span> main()
<span class="keyword">try</span> {
<span class="comment">// The XMP property container</span>
Exiv2::XmpData 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>] = Exiv2::Rational(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>
Exiv2::XmpTextValue val(<span class="stringliteral">"Seven"</span>);
xmpData[<span class="stringliteral">"Xmp.dc.seven"</span>] = val;
<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>
Exiv2::Value::AutoPtr v = Exiv2::Value::create(Exiv2::xmpText);
v-&gt;read(<span class="stringliteral">"image/jpeg"</span>);
xmpData.add(Exiv2::XmpKey(<span class="stringliteral">"Xmp.dc.format"</span>), v.get());
<span class="comment">// Add an ordered array of text values.</span>
v = Exiv2::Value::create(Exiv2::xmpSeq); <span class="comment">// or xmpBag or xmpAlt.</span>
v-&gt;read(<span class="stringliteral">"1) The first creator"</span>); <span class="comment">// The sequence in which the array</span>
v-&gt;read(<span class="stringliteral">"2) The second creator"</span>); <span class="comment">// elements are added is their</span>
v-&gt;read(<span class="stringliteral">"3) And another one"</span>); <span class="comment">// order in the array.</span>
xmpData.add(Exiv2::XmpKey(<span class="stringliteral">"Xmp.dc.creator"</span>), v.get());
<span class="comment">// Add a language alternative property</span>
v = Exiv2::Value::create(Exiv2::langAlt);
v-&gt;read(<span class="stringliteral">"lang=de-DE Hallo, Welt"</span>); <span class="comment">// The default doesn't need a </span>
v-&gt;read(<span class="stringliteral">"Hello, World"</span>); <span class="comment">// qualifier</span>
xmpData.add(Exiv2::XmpKey(<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>
Exiv2::XmpProperties::registerNs(<span class="stringliteral">"myNamespace/"</span>, <span class="stringliteral">"ns"</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>
Exiv2::XmpTextValue tv(<span class="stringliteral">"16"</span>);
xmpData.add(Exiv2::XmpKey(<span class="stringliteral">"Xmp.xmpDM.videoFrameSize/stDim:w"</span>), &amp;tv);
tv.read(<span class="stringliteral">"9"</span>);
xmpData.add(Exiv2::XmpKey(<span class="stringliteral">"Xmp.xmpDM.videoFrameSize/stDim:h"</span>), &amp;tv);
tv.read(<span class="stringliteral">"inch"</span>);
xmpData.add(Exiv2::XmpKey(<span class="stringliteral">"Xmp.xmpDM.videoFrameSize/stDim:unit"</span>), &amp;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.add(Exiv2::XmpKey(<span class="stringliteral">"Xmp.dc.creator[2]/?ns:role"</span>), &amp;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.add(Exiv2::XmpKey(<span class="stringliteral">"Xmp.xmpBJ.JobRef"</span>), &amp;tv); <span class="comment">// Set the array type.</span>
tv.setXmpArrayType(Exiv2::XmpValue::xaNone);
tv.read(<span class="stringliteral">"Birthday party"</span>);
xmpData.add(Exiv2::XmpKey(<span class="stringliteral">"Xmp.xmpBJ.JobRef[1]/stJob:name"</span>), &amp;tv);
tv.read(<span class="stringliteral">"Photographer"</span>);
xmpData.add(Exiv2::XmpKey(<span class="stringliteral">"Xmp.xmpBJ.JobRef[1]/stJob:role"</span>), &amp;tv);
tv.read(<span class="stringliteral">"Wedding ceremony"</span>);
xmpData.add(Exiv2::XmpKey(<span class="stringliteral">"Xmp.xmpBJ.JobRef[2]/stJob:name"</span>), &amp;tv);
tv.read(<span class="stringliteral">"Best man"</span>);
xmpData.add(Exiv2::XmpKey(<span class="stringliteral">"Xmp.xmpBJ.JobRef[2]/stJob:role"</span>), &amp;tv);
<span class="comment">// -------------------------------------------------------------------------</span>
<span class="comment">// Output XMP properties</span>
<span class="keywordflow">for</span> (Exiv2::XmpData::const_iterator md = xmpData.begin();
md != xmpData.end(); ++md) {
std::cout &lt;&lt; std::setfill(<span class="charliteral">' '</span>) &lt;&lt; std::left
&lt;&lt; std::setw(44)
&lt;&lt; md-&gt;key() &lt;&lt; <span class="stringliteral">" "</span>
&lt;&lt; std::setw(9) &lt;&lt; std::setfill(<span class="charliteral">' '</span>) &lt;&lt; std::left
&lt;&lt; md-&gt;typeName() &lt;&lt; <span class="stringliteral">" "</span>
&lt;&lt; std::dec &lt;&lt; std::setw(3)
&lt;&lt; std::setfill(<span class="charliteral">' '</span>) &lt;&lt; std::right
&lt;&lt; md-&gt;count() &lt;&lt; <span class="stringliteral">" "</span>
&lt;&lt; std::dec &lt;&lt; md-&gt;value()
&lt;&lt; std::endl;
}
<span class="comment">// -------------------------------------------------------------------------</span>
<span class="comment">// Serialize the XMP data and output the XMP packet</span>
std::string xmpPacket;
<span class="keywordflow">if</span> (0 != Exiv2::XmpParser::encode(xmpPacket, xmpData)) {
<span class="keywordflow">throw</span> Exiv2::Error(1, <span class="stringliteral">"Failed to serialize XMP data"</span>);
}
std::cout &lt;&lt; xmpPacket &lt;&lt; <span class="stringliteral">"\n"</span>;
<span class="comment">// Cleanup</span>
Exiv2::XmpParser::terminate();
<span class="keywordflow">return</span> 0;
}
<span class="keywordflow">catch</span> (Exiv2::AnyError&amp; e) {
std::cout &lt;&lt; <span class="stringliteral">"Caught Exiv2 exception '"</span> &lt;&lt; e &lt;&lt; <span class="stringliteral">"'\n"</span>;
<span class="keywordflow">return</span> -1;
}
</pre></div>
<div class="fragment"><div class="line"><span class="comment">// ***************************************************************** -*- C++ -*-</span></div>
<div class="line"><span class="comment">// xmpsample.cpp, $Rev: 3090 $</span></div>
<div class="line"><span class="comment">// Sample/test for high level XMP classes. See also addmoddel.cpp</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="doc/exiv2_8hpp.html" title="Include all Exiv2 header files.">exiv2/exiv2.hpp</a>&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;iomanip&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;cassert&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;cmath&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="keywordtype">bool</span> isEqual(<span class="keywordtype">float</span> a, <span class="keywordtype">float</span> b)</div>
<div class="line">{</div>
<div class="line"> <span class="keywordtype">double</span> d = std::fabs(a - b);</div>
<div class="line"> <span class="keywordflow">return</span> d &lt; 0.00001;</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">int</span> main()</div>
<div class="line"><span class="keyword">try</span> {</div>
<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"></div>
<div class="line"> <span class="comment">// -------------------------------------------------------------------------</span></div>
<div class="line"> <span class="comment">// Teaser: Setting XMP properties doesn&#39;t get much easier than this:</span></div>
<div class="line"></div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.source&quot;</span>] = <span class="stringliteral">&quot;xmpsample.cpp&quot;</span>; <span class="comment">// a simple text value</span></div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.subject&quot;</span>] = <span class="stringliteral">&quot;Palmtree&quot;</span>; <span class="comment">// an array item</span></div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.subject&quot;</span>] = <span class="stringliteral">&quot;Rubbertree&quot;</span>; <span class="comment">// add a 2nd array item</span></div>
<div class="line"> <span class="comment">// a language alternative with two entries and without default</span></div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.title&quot;</span>] = <span class="stringliteral">&quot;lang=de-DE Sonnenuntergang am Strand&quot;</span>;</div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.title&quot;</span>] = <span class="stringliteral">&quot;lang=en-US Sunset on the beach&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// -------------------------------------------------------------------------</span></div>
<div class="line"> <span class="comment">// Any properties can be set provided the namespace is known. Values of any</span></div>
<div class="line"> <span class="comment">// type can be assigned to an Xmpdatum, if they have an output operator. The</span></div>
<div class="line"> <span class="comment">// default XMP value type for unknown properties is a simple text value.</span></div>
<div class="line"></div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.one&quot;</span>] = -1;</div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.two&quot;</span>] = 3.1415;</div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.three&quot;</span>] = <a name="a1"></a><a class="code" href="doc/namespaceExiv2.html#a95756f3f7fa19103f83addf5fa088a30" title="8 byte signed rational type.">Exiv2::Rational</a>(5, 7);</div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.four&quot;</span>] = uint16_t(255);</div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.five&quot;</span>] = int32_t(256);</div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.six&quot;</span>] = <span class="keyword">false</span>;</div>
<div class="line"></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">&quot;Seven&quot;</span>);</div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.seven&quot;</span>] = val;</div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.eight&quot;</span>] = <span class="keyword">true</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Extracting values</span></div>
<div class="line"> assert(xmpData[<span class="stringliteral">&quot;Xmp.dc.one&quot;</span>].toLong() == -1);</div>
<div class="line"> assert(xmpData[<span class="stringliteral">&quot;Xmp.dc.one&quot;</span>].value().ok());</div>
<div class="line"></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> &amp;getv1 = xmpData[<span class="stringliteral">&quot;Xmp.dc.one&quot;</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&lt;Type&gt; 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&lt;Type&gt; 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> &amp;getv2 = xmpData[<span class="stringliteral">&quot;Xmp.dc.two&quot;</span>].value();</div>
<div class="line"> assert(isEqual(getv2.toFloat(), 3.1415f)); </div>
<div class="line"> assert(getv2.ok());</div>
<div class="line"> assert(getv2.toLong() == 3);</div>
<div class="line"> assert(getv2.ok());</div>
<div class="line"> <a class="code" href="doc/namespaceExiv2.html#a95756f3f7fa19103f83addf5fa088a30" title="8 byte signed rational type.">Exiv2::Rational</a> R = getv2.toRational();</div>
<div class="line"> assert(getv2.ok());</div>
<div class="line"> assert(isEqual(static_cast&lt;float&gt;(R.first) / R.second, 3.1415f ));</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> &amp;getv3 = xmpData[<span class="stringliteral">&quot;Xmp.dc.three&quot;</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&lt;Type&gt; 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&lt;Type&gt; 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&lt;Type&gt; 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> &amp;getv6 = xmpData[<span class="stringliteral">&quot;Xmp.dc.six&quot;</span>].value();</div>
<div class="line"> assert(getv6.toLong() == 0);</div>
<div class="line"> assert(getv6.ok());</div>
<div class="line"> assert(getv6.toFloat() == 0.0);</div>
<div class="line"> assert(getv6.ok());</div>
<div class="line"> assert(getv6.toRational() == <a class="code" href="doc/namespaceExiv2.html#a95756f3f7fa19103f83addf5fa088a30" title="8 byte signed rational type.">Exiv2::Rational</a>(0, 1));</div>
<div class="line"> assert(getv6.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> &amp;getv7 = xmpData[<span class="stringliteral">&quot;Xmp.dc.seven&quot;</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> &amp;getv8 = xmpData[<span class="stringliteral">&quot;Xmp.dc.eight&quot;</span>].value();</div>
<div class="line"> assert(getv8.toLong() == 1);</div>
<div class="line"> assert(getv8.ok());</div>
<div class="line"> assert(getv8.toFloat() == 1.0);</div>
<div class="line"> assert(getv8.ok());</div>
<div class="line"> assert(getv8.toRational() == <a class="code" href="doc/namespaceExiv2.html#a95756f3f7fa19103f83addf5fa088a30" title="8 byte signed rational type.">Exiv2::Rational</a>(1, 1));</div>
<div class="line"> assert(getv8.ok());</div>
<div class="line"></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">&quot;Xmp.dc.eight&quot;</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">&quot;Key not found&quot;</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"></div>
<div class="line"> <span class="comment">// -------------------------------------------------------------------------</span></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"> v-&gt;read(<span class="stringliteral">&quot;image/jpeg&quot;</span>);</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">&quot;Xmp.dc.format&quot;</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-&gt;read(<span class="stringliteral">&quot;1) The first creator&quot;</span>); <span class="comment">// The sequence in which the array</span></div>
<div class="line"> v-&gt;read(<span class="stringliteral">&quot;2) The second creator&quot;</span>); <span class="comment">// elements are added is their</span></div>
<div class="line"> v-&gt;read(<span class="stringliteral">&quot;3) And another one&quot;</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">&quot;Xmp.dc.creator&quot;</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-&gt;read(<span class="stringliteral">&quot;lang=de-DE Hallo, Welt&quot;</span>); <span class="comment">// The default doesn&#39;t need a </span></div>
<div class="line"> v-&gt;read(<span class="stringliteral">&quot;Hello, World&quot;</span>); <span class="comment">// qualifier</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">&quot;Xmp.dc.description&quot;</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"> xmpData[<span class="stringliteral">&quot;Xmp.tiff.ImageDescription&quot;</span>] = <span class="stringliteral">&quot;TIFF image description&quot;</span>;</div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.tiff.ImageDescription&quot;</span>] = <span class="stringliteral">&quot;lang=de-DE TIFF Bildbeschreibung&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// -------------------------------------------------------------------------</span></div>
<div class="line"> <span class="comment">// Register a namespace which Exiv2 doesn&#39;t know yet. This is only needed</span></div>
<div class="line"> <span class="comment">// when properties are added manually. If the XMP metadata is read from an</span></div>
<div class="line"> <span class="comment">// image, namespaces are decoded and registered at the same time.</span></div>
<div class="line"> <a name="a18"></a><a class="code" href="doc/classExiv2_1_1XmpProperties.html#ae58ee081625b7924563e93a1ba184fec" title="Register namespace ns with preferred prefix prefix.">Exiv2::XmpProperties::registerNs</a>(<span class="stringliteral">&quot;myNamespace/&quot;</span>, <span class="stringliteral">&quot;ns&quot;</span>);</div>
<div class="line"></div>
<div class="line"> <span class="comment">// -------------------------------------------------------------------------</span></div>
<div class="line"> <span class="comment">// Add a property in the new custom namespace.</span></div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.ns.myProperty&quot;</span>] = <span class="stringliteral">&quot;myValue&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// -------------------------------------------------------------------------</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">&quot;16&quot;</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">&quot;Xmp.xmpDM.videoFrameSize/stDim:w&quot;</span>), &amp;tv);</div>
<div class="line"> tv.read(<span class="stringliteral">&quot;9&quot;</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">&quot;Xmp.xmpDM.videoFrameSize/stDim:h&quot;</span>), &amp;tv);</div>
<div class="line"> tv.read(<span class="stringliteral">&quot;inch&quot;</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">&quot;Xmp.xmpDM.videoFrameSize/stDim:unit&quot;</span>), &amp;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[<span class="stringliteral">&quot;Xmp.dc.publisher&quot;</span>] = <span class="stringliteral">&quot;James Bond&quot;</span>; <span class="comment">// creates an unordered array</span></div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.dc.publisher[1]/?ns:role&quot;</span>] = <span class="stringliteral">&quot;secret agent&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Add a qualifer to an array element of Xmp.dc.creator (added above)</span></div>
<div class="line"> tv.read(<span class="stringliteral">&quot;programmer&quot;</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">&quot;Xmp.dc.creator[2]/?ns:role&quot;</span>), &amp;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">&quot;&quot;</span>); <span class="comment">// Clear the value</span></div>
<div class="line"> tv.setXmpArrayType(Exiv2::XmpValue::xaBag);</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">&quot;Xmp.xmpBJ.JobRef&quot;</span>), &amp;tv); <span class="comment">// Set the array type.</span></div>
<div class="line"></div>
<div class="line"> tv.setXmpArrayType(Exiv2::XmpValue::xaNone);</div>
<div class="line"> tv.read(<span class="stringliteral">&quot;Birthday party&quot;</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">&quot;Xmp.xmpBJ.JobRef[1]/stJob:name&quot;</span>), &amp;tv);</div>
<div class="line"> tv.read(<span class="stringliteral">&quot;Photographer&quot;</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">&quot;Xmp.xmpBJ.JobRef[1]/stJob:role&quot;</span>), &amp;tv);</div>
<div class="line"></div>
<div class="line"> tv.read(<span class="stringliteral">&quot;Wedding ceremony&quot;</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">&quot;Xmp.xmpBJ.JobRef[2]/stJob:name&quot;</span>), &amp;tv);</div>
<div class="line"> tv.read(<span class="stringliteral">&quot;Best man&quot;</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">&quot;Xmp.xmpBJ.JobRef[2]/stJob:role&quot;</span>), &amp;tv);</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Add a creator contact info structure</span></div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCity&quot;</span>] = <span class="stringliteral">&quot;Kuala Lumpur&quot;</span>;</div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCtry&quot;</span>] = <span class="stringliteral">&quot;Malaysia&quot;</span>;</div>
<div class="line"> xmpData[<span class="stringliteral">&quot;Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiUrlWork&quot;</span>] = <span class="stringliteral">&quot;http://www.exiv2.org&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// -------------------------------------------------------------------------</span></div>
<div class="line"> <span class="comment">// Output XMP properties</span></div>
<div class="line"> <span class="keywordflow">for</span> (<a class="code" href="doc/classExiv2_1_1XmpData.html#a9c0a6575296f3da8bfc200091da40f2e" title="XmpMetadata const iterator type.">Exiv2::XmpData::const_iterator</a> md = xmpData.<a name="a19"></a><a class="code" href="doc/classExiv2_1_1XmpData.html#aa6649bbd9d1f35555778febb49d5857a" title="Begin of the metadata.">begin</a>(); </div>
<div class="line"> md != xmpData.<a class="code" href="doc/classExiv2_1_1XmpData.html#a1db4d5a92a7ec0694da08a7dee58faac" title="End of the metadata.">end</a>(); ++md) {</div>
<div class="line"> std::cout &lt;&lt; std::setfill(<span class="charliteral">&#39; &#39;</span>) &lt;&lt; std::left</div>
<div class="line"> &lt;&lt; std::setw(44)</div>
<div class="line"> &lt;&lt; md-&gt;key() &lt;&lt; <span class="stringliteral">&quot; &quot;</span></div>
<div class="line"> &lt;&lt; std::setw(9) &lt;&lt; std::setfill(<span class="charliteral">&#39; &#39;</span>) &lt;&lt; std::left</div>
<div class="line"> &lt;&lt; md-&gt;typeName() &lt;&lt; <span class="stringliteral">&quot; &quot;</span></div>
<div class="line"> &lt;&lt; std::dec &lt;&lt; std::setw(3)</div>
<div class="line"> &lt;&lt; std::setfill(<span class="charliteral">&#39; &#39;</span>) &lt;&lt; std::right</div>
<div class="line"> &lt;&lt; md-&gt;<a name="a20"></a><a class="code" href="doc/classExiv2_1_1XmpData.html#a65b24c7bef3d7e9f2b58edfc19571753" title="Get the number of metadata entries.">count</a>() &lt;&lt; <span class="stringliteral">&quot; &quot;</span></div>
<div class="line"> &lt;&lt; std::dec &lt;&lt; md-&gt;value()</div>
<div class="line"> &lt;&lt; std::endl;</div>
<div class="line"> }</div>
<div class="line"></div>
<div class="line"> <span class="comment">// -------------------------------------------------------------------------</span></div>
<div class="line"> <span class="comment">// Serialize the XMP data and output the XMP packet</span></div>
<div class="line"> <a name="a21"></a><a class="code" href="doc/namespaceExiv2.html#a5153319711f35fe81cbc13f4b852450ca2d79fb07c9ec891f281968dad43c1e25" title="IPTC string type.">std::string</a> xmpPacket;</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">&quot;Failed to serialize XMP data&quot;</span>);</div>
<div class="line"> }</div>
<div class="line"> std::cout &lt;&lt; xmpPacket &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div>
<div class="line"></div>
<div class="line"> <span class="comment">// Cleanup</span></div>
<div class="line"> <a name="a24"></a><a class="code" href="doc/classExiv2_1_1XmpParser.html#a46ff7c85b860ef81310e0ac8dd6b62a2" title="Terminate the XMP Toolkit and unregister custom namespaces.">Exiv2::XmpParser::terminate</a>();</div>
<div class="line"></div>
<div class="line"> <span class="keywordflow">return</span> 0;</div>
<div class="line">}</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>&amp; e) {</div>
<div class="line"> std::cout &lt;&lt; <span class="stringliteral">&quot;Caught Exiv2 exception &#39;&quot;</span> &lt;&lt; e &lt;&lt; <span class="stringliteral">&quot;&#39;\n&quot;</span>;</div>
<div class="line"> <span class="keywordflow">return</span> -1;</div>
<div class="line">}</div>
</div><!-- fragment -->

@ -11,6 +11,10 @@
<title>Exiv2 - Image metadata library and tools</title>
<!-- Doxygen styles -->
<link href="doc/doxygen.css" rel="stylesheet" type="text/css">
<link href="doc/customdoxygen.css" rel="stylesheet" type="text/css">
<!-- Bootstrap core CSS -->
<link href="dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap theme -->

@ -13,7 +13,6 @@
<!-- Doxygen styles -->
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="customdoxygen.css" rel="stylesheet" type="text/css">
<!-- Bootstrap core CSS -->

@ -18,12 +18,12 @@
<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">API doc <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="index.html">Quick start</a></li>
<li><a href="namespaces.html">Namespace list</a></li>
<li><a href="classes.html">Class index</a></li>
<li><a href="hierarchy.html">Class hierarchy</a></li>
<li><a href="files.html">File list</a></li>
<li><a href="examples.html">Examples</a></li>
<li><a href="index.html"><span class="glyphicon glyphicon-home" aria-hidden="true"></span>&nbsp; Quick start</a></li>
<li><a href="namespaceExiv2.html"><span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span>&nbsp; Namespace reference</a></li>
<li><a href="classes.html"><span class="glyphicon glyphicon-th" aria-hidden="true"></span>&nbsp; Class index</a></li>
<li><a href="hierarchy.html"><span class="glyphicon glyphicon-list" aria-hidden="true"></span>&nbsp; Class hierarchy</a></li>
<li><a href="files.html"><span class="glyphicon glyphicon-file" aria-hidden="true"></span>&nbsp; File list</a></li>
<li><a href="../examples.html"><span class="glyphicon glyphicon-star-empty" aria-hidden="true"></span>&nbsp; Examples</a></li>
</ul>
</li>
<li><a href="../manpage.html">Manpage</a></li>

Loading…
Cancel
Save