本文整理汇总了C++中SXMPMeta::SetQualifier方法的典型用法代码示例。如果您正苦于以下问题:C++ SXMPMeta::SetQualifier方法的具体用法?C++ SXMPMeta::SetQualifier怎么用?C++ SXMPMeta::SetQualifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SXMPMeta
的用法示例。
在下文中一共展示了SXMPMeta::SetQualifier方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: encode
int XmpParser::encode( std::string& xmpPacket,
const XmpData& xmpData,
uint16_t formatFlags,
uint32_t padding)
{ try {
if (xmpData.empty()) {
xmpPacket.clear();
return 0;
}
if (!initialize()) {
#ifndef SUPPRESS_WARNINGS
std::cerr << "XMP Toolkit initialization failed.\n";
#endif
return 2;
}
SXMPMeta meta;
for (XmpData::const_iterator i = xmpData.begin(); i != xmpData.end(); ++i) {
const std::string ns = XmpProperties::ns(i->groupName());
XMP_OptionBits options = 0;
if (i->typeId() == langAlt) {
// Encode Lang Alt property
const LangAltValue* la = dynamic_cast<const LangAltValue*>(&i->value());
if (la == 0) throw Error(43, i->key());
int idx = 1;
// write the default first
LangAltValue::ValueType::const_iterator k = la->value_.find("x-default");
if (k != la->value_.end()) {
#ifdef DEBUG
printNode(ns, i->tagName(), k->second, 0);
#endif
meta.AppendArrayItem(ns.c_str(), i->tagName().c_str(), kXMP_PropArrayIsAlternate, k->second.c_str());
const std::string item = i->tagName() + "[" + toString(idx++) + "]";
meta.SetQualifier(ns.c_str(), item.c_str(), kXMP_NS_XML, "lang", k->first.c_str());
}
for (k = la->value_.begin(); k != la->value_.end(); ++k) {
if (k->first == "x-default") continue;
#ifdef DEBUG
printNode(ns, i->tagName(), k->second, 0);
#endif
meta.AppendArrayItem(ns.c_str(), i->tagName().c_str(), kXMP_PropArrayIsAlternate, k->second.c_str());
const std::string item = i->tagName() + "[" + toString(idx++) + "]";
meta.SetQualifier(ns.c_str(), item.c_str(), kXMP_NS_XML, "lang", k->first.c_str());
}
continue;
}
// Todo: Xmpdatum should have an XmpValue, not a Value
const XmpValue* val = dynamic_cast<const XmpValue*>(&i->value());
assert(val);
options = xmpArrayOptionBits(val->xmpArrayType())
| xmpArrayOptionBits(val->xmpStruct());
if ( i->typeId() == xmpBag
|| i->typeId() == xmpSeq
|| i->typeId() == xmpAlt) {
#ifdef DEBUG
printNode(ns, i->tagName(), "", options);
#endif
meta.SetProperty(ns.c_str(), i->tagName().c_str(), 0, options);
for (int idx = 0; idx < i->count(); ++idx) {
const std::string item = i->tagName() + "[" + toString(idx + 1) + "]";
#ifdef DEBUG
printNode(ns, item, i->toString(idx), 0);
#endif
meta.SetProperty(ns.c_str(), item.c_str(), i->toString(idx).c_str());
}
continue;
}
if (i->typeId() == xmpText) {
if (i->count() == 0) {
#ifdef DEBUG
printNode(ns, i->tagName(), "", options);
#endif
meta.SetProperty(ns.c_str(), i->tagName().c_str(), 0, options);
}
else {
#ifdef DEBUG
printNode(ns, i->tagName(), i->toString(0), options);
#endif
meta.SetProperty(ns.c_str(), i->tagName().c_str(), i->toString(0).c_str(), options);
}
continue;
}
// Don't let any Xmpdatum go by unnoticed
throw Error(38, i->tagName(), TypeInfo::typeName(i->typeId()));
}
std::string tmpPacket;
meta.SerializeToBuffer(&tmpPacket, xmpFormatOptionBits(static_cast<XmpFormatFlags>(formatFlags)), padding); // throws
xmpPacket = tmpPacket;
return 0;
}
catch (const XMP_Error& e) {
#ifndef SUPPRESS_WARNINGS
std::cerr << Error(40, e.GetID(), e.GetErrMsg()) << "\n";
#endif
return 3;
}} // XmpParser::decode