本文整理汇总了C++中SXMPMeta::DoesStructFieldExist方法的典型用法代码示例。如果您正苦于以下问题:C++ SXMPMeta::DoesStructFieldExist方法的具体用法?C++ SXMPMeta::DoesStructFieldExist怎么用?C++ SXMPMeta::DoesStructFieldExist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SXMPMeta
的用法示例。
在下文中一共展示了SXMPMeta::DoesStructFieldExist方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
opts = kXMPFiles_OpenForUpdate | kXMPFiles_OpenUsePacketScanning;
ok = myFile.OpenFile(filename, kXMP_UnknownFile, opts);
}
// If the file is open then read the metadata
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);
bool exists;
// Read a simple property
string simpleValue; //Stores the value for the property
exists = meta.GetProperty(kXMP_NS_XMP, "CreatorTool", &simpleValue, NULL);
if(exists)
cout << "CreatorTool = " << simpleValue << endl;
else
simpleValue.clear();
// Get the first element in the dc:creator array
string elementValue;
exists = meta.GetArrayItem(kXMP_NS_DC, "creator", 1, &elementValue, NULL);
if(exists)
cout << "dc:creator = " << elementValue << endl;
else
elementValue.clear();
// Get the the entire dc:subject array
string propValue;
int arrSize = meta.CountArrayItems(kXMP_NS_DC, "subject");
for(int i = 1; i <= arrSize;i++)
{
meta.GetArrayItem(kXMP_NS_DC, "subject", i, &propValue, 0);
cout << "dc:subject[" << i << "] = " << propValue << endl;
}
// Get the dc:title for English and French
string itemValue;
string actualLang;
meta.GetLocalizedText(kXMP_NS_DC, "title", "en", "en-US", NULL, &itemValue, NULL);
cout << "dc:title in English = " << itemValue << endl;
meta.GetLocalizedText(kXMP_NS_DC, "title", "fr", "fr-FR", NULL, &itemValue, NULL);
cout << "dc:title in French = " << itemValue << endl;
// Get dc:MetadataDate
XMP_DateTime myDate;
if(meta.GetProperty_Date(kXMP_NS_XMP, "MetadataDate", &myDate, NULL))
{
// Convert the date struct into a convenient string and display it
string myDateStr;
SXMPUtils::ConvertFromDate(myDate, &myDateStr);
cout << "meta:MetadataDate = " << myDateStr << endl;
}
// See if the flash struct exists and see if it was used
string path, value;
exists = meta.DoesStructFieldExist(kXMP_NS_EXIF, "Flash", kXMP_NS_EXIF,"Fired");
if(exists)
{
bool flashFired;
SXMPUtils::ComposeStructFieldPath(kXMP_NS_EXIF, "Flash", kXMP_NS_EXIF, "Fired", &path);
meta.GetProperty_Bool(kXMP_NS_EXIF, path.c_str(), &flashFired, NULL);
string flash = (flashFired) ? "True" : "False";
cout << "Flash Used = " << flash << endl;
}
// Dump the current xmp object to a file
ofstream dumpFile;
dumpFile.open("XMPDump.txt", ios::out);
meta.DumpObject(DumpXMPToFile, &dumpFile);
dumpFile.close();
cout << endl << "XMP dumped to XMPDump.txt" << endl;
// Close the SXMPFile. The resource file is already closed if it was
// opened as read only but this call must still be made.
myFile.CloseFile();
}
else
{
cout << "Unable to open " << filename << endl;
}
}
catch(XMP_Error & e)
{
cout << "ERROR: " << e.GetErrMsg() << endl;
}
// Terminate the toolkit
SXMPFiles::Terminate();
SXMPMeta::Terminate();
return 0;
}