本文整理汇总了C++中exiv2::iptcdata::iterator::key方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::key方法的具体用法?C++ iterator::key怎么用?C++ iterator::key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exiv2::iptcdata::iterator
的用法示例。
在下文中一共展示了iterator::key方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// *****************************************************************************
// Main
int main(int argc, char* const argv[])
try {
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n";
return 1;
}
Exiv2::IptcData iptcData;
int rc = iptcData.read(argv[1]);
if (rc) {
std::string error = Exiv2::IptcData::strError(rc, argv[1]);
throw Exiv2::Error(error);
}
Exiv2::IptcData::iterator end = iptcData.end();
for (Exiv2::IptcData::iterator i = iptcData.begin(); i != end; ++i) {
std::cout << std::setw(40) << std::setfill(' ') << std::left
<< i->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << i->tag() << " "
<< std::dec << i->value()
<< "\n";
}
return rc;
}
catch (Exiv2::Error& e) {
std::cout << "Caught Exiv2 exception '" << e << "'\n";
return -1;
}
示例2: iptcData
QStringList KExiv2::getIptcSubCategories() const
{
try
{
if (!d->iptcMetadata().empty())
{
QStringList subCategories;
Exiv2::IptcData iptcData(d->iptcMetadata());
for (Exiv2::IptcData::iterator it = iptcData.begin(); it != iptcData.end(); ++it)
{
QString key = QString::fromLocal8Bit(it->key().c_str());
if (key == QString("Iptc.Application2.SuppCategory"))
{
QString val(it->toString().c_str());
subCategories.append(val);
}
}
return subCategories;
}
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot get Iptc Sub Categories from image using Exiv2 ", e);
}
return QStringList();
}
示例3: while
bool KExiv2::removeIptcTag(const char* iptcTagName, bool setProgramName) const
{
if (!setProgramId(setProgramName))
return false;
try
{
Exiv2::IptcData::iterator it = d->iptcMetadata().begin();
int i = 0;
while(it != d->iptcMetadata().end())
{
QString key = QString::fromLocal8Bit(it->key().c_str());
if (key == QString(iptcTagName))
{
it = d->iptcMetadata().erase(it);
++i;
}
else
{
++it;
}
};
if (i > 0)
return true;
}
catch( Exiv2::Error& e )
{
d->printExiv2ExceptionError("Cannot remove Iptc tag using Exiv2 ", e);
}
return false;
}
示例4: gexiv2_metadata_has_iptc_tag
gboolean gexiv2_metadata_has_iptc_tag(GExiv2Metadata *self, const gchar* tag) {
g_return_val_if_fail(GEXIV2_IS_METADATA(self), FALSE);
g_return_val_if_fail(tag != NULL, FALSE);
g_return_val_if_fail(self->priv->image.get() != NULL, FALSE);
Exiv2::IptcData &iptc_data = self->priv->image->iptcData();
for (Exiv2::IptcData::iterator it = iptc_data.begin(); it != iptc_data.end(); ++it) {
if (it->count() > 0 && g_ascii_strcasecmp(tag, it->key().c_str()) == 0)
return TRUE;
}
return FALSE;
}
示例5: getIptcKeywords
bool getIptcKeywords(Exiv2::IptcData &iptcData, bool isIptcUtf8, QStringList &keywords) {
bool anyAdded = false;
try {
QString keywordsTagName = QString::fromLatin1(IPTC_KEYWORDS);
for (Exiv2::IptcData::iterator it = iptcData.begin(); it != iptcData.end(); ++it) {
QString key = QString::fromLocal8Bit(it->key().c_str());
if (key == keywordsTagName) {
QString tag;
if (isIptcUtf8) {
tag = QString::fromUtf8(it->toString().c_str());
} else {
tag = QString::fromLocal8Bit(it->toString().c_str());
}
keywords.append(tag);
anyAdded = true;
}
}
if (keywords.length() == 1 && keywords[0].contains(',')) {
LOG_DEBUG << "processing legacy saved keywords";
QString composite = keywords[0];
keywords.clear();
keywords += decomposeKeyword(composite);
}
}
catch (Exiv2::Error &e) {
LOG_WARNING << "Exiv2 error:" << e.what();
anyAdded = false;
}
catch (...) {
LOG_WARNING << "Exception";
anyAdded = false;
#ifdef QT_DEBUG
throw;
#endif
}
return anyAdded;
}
示例6: gexiv2_metadata_clear_iptc_tag
gboolean gexiv2_metadata_clear_iptc_tag(GExiv2Metadata *self, const gchar* tag) {
g_return_val_if_fail(GEXIV2_IS_METADATA(self), FALSE);
g_return_val_if_fail(tag != NULL, FALSE);
g_return_val_if_fail(self->priv->image.get() != NULL, FALSE);
Exiv2::IptcData &iptc_data = self->priv->image->iptcData();
gboolean erased = FALSE;
Exiv2::IptcData::iterator it = iptc_data.begin();
while (it != iptc_data.end()) {
if (it->count() > 0 && g_ascii_strcasecmp(tag, it->key().c_str()) == 0) {
it = iptc_data.erase(it);
erased = TRUE;
} else {
it++;
}
}
return erased;
}
示例7: MetaDataMap
KExiv2::MetaDataMap KExiv2::getIptcTagsDataList(const QStringList& iptcKeysFilter, bool invertSelection) const
{
if (d->iptcMetadata().empty())
return MetaDataMap();
try
{
Exiv2::IptcData iptcData = d->iptcMetadata();
iptcData.sortByKey();
QString ifDItemName;
MetaDataMap metaDataMap;
for (Exiv2::IptcData::iterator md = iptcData.begin(); md != iptcData.end(); ++md)
{
QString key = QString::fromLocal8Bit(md->key().c_str());
// Decode the tag value with a user friendly output.
std::ostringstream os;
os << *md;
QString value = QString(os.str().c_str());
// To make a string just on one line.
value.replace('\n', ' ');
// Some Iptc key are redondancy. check if already one exist...
MetaDataMap::iterator it = metaDataMap.find(key);
// We apply a filter to get only the Iptc tags that we need.
if (!invertSelection)
{
if (iptcKeysFilter.contains(key.section('.', 1, 1)))
{
if (it == metaDataMap.end())
metaDataMap.insert(key, value);
else
{
QString v = *it;
v.append(", ");
v.append(value);
metaDataMap.insert(key, v);
}
}
}
else
{
if (!iptcKeysFilter.contains(key.section('.', 1, 1)))
{
if (it == metaDataMap.end())
metaDataMap.insert(key, value);
else
{
QString v = *it;
v.append(", ");
v.append(value);
metaDataMap.insert(key, v);
}
}
}
}
return metaDataMap;
}
catch (Exiv2::Error& e)
{
d->printExiv2ExceptionError("Cannot parse Iptc metadata using Exiv2 ", e);
}
return MetaDataMap();
}