本文整理汇总了C++中SXMPMeta::AppendArrayItem方法的典型用法代码示例。如果您正苦于以下问题:C++ SXMPMeta::AppendArrayItem方法的具体用法?C++ SXMPMeta::AppendArrayItem怎么用?C++ SXMPMeta::AppendArrayItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SXMPMeta
的用法示例。
在下文中一共展示了SXMPMeta::AppendArrayItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xmp_append_array_item
bool xmp_append_array_item(XmpPtr xmp, const char *schema, const char *name,
uint32_t arrayOptions, const char *value,
uint32_t optionBits)
{
CHECK_PTR(xmp, false);
RESET_ERROR;
bool ret = false;
SXMPMeta *txmp = (SXMPMeta *)xmp;
try {
txmp->AppendArrayItem(schema, name, arrayOptions, value,
optionBits);
ret = true;
}
catch(const XMP_Error & e) {
set_error(e);
}
catch(...) {
}
return ret;
}
示例2: 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
示例3: main
/**
* Initializes the toolkit and attempts to open a file for updating its metadata. Initially
* an attempt to open the file is done with a handler, if this fails then the file is opened with
* packet scanning. Once the file is open several properties are read and displayed in the console.
*
* Several properties are then modified, first by checking for their existence and then, if they
* exist, by updating their values. The updated properties are then displayed again in the console.
*
* Next a new XMP object is created from an RDF stream, the properties from the new XMP object are
* appended to the original XMP object and the updated properties are displayed in the console for
* last time.
*
* The updated XMP object is then serialized in different formats and written to text files. Lastly,
* the modified XMP is written back to the resource file.
*/
int main ( int argc, const char * argv[] )
{
if ( argc != 2 ) // 2 := command and 1 parameter
{
cout << "usage: ModifyingXMP (filename)" << endl;
return 0;
}
string filename = string( argv[1] );
if(!SXMPMeta::Initialize())
{
cout << "Could not initialize toolkit!";
return -1;
}
XMP_OptionBits options = 0;
#if UNIX_ENV
options |= kXMPFiles_ServerMode;
#endif
// Must initialize SXMPFiles before we use it
if(SXMPFiles::Initialize(options))
{
try
{
// Options to open the file with - open for editing and use a smart handler
XMP_OptionBits opts = kXMPFiles_OpenForUpdate | kXMPFiles_OpenUseSmartHandler;
bool ok;
SXMPFiles myFile;
std::string status = "";
// First we try and open the file
ok = myFile.OpenFile(filename, kXMP_UnknownFile, opts);
if( ! ok )
{
status += "No smart handler available for " + filename + "\n";
status += "Trying packet scanning.\n";
// Now try using packet scanning
opts = kXMPFiles_OpenForUpdate | kXMPFiles_OpenUsePacketScanning;
ok = myFile.OpenFile(filename, kXMP_UnknownFile, opts);
}
// If the file is open then read get the XMP data
if(ok)
{
cout << status << endl;
cout << filename << " is opened successfully" << endl;
// Create the XMP object and get the XMP data
SXMPMeta meta;
myFile.GetXMP(&meta);
// Display some properties in the console
displayPropertyValues(&meta);
///////////////////////////////////////////////////
// Now modify the XMP
if(meta.DoesPropertyExist(kXMP_NS_XMP, "CreatorTool"))
{
// Update xap:CreatorTool - we don't need to set any option bits
meta.SetProperty(kXMP_NS_XMP, "CreatorTool", "Updated By XMP SDK", 0);
}
// Update the Metadata Date
XMP_DateTime updatedTime;
// Get the current time. This is a UTC time automatically
// adjusted for the local time
SXMPUtils::CurrentDateTime(&updatedTime);
if(meta.DoesPropertyExist(kXMP_NS_XMP, "MetadataDate"))
{
meta.SetProperty_Date(kXMP_NS_XMP, "MetadataDate", updatedTime, 0);
}
// Add an item onto the dc:creator array
// Note the options used, kXMP_PropArrayIsOrdered, if the array does not exist it will be created
meta.AppendArrayItem(kXMP_NS_DC, "creator", kXMP_PropArrayIsOrdered, "Author Name", 0);
meta.AppendArrayItem(kXMP_NS_DC, "creator", kXMP_PropArrayIsOrdered, "Another Author Name", 0);
// Now update alt-text properties
meta.SetLocalizedText(kXMP_NS_DC, "title", "en", "en-US", "An English title");
meta.SetLocalizedText(kXMP_NS_DC, "title", "fr", "fr-FR", "Un titre Francais");
// Display the properties again to show changes
//.........这里部分代码省略.........