Update taglist sample with more functionality

v0.27.3
Robin Mills 7 years ago committed by Luis Díaz Más
parent 19e740b447
commit 8b9cbc5888

@ -10,20 +10,57 @@
#include <exiv2/exiv2.hpp>
#include <string>
#include <iostream>
#include <string>
using namespace Exiv2;
int main(int argc, char* argv[])
try {
{
try {
int rc = 0;
switch (argc) {
case 2:
{
case 2: {
std::string item(argv[1]);
if (item == "Groups") {
/*
https://cgit.kde.org/digikam.git/tree/core/libs/dmetadata/metaengine_exif.cpp#n1077
const Exiv2::GroupInfo* gi = Exiv2::ExifTags::groupList();
while (gi->tagList_ != 0)
{
// NOTE: See BUG #375809 : MPF tags = exception Exiv2 0.26
if (QLatin1String(gi->ifdName_) != QLatin1String("Makernote"))
{
Exiv2::TagListFct tl = gi->tagList_;
const Exiv2::TagInfo* ti = tl();
while (ti->tag_ != 0xFFFF)
{
tags << ti;
++ti;
}
}
++gi;
}
*/
const GroupInfo* groupList = ExifTags::groupList();
int count = 0;
if (groupList) {
while (groupList->tagList_ && count < 10000) {
count++;
std::cout << groupList->groupName_ << std::endl;
groupList++;
}
}
std::cout << "Groups = " << count << std::endl;
break;
}
if (item == "Exif") {
ExifTags::taglist(std::cout);
break;
@ -41,8 +78,7 @@ try {
try {
XmpProperties::printProperties(std::cout, item);
}
catch(const AnyError&) {
} catch (const AnyError&) {
rc = 2;
}
@ -51,19 +87,49 @@ try {
case 1:
ExifTags::taglist(std::cout);
break;
case 3: {
rc = 1; // assume unhappy ending!
std::string item(argv[1]);
std::string name(argv[2]);
if (item == "--group") {
const GroupInfo* groupList = ExifTags::groupList();
if (groupList) {
while (groupList->tagList_) {
int count = 0;
if (name == groupList->groupName_) {
const Exiv2::TagInfo* tagInfo = groupList->tagList_();
while (tagInfo->tag_ != 0xFFFF) {
std::cout << tagInfo->name_ << std::endl;
tagInfo++;
count++;
}
rc = 0; // result is good
std::cout << "Tags = " << count << std::endl;
}
groupList++;
}
}
}
} break;
default:
rc = 1;
break;
}
if (rc) {
std::cout << "Usage: " << argv[0]
<< " [Exif|Canon|CanonCs|CanonSi|CanonCf|Fujifilm|Minolta|Nikon1|Nikon2|Nikon3|Olympus|Panasonic|Pentax|Sigma|Sony|Iptc"
<< " [--group "
"name|Groups|Exif|Canon|CanonCs|CanonSi|CanonCf|Fujifilm|Minolta|Nikon1|Nikon2|Nikon3|Olympus|"
"Panasonic|Pentax|Sigma|Sony|Iptc"
<< "|dc|xmp|xmpRights|xmpMM|xmpBJ|xmpTPg|xmpDM|pdf|photoshop|crs|tiff|exif|aux|iptc]\n"
<< "Print Exif tags, MakerNote tags, or Iptc datasets\n";
}
return rc;
}
catch (AnyError& e) {
} catch (AnyError& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return 1;
}
}

Loading…
Cancel
Save