本文整理汇总了C++中XMP_VarString类的典型用法代码示例。如果您正苦于以下问题:C++ XMP_VarString类的具体用法?C++ XMP_VarString怎么用?C++ XMP_VarString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XMP_VarString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetRDFTermKind
static RDFTermKind
GetRDFTermKind ( const XMP_VarString & name )
{
RDFTermKind term = kRDFTerm_Other;
// Arranged to hopefully minimize the parse time for large XMP.
if ( (name.size() > 4) && (strncmp ( name.c_str(), "rdf:", 4 ) == 0) ) {
if ( name == "rdf:li" ) {
term = kRDFTerm_li;
} else if ( name == "rdf:parseType" ) {
term = kRDFTerm_parseType;
} else if ( name == "rdf:Description" ) {
term = kRDFTerm_Description;
} else if ( name == "rdf:about" ) {
term = kRDFTerm_about;
} else if ( name == "rdf:resource" ) {
term = kRDFTerm_resource;
} else if ( name == "rdf:RDF" ) {
term = kRDFTerm_RDF;
} else if ( name == "rdf:ID" ) {
term = kRDFTerm_ID;
} else if ( name == "rdf:nodeID" ) {
term = kRDFTerm_nodeID;
} else if ( name == "rdf:datatype" ) {
term = kRDFTerm_datatype;
} else if ( name == "rdf:aboutEach" ) {
term = kRDFTerm_aboutEach;
} else if ( name == "rdf:aboutEachPrefix" ) {
term = kRDFTerm_aboutEachPrefix;
} else if ( name == "rdf:bagID" ) {
term = kRDFTerm_bagID;
}
}
return term;
} // GetRDFTermKind
开发者ID:BielBdeLuna,项目名称:jp4tools,代码行数:40,代码来源:ParseRDF.cpp
示例2: SplitNameAndValue
static void
SplitNameAndValue ( const XMP_VarString & selStep, XMP_VarString * nameStr, XMP_VarString * valueStr )
{
XMP_StringPtr partBegin = selStep.c_str();
XMP_StringPtr partEnd;
const XMP_StringPtr valueEnd = partBegin + (selStep.size() - 2);
const char quote = *valueEnd;
XMP_Assert ( (*partBegin == '[') && (*(valueEnd+1) == ']') );
XMP_Assert ( (selStep.size() >= 6) && ((quote == '"') || (quote == '\'')) );
// Extract the name part.
++partBegin; // Skip the opening '['.
if ( *partBegin == '?' ) ++partBegin;
for ( partEnd = partBegin+1; *partEnd != '='; ++partEnd ) {};
nameStr->assign ( partBegin, (partEnd - partBegin) );
// Extract the value part, reducing doubled quotes.
XMP_Assert ( *(partEnd+1) == quote );
partBegin = partEnd + 2;
valueStr->erase();
valueStr->reserve ( valueEnd - partBegin ); // Maximum length, don't optimize doubled quotes.
for ( partEnd = partBegin; partEnd < valueEnd; ++partEnd ) {
if ( (*partEnd == quote) && (*(partEnd+1) == quote) ) {
++partEnd;
valueStr->append ( partBegin, (partEnd - partBegin) );
partBegin = partEnd+1; // ! Loop will increment partEnd again.
}
}
valueStr->append ( partBegin, (partEnd - partBegin) ); // ! The loop does not add the last part.
} // SplitNameAndValue
开发者ID:crass,项目名称:dng4ps2,代码行数:39,代码来源:XMPCore_Impl.cpp
示例3: CodePointToUTF8
static void
CodePointToUTF8 ( UniCodePoint uniChar, XMP_VarString & utf8Str )
{
size_t i, byteCount;
XMP_Uns8 buffer [8];
UniCodePoint cpTemp;
if ( uniChar <= 0x7F ) {
i = 7;
byteCount = 1;
buffer[7] = char(uniChar);
} else {
// ---------------------------------------------------------------------------------------
// Copy the data bits from the low order end to the high order end, include the 0x80 mask.
i = 8;
cpTemp = uniChar;
while ( cpTemp != 0 ) {
-- i; // Exit with i pointing to the last byte stored.
buffer[i] = UnsByte(0x80) | (UnsByte(cpTemp) & 0x3F);
cpTemp = cpTemp >> 6;
}
byteCount = 8 - i; // The total number of bytes needed.
XMP_Assert ( (2 <= byteCount) && (byteCount <= 6) );
// -------------------------------------------------------------------------------------
// Make sure the high order byte can hold the byte count mask, compute and set the mask.
size_t bitCount = 0; // The number of data bits in the first byte.
for ( cpTemp = (buffer[i] & UnsByte(0x3F)); cpTemp != 0; cpTemp = cpTemp >> 1 ) bitCount += 1;
if ( bitCount > (8 - (byteCount + 1)) ) byteCount += 1;
i = 8 - byteCount; // First byte index and mask shift count.
XMP_Assert ( (0 <= i) && (i <= 6) );
buffer[i] |= (UnsByte(0xFF) << i) & UnsByte(0xFF); // AUDIT: Safe, i is between 0 and 6.
}
utf8Str.assign ( (char*)(&buffer[i]), byteCount );
} // CodePointToUTF8
开发者ID:BielBdeLuna,项目名称:jp4tools,代码行数:44,代码来源:XMPUtils-FileInfo.cpp
示例4: tableLock
bool XMP_NamespaceTable::Define ( XMP_StringPtr _uri, XMP_StringPtr _suggPrefix,
XMP_StringPtr * prefixPtr, XMP_StringLen * prefixLen )
{
XMP_AutoLock tableLock ( &this->lock, kXMP_WriteLock );
bool prefixMatches = false;
XMP_Assert ( (_uri != 0) && (*_uri != 0) && (_suggPrefix != 0) && (*_suggPrefix != 0) );
XMP_VarString uri ( _uri );
XMP_VarString suggPrefix ( _suggPrefix );
if ( suggPrefix[suggPrefix.size()-1] != ':' ) suggPrefix += ':';
VerifySimpleXMLName ( _suggPrefix, _suggPrefix+suggPrefix.size()-1 ); // Exclude the colon.
XMP_StringMapPos uriPos = this->uriToPrefixMap.find ( uri );
if ( uriPos == this->uriToPrefixMap.end() ) {
// The URI is not yet registered, make sure we use a unique prefix.
XMP_VarString uniqPrefix ( suggPrefix );
int suffix = 0;
char buffer [32]; // AUDIT: Plenty of room for the "_%d_" suffix.
while ( true ) {
if ( this->prefixToURIMap.find ( uniqPrefix ) == this->prefixToURIMap.end() ) break;
++suffix;
snprintf ( buffer, sizeof(buffer), "_%d_:", suffix ); // AUDIT: Using sizeof for snprintf length is safe.
uniqPrefix = suggPrefix;
uniqPrefix.erase ( uniqPrefix.size()-1 ); // ! Remove the trailing ':'.
uniqPrefix += buffer;
}
// Add the new namespace to both maps.
XMP_StringPair newNS ( uri, uniqPrefix );
uriPos = this->uriToPrefixMap.insert ( this->uriToPrefixMap.end(), newNS );
newNS.first.swap ( newNS.second );
(void) this->prefixToURIMap.insert ( this->prefixToURIMap.end(), newNS );
}
// Return the actual prefix and see if it matches the suggested prefix.
if ( prefixPtr != 0 ) *prefixPtr = uriPos->second.c_str();
if ( prefixLen != 0 ) *prefixLen = (XMP_StringLen)uriPos->second.size();
prefixMatches = ( uriPos->second == suggPrefix );
return prefixMatches;
} // XMP_NamespaceTable::Define
开发者ID:crass,项目名称:dngconvert,代码行数:51,代码来源:XMP_LibUtils.cpp
示例5: DumpClearString
void
DumpClearString ( const XMP_VarString & value, XMP_TextOutputProc outProc, void * refCon )
{
char buffer [20];
bool prevNormal;
XMP_Status status = 0;
XMP_StringPtr spanStart, spanEnd;
XMP_StringPtr valueEnd = &value[0] + value.size();
spanStart = &value[0];
while ( spanStart < valueEnd ) {
// Output the next span of regular characters.
for ( spanEnd = spanStart; spanEnd < valueEnd; ++spanEnd ) {
//if ( *spanEnd > 0x7F ) break;
if ( (*spanEnd < 0x20) && (*spanEnd != kTab) && (*spanEnd != kLF) ) break;
}
if ( spanStart != spanEnd ) status = (*outProc) ( refCon, spanStart, (XMP_StringLen)(spanEnd-spanStart) );
if ( status != 0 ) break;
spanStart = spanEnd;
// Output the next span of irregular characters.
prevNormal = true;
for ( spanEnd = spanStart; spanEnd < valueEnd; ++spanEnd ) {
if ( ((0x20 <= *spanEnd) /*&& (*spanEnd <= 0x7F)*/) || (*spanEnd == kTab) || (*spanEnd == kLF) ) break;
char space = ' ';
if ( prevNormal ) space = '<';
status = (*outProc) ( refCon, &space, 1 );
if ( status != 0 ) break;
OutProcHexByte ( *spanEnd );
prevNormal = false;
}
if ( ! prevNormal ) {
status = (*outProc) ( refCon, ">", 1 );
if ( status != 0 ) return;
}
spanStart = spanEnd;
}
} // DumpClearString
开发者ID:crass,项目名称:dngconvert,代码行数:43,代码来源:XMP_LibUtils.cpp
示例6: GetMatchingChildren
void IOUtils::GetMatchingChildren ( XMP_StringVector & matchingChildList, const XMP_VarString & rootPath,
const XMP_StringVector & regExStringVec, XMP_Bool includeFolders, XMP_Bool includeFiles, XMP_Bool prefixRootPath )
{
try
{
XMP_StringVector listOfAllResources;
ListAllChildren (rootPath.c_str(), listOfAllResources, includeFolders, includeFiles, true);
XMP_Bool matchRequired = !regExStringVec.empty();
if ( matchRequired )
{
size_t childCount = listOfAllResources.size();
for ( size_t index = 0; index < childCount; index++ )
{
XMP_Bool match = false;
size_t regExpCount = regExStringVec.size();
for ( size_t index2 = 0; index2 < regExpCount; index2++ )
{
XMP_RegExp regexObj ( regExStringVec[index2].c_str() );
match = regexObj.Match ( listOfAllResources[index].c_str() );
if ( match )
{
if ( prefixRootPath )
{
std::string fullPath = rootPath;
if (fullPath[fullPath.length() - 1] != kDirChar )
fullPath += kDirChar;
fullPath += listOfAllResources[index];
matchingChildList.push_back ( fullPath );
}
else
matchingChildList.push_back ( listOfAllResources[index] );
break;
}
}
}
}
} catch ( XMP_Error & ) {
// do nothing
}
} // GetMatchingChildren
开发者ID:BangL,项目名称:android_external_Focal,代码行数:42,代码来源:IOUtils.cpp
示例7: SerializeAsRDF
static void
SerializeAsRDF ( const XMPMeta & xmpObj,
XMP_VarString & headStr, // Everything up to the padding.
XMP_VarString & tailStr, // Everything after the padding.
XMP_OptionBits options,
XMP_StringPtr newline,
XMP_StringPtr indentStr,
XMP_Index baseIndent )
{
const size_t treeNameLen = xmpObj.tree.name.size();
const size_t indentLen = strlen ( indentStr );
// First estimate the worst case space and reserve room in the output string. This optimization
// avoids reallocating and copying the output as it grows. The initial count does not look at
// the values of properties, so it does not account for character entities, e.g. 
 for newline.
// Since there can be a lot of these in things like the base 64 encoding of a large thumbnail,
// inflate the count by 1/4 (easy to do) to accommodate.
// *** Need to include estimate for alias comments.
size_t outputLen = 2 * (strlen(kPacketHeader) + strlen(kRDF_XMPMetaStart) + strlen(kRDF_RDFStart) + 3*baseIndent*indentLen);
for ( size_t schemaNum = 0, schemaLim = xmpObj.tree.children.size(); schemaNum < schemaLim; ++schemaNum ) {
const XMP_Node * currSchema = xmpObj.tree.children[schemaNum];
outputLen += 2*(baseIndent+2)*indentLen + strlen(kRDF_SchemaStart) + treeNameLen + strlen(kRDF_SchemaEnd) + 2;
outputLen += EstimateRDFSize ( currSchema, baseIndent+2, indentLen );
}
outputLen += (outputLen >> 2); // Inflate by 1/4, an empirical fudge factor.
// Now generate the RDF into the head string as UTF-8.
XMP_Index level;
std::string rdfstring;
headStr.erase();
rdfstring.reserve ( outputLen );
// Write the rdf:RDF start tag.
rdfstring += kRDF_RDFStart;
rdfstring += newline;
// Write all of the properties.
if ( options & kXMP_UseCompactFormat ) {
SerializeCompactRDFSchemas ( xmpObj.tree, rdfstring, newline, indentStr, baseIndent );
} else {
bool useCanonicalRDF = XMP_OptionIsSet ( options, kXMP_UseCanonicalFormat );
SerializeCanonicalRDFSchemas ( xmpObj.tree, rdfstring, newline, indentStr, baseIndent, useCanonicalRDF );
}
// Write the rdf:RDF end tag.
for ( level = baseIndent+1; level > 0; --level ) rdfstring += indentStr;
rdfstring += kRDF_RDFEnd;
// Write the packet header PI.
if ( ! (options & kXMP_OmitPacketWrapper) ) {
for ( level = baseIndent; level > 0; --level ) headStr += indentStr;
headStr += kPacketHeader;
headStr += newline;
}
// Write the xmpmeta element's start tag.
if ( ! (options & kXMP_OmitXMPMetaElement) ) {
for ( level = baseIndent; level > 0; --level ) headStr += indentStr;
headStr += kRDF_XMPMetaStart;
headStr += kXMPCore_VersionMessage "\"";
std::string digestStr;
unsigned char digestBin [16];
if (options & kXMP_IncludeRDFHash)
{
std::string hashrdf;
MD5_CTX context;
MD5Init ( &context );
MD5Update ( &context, (XMP_Uns8*)rdfstring.c_str(), (unsigned int)rdfstring.size() );
MD5Final ( digestBin, &context );
char buffer [40];
for ( int in = 0, out = 0; in < 16; in += 1, out += 2 ) {
XMP_Uns8 byte = digestBin[in];
buffer[out] = kHexDigits [ byte >> 4 ];
buffer[out+1] = kHexDigits [ byte & 0xF ];
}
buffer[32] = 0;
digestStr.append ( buffer );
headStr += " rdfhash=\"";
headStr += digestStr + "\"";
headStr += " merged=\"0\"";
}
headStr += ">";
headStr += newline;
}
开发者ID:yanburman,项目名称:sjcam_raw2dng,代码行数:89,代码来源:XMPMeta-Serialize.cpp
示例8: SerializeCompactRDFSchemas
static void
SerializeCompactRDFSchemas ( const XMP_Node & xmpTree,
XMP_VarString & outputStr,
XMP_StringPtr newline,
XMP_StringPtr indentStr,
XMP_Index baseIndent )
{
XMP_Index level;
size_t schema, schemaLim;
// Begin the rdf:Description start tag.
for ( level = baseIndent+2; level > 0; --level ) outputStr += indentStr;
outputStr += kRDF_SchemaStart;
outputStr += '"';
outputStr += xmpTree.name;
outputStr += '"';
// Write all necessary xmlns attributes.
size_t totalLen = 8; // Start at 8 for "xml:rdf:".
XMP_cStringMapPos currPos = sNamespacePrefixToURIMap->begin();
XMP_cStringMapPos endPos = sNamespacePrefixToURIMap->end();
for ( ; currPos != endPos; ++currPos ) totalLen += currPos->first.size();
XMP_VarString usedNS;
usedNS.reserve ( totalLen );
usedNS = "xml:rdf:";
for ( schema = 0, schemaLim = xmpTree.children.size(); schema != schemaLim; ++schema ) {
const XMP_Node * currSchema = xmpTree.children[schema];
DeclareUsedNamespaces ( currSchema, usedNS, outputStr, newline, indentStr, baseIndent+4 );
}
// Write the top level "attrProps" and close the rdf:Description start tag.
bool allAreAttrs = true;
for ( schema = 0, schemaLim = xmpTree.children.size(); schema != schemaLim; ++schema ) {
const XMP_Node * currSchema = xmpTree.children[schema];
allAreAttrs &= SerializeCompactRDFAttrProps ( currSchema, outputStr, newline, indentStr, baseIndent+3 );
}
if ( ! allAreAttrs ) {
outputStr += ">";
outputStr += newline;
} else {
outputStr += "/>";
outputStr += newline;
return; // ! Done if all properties in all schema are written as attributes.
}
// Write the remaining properties for each schema.
for ( schema = 0, schemaLim = xmpTree.children.size(); schema != schemaLim; ++schema ) {
const XMP_Node * currSchema = xmpTree.children[schema];
SerializeCompactRDFElemProps ( currSchema, outputStr, newline, indentStr, baseIndent+3 );
}
// Write the rdf:Description end tag.
// *** Elide the end tag if everything (all props in all schema) is an attr.
for ( level = baseIndent+2; level > 0; --level ) outputStr += indentStr;
outputStr += kRDF_SchemaEnd;
outputStr += newline;
} // SerializeCompactRDFSchemas
开发者ID:coapp-packages,项目名称:exiv2,代码行数:61,代码来源:XMPMeta-Serialize.cpp
示例9: IgnoreParam
void
XMPMeta::SetLocalizedText ( XMP_StringPtr schemaNS,
XMP_StringPtr arrayName,
XMP_StringPtr _genericLang,
XMP_StringPtr _specificLang,
XMP_StringPtr itemValue,
XMP_OptionBits options )
{
IgnoreParam(options);
XMP_Assert ( (schemaNS != 0) && (arrayName != 0) && (_genericLang != 0) && (_specificLang != 0) ); // Enforced by wrapper.
XMP_VarString zGenericLang ( _genericLang );
XMP_VarString zSpecificLang ( _specificLang );
NormalizeLangValue ( &zGenericLang );
NormalizeLangValue ( &zSpecificLang );
XMP_StringPtr genericLang = zGenericLang.c_str();
XMP_StringPtr specificLang = zSpecificLang.c_str();
XMP_ExpandedXPath arrayPath;
ExpandXPath ( schemaNS, arrayName, &arrayPath );
// Find the array node and set the options if it was just created.
XMP_Node * arrayNode = FindNode ( &tree, arrayPath, kXMP_CreateNodes,
(kXMP_PropValueIsArray | kXMP_PropArrayIsOrdered | kXMP_PropArrayIsAlternate) );
if ( arrayNode == 0 ) XMP_Throw ( "Failed to find or create array node", kXMPErr_BadXPath );
if ( ! XMP_ArrayIsAltText(arrayNode->options) ) {
if ( arrayNode->children.empty() && XMP_ArrayIsAlternate(arrayNode->options) ) {
arrayNode->options |= kXMP_PropArrayIsAltText;
} else {
XMP_Throw ( "Localized text array is not alt-text", kXMPErr_BadXPath );
}
}
// Make sure the x-default item, if any, is first.
size_t itemNum, itemLim;
XMP_Node * xdItem = 0;
bool haveXDefault = false;
for ( itemNum = 0, itemLim = arrayNode->children.size(); itemNum < itemLim; ++itemNum ) {
XMP_Node * currItem = arrayNode->children[itemNum];
XMP_Assert ( XMP_PropHasLang(currItem->options) );
if ( currItem->qualifiers.empty() || (currItem->qualifiers[0]->name != "xml:lang") ) {
XMP_Throw ( "Language qualifier must be first", kXMPErr_BadXPath );
}
if ( currItem->qualifiers[0]->value == "x-default" ) {
xdItem = currItem;
haveXDefault = true;
break;
}
}
if ( haveXDefault && (itemNum != 0) ) {
XMP_Assert ( arrayNode->children[itemNum]->qualifiers[0]->value == "x-default" );
XMP_Node * temp = arrayNode->children[0];
arrayNode->children[0] = arrayNode->children[itemNum];
arrayNode->children[itemNum] = temp;
}
// Find the appropriate item. ChooseLocalizedText will make sure the array is a language alternative.
const XMP_Node * cItemNode; // ! ChooseLocalizedText returns a pointer to a const node.
XMP_CLTMatch match = ChooseLocalizedText ( arrayNode, genericLang, specificLang, &cItemNode );
XMP_Node * itemNode = const_cast<XMP_Node*> ( cItemNode );
const bool specificXDefault = XMP_LitMatch ( specificLang, "x-default" );
switch ( match ) {
case kXMP_CLT_NoValues :
// Create the array items for the specificLang and x-default, with x-default first.
AppendLangItem ( arrayNode, "x-default", itemValue );
haveXDefault = true;
if ( ! specificXDefault ) AppendLangItem ( arrayNode, specificLang, itemValue );
break;
case kXMP_CLT_SpecificMatch :
if ( ! specificXDefault ) {
// Update the specific item, update x-default if it matches the old value.
if ( xdItem != NULL && haveXDefault && (xdItem != itemNode) && (xdItem->value == itemNode->value) ) {
SetNodeValue ( xdItem, itemValue );
}
SetNodeValue ( itemNode, itemValue ); // ! Do this after the x-default check!
} else {
// Update all items whose values match the old x-default value.
XMP_Assert ( xdItem != NULL && haveXDefault && (xdItem == itemNode) );
for ( itemNum = 0, itemLim = arrayNode->children.size(); itemNum < itemLim; ++itemNum ) {
XMP_Node * currItem = arrayNode->children[itemNum];
if ( (currItem == xdItem) || (currItem->value != xdItem->value) ) continue;
SetNodeValue ( currItem, itemValue );
}
SetNodeValue ( xdItem, itemValue ); // And finally do the x-default item.
}
break;
case kXMP_CLT_SingleGeneric :
//.........这里部分代码省略.........
开发者ID:hfiguiere,项目名称:exempi,代码行数:101,代码来源:XMPMeta-GetSet.cpp
示例10: SerializeAsRDF
static void
SerializeAsRDF ( const XMPMeta & xmpObj,
XMP_VarString & headStr, // Everything up to the padding.
XMP_VarString & tailStr, // Everything after the padding.
XMP_OptionBits options,
XMP_StringPtr newline,
XMP_StringPtr indentStr,
XMP_Index baseIndent )
{
const size_t treeNameLen = xmpObj.tree.name.size();
const size_t indentLen = strlen ( indentStr );
// First estimate the worst case space and reserve room in the output string. This optimization
// avoids reallocating and copying the output as it grows. The initial count does not look at
// the values of properties, so it does not account for character entities, e.g. 
 for newline.
// Since there can be a lot of these in things like the base 64 encoding of a large thumbnail,
// inflate the count by 1/4 (easy to do) to accommodate.
// *** Need to include estimate for alias comments.
size_t outputLen = 2 * (strlen(kPacketHeader) + strlen(kRDF_XMPMetaStart) + strlen(kRDF_RDFStart) + 3*baseIndent*indentLen);
for ( size_t schemaNum = 0, schemaLim = xmpObj.tree.children.size(); schemaNum < schemaLim; ++schemaNum ) {
const XMP_Node * currSchema = xmpObj.tree.children[schemaNum];
outputLen += 2*(baseIndent+2)*indentLen + strlen(kRDF_SchemaStart) + treeNameLen + strlen(kRDF_SchemaEnd) + 2;
outputLen += EstimateRDFSize ( currSchema, baseIndent+2, indentLen );
}
outputLen += (outputLen >> 2); // Inflate by 1/4, an empirical fudge factor.
// Now generate the RDF into the head string as UTF-8.
XMP_Index level;
headStr.erase();
headStr.reserve ( outputLen );
// Write the packet header PI.
if ( ! (options & kXMP_OmitPacketWrapper) ) {
for ( level = baseIndent; level > 0; --level ) headStr += indentStr;
headStr += kPacketHeader;
headStr += newline;
}
// Write the xmpmeta element's start tag.
if ( ! (options & kXMP_OmitXMPMetaElement) ) {
for ( level = baseIndent; level > 0; --level ) headStr += indentStr;
headStr += kRDF_XMPMetaStart;
headStr += kXMPCore_VersionMessage "\">";
headStr += newline;
}
// Write the rdf:RDF start tag.
for ( level = baseIndent+1; level > 0; --level ) headStr += indentStr;
headStr += kRDF_RDFStart;
headStr += newline;
// Write all of the properties.
if ( options & kXMP_UseCompactFormat ) {
SerializeCompactRDFSchemas ( xmpObj.tree, headStr, newline, indentStr, baseIndent );
} else {
if ( xmpObj.tree.children.size() > 0 ) {
for ( size_t schemaNum = 0, schemaLim = xmpObj.tree.children.size(); schemaNum < schemaLim; ++schemaNum ) {
const XMP_Node * currSchema = xmpObj.tree.children[schemaNum];
SerializePrettyRDFSchema ( xmpObj.tree.name, currSchema, headStr, options, newline, indentStr, baseIndent );
}
} else {
for ( XMP_Index level = baseIndent+2; level > 0; --level ) headStr += indentStr;
headStr += kRDF_SchemaStart; // Special case an empty XMP object.
headStr += '"';
headStr += xmpObj.tree.name;
headStr += "\"/>";
headStr += newline;
}
}
// Write the rdf:RDF end tag.
for ( level = baseIndent+1; level > 0; --level ) headStr += indentStr;
headStr += kRDF_RDFEnd;
headStr += newline;
// Write the xmpmeta end tag.
if ( ! (options & kXMP_OmitXMPMetaElement) ) {
for ( level = baseIndent; level > 0; --level ) headStr += indentStr;
headStr += kRDF_XMPMetaEnd;
headStr += newline;
}
// Write the packet trailer PI into the tail string as UTF-8.
tailStr.erase();
if ( ! (options & kXMP_OmitPacketWrapper) ) {
tailStr.reserve ( strlen(kPacketTrailer) + (strlen(indentStr) * baseIndent) );
for ( level = baseIndent; level > 0; --level ) tailStr += indentStr;
tailStr += kPacketTrailer;
if ( options & kXMP_ReadOnlyPacket ) tailStr[tailStr.size()-4] = 'r';
}
// ! This assert is just a performance check, to see if the reserve was enough.
// *** XMP_Assert ( headStr.size() <= outputLen );
// *** Don't use an assert. Think of some way to track this without risk of aborting the client.
//.........这里部分代码省略.........
开发者ID:coapp-packages,项目名称:exiv2,代码行数:101,代码来源:XMPMeta-Serialize.cpp
示例11: SerializePrettyRDFSchema
static void
SerializePrettyRDFSchema ( const XMP_VarString & treeName,
const XMP_Node * schemaNode,
XMP_VarString & outputStr,
XMP_OptionBits options,
XMP_StringPtr newline,
XMP_StringPtr indentStr,
XMP_Index baseIndent )
{
XMP_Assert ( schemaNode->options & kXMP_SchemaNode );
XMP_Assert ( schemaNode->qualifiers.empty() );
// Write the rdf:Description start tag with the namespace declarations.
XMP_Index level;
for ( level = baseIndent+2; level > 0; --level ) outputStr += indentStr;
outputStr += kRDF_SchemaStart;
outputStr += '"';
outputStr += treeName;
outputStr += '"';
size_t totalLen = 8; // Start at 8 for "xml:rdf:".
XMP_cStringMapPos currPos = sNamespacePrefixToURIMap->begin();
XMP_cStringMapPos endPos = sNamespacePrefixToURIMap->end();
for ( ; currPos != endPos; ++currPos ) totalLen += currPos->first.size();
XMP_VarString usedNS;
usedNS.reserve ( totalLen );
usedNS = "xml:rdf:";
DeclareUsedNamespaces ( schemaNode, usedNS, outputStr, newline, indentStr, baseIndent+4 );
outputStr += ">";
outputStr += newline;
// Write alias comments, if wanted.
if ( options & kXMP_WriteAliasComments ) { // *** Hoist into a routine, used for Plain XMP also.
#if 0 // *** Buggy, disable for now.
XMP_cAliasMapPos aliasPos = sRegisteredAliasMap->begin();
XMP_cAliasMapPos aliasEnd = sRegisteredAliasMap->end();
for ( ; aliasPos != aliasEnd; ++aliasPos ) {
size_t nsPos = aliasPos->first.find ( schemaNode->value );
if ( nsPos == XMP_VarString::npos ) continue;
XMP_Assert ( nsPos == 0 );
for ( level = baseIndent+3; level > 0; --level ) outputStr += indentStr;
outputStr += "<!-- ";
outputStr += aliasPos->first;
outputStr += " is aliased to ";
for ( size_t step = 1, stepLim = aliasPos->second.size(); step != stepLim; ++step ) {
outputStr += aliasPos->second[step].step;
}
outputStr += " -->";
outputStr += newline;
}
#endif
}
// Write each of the schema's actual properties.
for ( size_t propNum = 0, propLim = schemaNode->children.size(); propNum < propLim; ++propNum ) {
const XMP_Node * currProp = schemaNode->children[propNum];
SerializePrettyRDFProperty ( currProp, outputStr, newline, indentStr, baseIndent+3 );
}
// Write the rdf:Description end tag.
for ( level = baseIndent+2; level > 0; --level ) outputStr += indentStr;
outputStr += kRDF_SchemaEnd;
outputStr += newline;
} // SerializePrettyRDFSchema
开发者ID:coapp-packages,项目名称:exiv2,代码行数:78,代码来源:XMPMeta-Serialize.cpp
示例12: XMP_Assert
void
XMPMeta::DeleteLocalizedText ( XMP_StringPtr schemaNS,
XMP_StringPtr arrayName,
XMP_StringPtr _genericLang,
XMP_StringPtr _specificLang )
{
XMP_Assert ( (schemaNS != 0) && (arrayName != 0) && (_genericLang != 0) && (_specificLang != 0) ); // Enforced by wrapper.
XMP_VarString zGenericLang ( _genericLang );
XMP_VarString zSpecificLang ( _specificLang );
NormalizeLangValue ( &zGenericLang );
NormalizeLangValue ( &zSpecificLang );
XMP_StringPtr genericLang = zGenericLang.c_str();
XMP_StringPtr specificLang = zSpecificLang.c_str();
XMP_ExpandedXPath arrayPath;
ExpandXPath ( schemaNS, arrayName, &arrayPath );
// Find the LangAlt array and the selected array item.
XMP_Node * arrayNode = FindNode ( &tree, arrayPath, kXMP_ExistingOnly );
if ( arrayNode == 0 ) return;
size_t arraySize = arrayNode->children.size();
XMP_CLTMatch match;
XMP_Node * itemNode;
match = ChooseLocalizedText ( arrayNode, genericLang, specificLang, (const XMP_Node **) &itemNode );
if ( match != kXMP_CLT_SpecificMatch ) return;
size_t itemIndex = 0;
for ( ; itemIndex < arraySize; ++itemIndex ) {
if ( arrayNode->children[itemIndex] == itemNode ) break;
}
XMP_Enforce ( itemIndex < arraySize );
// Decide if the selected item is x-default or not, find relevant matching item.
bool itemIsXDefault = false;
if ( ! itemNode->qualifiers.empty() ) {
XMP_Node * qualNode = itemNode->qualifiers[0];
if ( (qualNode->name == "xml:lang") && (qualNode->value == "x-default") ) itemIsXDefault = true;
}
if ( itemIsXDefault && (itemIndex != 0) ) { // Enforce the x-default is first policy.
XMP_Node * temp = arrayNode->children[0];
arrayNode->children[0] = arrayNode->children[itemIndex];
arrayNode->children[itemIndex] = temp;
itemIndex = 0;
}
XMP_Node * assocNode = 0;
size_t assocIndex;
if ( itemIsXDefault ) {
for ( assocIndex = 1; assocIndex < arraySize; ++assocIndex ) {
if ( arrayNode->children[assocIndex]->value == itemNode->value ) {
assocNode = arrayNode->children[assocIndex];
break;
}
}
} else if ( itemIndex > 0 ) {
XMP_Node * itemZero = arrayNode->children[0];
if ( itemZero->value == itemNode->value ) {
XMP_Node * qualNode = itemZero->qualifiers[0];
if ( (qualNode->name == "xml:lang") && (qualNode->value == "x-default") ) {
assocNode = arrayNode->children[0];
assocIndex = 0;
}
}
}
// Delete the appropriate nodes.
XMP_NodePtrPos arrayBegin = arrayNode->children.begin();
if ( assocNode == 0 ) {
arrayNode->children.erase ( arrayBegin + itemIndex );
} else if ( itemIndex < assocIndex ) {
arrayNode->children.erase ( arrayBegin + assocIndex );
arrayNode->children.erase ( arrayBegin + itemIndex );
} else {
arrayNode->children.erase ( arrayBegin + itemIndex );
arrayNode->children.erase ( arrayBegin + assocIndex );
}
delete itemNode;
if ( assocNode != 0 ) delete assocNode;
} // DeleteLocalizedText
开发者ID:hfiguiere,项目名称:exempi,代码行数:95,代码来源:XMPMeta-GetSet.cpp
示例13: clientRefs
XMPIterator::XMPIterator ( const XMPMeta & xmpObj,
XMP_StringPtr schemaNS,
XMP_StringPtr propName,
XMP_OptionBits options ) : clientRefs(0), info(IterInfo(options,&xmpObj))
{
if ( (options & kXMP_IterClassMask) != kXMP_IterProperties ) {
XMP_Throw ( "Unsupported iteration kind", kXMPErr_BadOptions );
}
// *** Lock the XMPMeta object if we ever stop using a full DLL lock.
if ( *propName != 0 ) {
// An iterator rooted at a specific node.
#if TraceIterators
printf ( "\nNew XMP property iterator for \"%s\", options = %X\n Schema = %s, root = %s\n",
xmpObj.tree.name.c_str(), options, schemaNS, propName );
#endif
XMP_ExpandedXPath propPath;
ExpandXPath ( schemaNS, propName, &propPath );
XMP_Node * propNode = FindConstNode ( &xmpObj.tree, propPath ); // If not found get empty iteration.
if ( propNode != 0 ) {
XMP_VarString rootName ( propPath[1].step ); // The schema is [0].
for ( size_t i = 2; i < propPath.size(); ++i ) {
XMP_OptionBits stepKind = GetStepKind ( propPath[i].options );
if ( stepKind <= kXMP_QualifierStep ) rootName += '/';
rootName += propPath[i].step;
}
propName = rootName.c_str();
size_t leafOffset = rootName.size();
while ( (leafOffset > 0) && (propName[leafOffset] != '/') && (propName[leafOffset] != '[') ) --leafOffset;
if ( propName[leafOffset] == '/' ) ++leafOffset;
info.tree.children.push_back ( IterNode ( propNode->options, propName, leafOffset ) );
SetCurrSchema ( info, propPath[kSchemaStep].step.c_str() );
if ( info.options & kXMP_IterJustChildren ) {
AddNodeOffspring ( info, info.tree.children.back(), propNode );
}
}
} else if ( *schemaNS != 0 ) {
// An iterator for all properties in one schema.
#if TraceIterators
printf ( "\nNew XMP schema iterator for \"%s\", options = %X\n Schema = %s\n",
xmpObj.tree.name.c_str(), options, schemaNS );
#endif
info.tree.children.push_back ( IterNode ( kXMP_SchemaNode, schemaNS, 0 ) );
IterNode & iterSchema = info.tree.children.back();
XMP_Node * xmpSchema = FindConstSchema ( &xmpObj.tree, schemaNS );
if ( xmpSchema != 0 ) AddSchemaProps ( info, iterSchema, xmpSchema );
if ( info.options & kXMP_IterIncludeAliases ) AddSchemaAliases ( info, iterSchema, schemaNS );
if ( iterSchema.children.empty() ) {
info.tree.children.pop_back(); // No properties, remove the schema node.
} else {
SetCurrSchema ( info, schemaNS );
}
} else {
// An iterator for all properties in all schema. First add schema that exist (have children),
// adding aliases from them if appropriate. Then add schema that have no actual properties
// but do have aliases to existing properties, if we're including aliases in the iteration.
#if TraceIterators
printf ( "\nNew XMP tree iterator for \"%s\", options = %X\n",
xmpObj.tree.name.c_str(), options );
#endif
// First pick up the schema that exist.
for ( size_t schemaNum = 0, schemaLim = xmpObj.tree.children.size(); schemaNum != schemaLim; ++schemaNum ) {
const XMP_Node * xmpSchema = xmpObj.tree.children[schemaNum];
info.tree.children.push_back ( IterNode ( kXMP_SchemaNode, xmpSchema->name, 0 ) );
IterNode & iterSchema = info.tree.children.back();
if ( ! (info.options & kXMP_IterJustChildren) ) {
AddSchemaProps ( info, iterSchema, xmpSchema );
if ( info.options & kXMP_IterIncludeAliases ) AddSchemaAliases ( info, iterSchema, xmpSchema->name.c_str() );
if ( iterSchema.children.empty() ) info.tree.children.pop_back(); // No properties, remove the schema node.
}
}
if ( info.options & kXMP_IterIncludeAliases ) {
// Add the schema that only have aliases. The most convenient, and safest way, is to go
// through the registered namespaces, see if it exists, and let AddSchemaAliases do its
//.........这里部分代码省略.........
开发者ID:dtbinh,项目名称:dviz,代码行数:101,代码来源:XMPIterator.cpp
示例14: warning
namespace DngXmpSdk {
#if XMP_WinBuild
#pragma warning ( disable : 4996 ) // '...' was declared deprecated
#endif
// *** Set memory handlers.
#ifndef DumpXMLParseEvents
#define DumpXMLParseEvents 0
#endif
#define FullNameSeparator '@'
// =================================================================================================
static void StartNamespaceDeclHandler ( void * userData, XMP_StringPtr prefix, XMP_StringPtr uri );
static void EndNamespaceDeclHandler ( void * userData, XMP_StringPtr prefix );
static void StartElementHandler ( void * userData, XMP_StringPtr name, XMP_StringPtr* attrs );
static void EndElementHandler ( void * userData, XMP_StringPtr name );
static void CharacterDataHandler ( void * userData, XMP_StringPtr cData, int len );
static void StartCdataSectionHandler ( void * userData );
static void EndCdataSectionHandler ( void * userData );
static void ProcessingInstructionHandler ( void * userData, XMP_StringPtr target, XMP_StringPtr data );
static void CommentHandler ( void * userData, XMP_StringPtr comment );
#if BanAllEntityUsage
// For now we do this by banning DOCTYPE entirely. This is easy and consistent with what is
// available in recent Java XML parsers. Another, somewhat less drastic, approach would be to
// ban all entity declarations. We can't allow declarations and ban references, Expat does not
// call the SkippedEntityHandler for references in attribute values.
// ! Standard entities (&, <, >, ", ', and numeric character references) are
// ! not banned. Expat handles them transparently no matter what.
static void StartDoctypeDeclHandler ( void * userData, XMP_StringPtr doctypeName,
XMP_StringPtr sysid, XMP_StringPtr pubid, int has_internal_subset );
#endif
// =================================================================================================
extern "C" ExpatAdapter * XMP_NewExpatAdapter()
{
return new ExpatAdapter;
} // XMP_NewExpatAdapter
// =================================================================================================
ExpatAdapter::ExpatAdapter() : parser(0)
{
#if XMP_DebugBuild
this->elemNesting = 0;
#if DumpXMLParseEvents
if ( this->parseLog == 0 ) this->parseLog = stdout;
#endif
#endif
this->parser = XML_ParserCreateNS ( 0, FullNameSeparator );
if ( this->parser == 0 ) XMP_Throw ( "Failure creating Expat parser", kXMPErr_ExternalFailure );
XML_SetUserData ( this->parser, this );
XML_SetNamespaceDeclHandler ( this->parser, StartNamespaceDeclHandler, EndNamespaceDeclHandler );
XML_SetElementHandler ( this->parser, StartElementHandler, EndElementHandler );
XML_SetCharacterDataHandler ( this->parser, CharacterDataHandler );
XML_SetCdataSectionHandler ( this->parser, StartCdataSectionHandler, EndCdataSectionHandler );
XML_SetProcessingInstructionHandler ( this->parser, ProcessingInstructionHandler );
XML_SetCommentHandler ( this->parser, CommentHandler );
#if BanAllEntityUsage
XML_SetStartDoctypeDeclHandler ( this->parser, StartDoctypeDeclHandler );
isAborted = false;
#endif
this->parseStack.push_back ( &this->tree ); // Push the XML root node.
} // ExpatAdapter::ExpatAdapter
// =================================================================================================
ExpatAdapter::~ExpatAdapter()
{
if ( this->parser != 0 ) XML_ParserFree ( this->parser );
this->parser = 0;
} // ExpatAdapter::~ExpatAdapter
// =================================================================================================
#if XMP_DebugBuild
static XMP_VarString sExpatMessage;
#endif
//.........这里部分代码省略.........
开发者ID:KDE,项目名称:digikam,代码行数:101,代码来源:ExpatAdapter.cpp
示例15: XMP_Assert
void
ExpandXPath ( XMP_StringPtr schemaNS,
XMP_StringPtr propPath,
XMP_ExpandedXPath * expandedXPath )
{
XMP_Assert ( (schemaNS != 0) && (propPath != 0) && (*propPath != 0) && (expandedXPath != 0) );
XMP_StringPtr stepBegin, stepEnd;
XMP_StringPtr qualName, nameEnd;
XMP_VarString currStep;
size_t resCount = 2; // Guess at the number of steps. At least 2, plus 1 for each '/' or '['.
for ( stepEnd = propPath; *stepEnd != 0; ++stepEnd ) {
if ( (*stepEnd == '/') || (*stepEnd == '[') ) ++resCount;
}
expandedXPath->clear();
expandedXPath->reserve ( resCount );
// -------------------------------------------------------------------------------------------
// Pull out the first component and do some special processing on it: add the schema namespace
// prefix and see if it is an alias. The start must be a qualName.
stepBegin = propPath;
stepEnd = stepBegin;
while ( (*stepEnd != 0) && (*stepEnd != '/') && (*stepEnd != '[') && (*stepEnd != '*') ) ++stepEnd;
if ( stepEnd == stepBegin ) XMP_Throw ( "Empty initial XPath step", kXMPErr_BadXPath );
currStep.assign ( stepBegin, (stepEnd - stepBegin) );
VerifyXPathRoot ( schemaNS, currStep.c_str(), expandedXPath );
XMP_OptionBits stepFlags = kXMP_StructFieldStep;
if ( sRegisteredAliasMap->find ( (*expandedXPath)[kRootPropStep].step ) != sRegisteredAliasMap->end() ) {
stepFlags |= kXMP_StepIsAlias;
}
(*expandedXPath)[kRootPropStep].options |= stepFlags;
// -----------------------------------------------------
// Now continue to process the rest of the XPath string.
while ( *stepEnd != 0 ) {
stepBegin = stepEnd;
if ( *stepBegin == '/' ) ++stepBegin;
if ( *stepBegin == '*' ) {
++stepBegin;
if ( *stepBegin != '[' ) XMP_Throw ( "Missing '[' after '*'", kXMPErr_BadXPath );
}
stepEnd = stepBegin;
if ( *stepBegin != '[' ) {
// A struct field or qualifier.
qualName = stepBegin;
while ( (*stepEnd != 0) && (*stepEnd != '/') && (*stepEnd != '[') && (*stepEnd != '*') ) ++stepEnd;
nameEnd = stepEnd;
stepFlags = kXMP_StructFieldStep; // ! Touch up later, also changing '@' to '?'.
} else {
// One of the array forms.
++stepEnd; // Look at the character after the leading '['.
if ( ('0' <= *stepEnd) && (*stepEnd <= '9') ) {
// A numeric (decimal integer) array index.
while ( (*stepEnd != 0) && ('0' <= *stepEnd) && (*stepEnd <= '9') ) ++stepEnd;
if ( *stepEnd != ']' ) XMP_Throw ( "Missing ']' for integer array index", kXMPErr_BadXPath );
stepFlags = kXMP_ArrayIndexStep;
} else {
// Could be "[last()]" or one of the selector forms. Find the ']' or '='.
while ( (*stepEnd != 0) && (*stepEnd != ']') && (*stepEnd != '=') ) ++stepEnd;
if ( *stepEnd == 0 ) XMP_Throw ( "Missing ']' or '=' for array index", kXMPErr_BadXPath );
if ( *stepEnd == ']' ) {
if ( strncmp ( "[last()", stepBegin, (stepEnd - stepBegin) ) != 0 ) {
XMP_Throw ( "Invalid non-numeric array index", kXMPErr_BadXPath );
}
stepFlags = kXMP_ArrayLastStep;
} else {
qualName = stepBegin+1;
nameEnd = stepEnd;
++stepEnd; // Absorb the '=', remember the quote.
const char quote = *stepEnd;
if ( (quote != '\'') && (quote != '"') ) {
XMP_Throw ( "Invalid quote in array selector", kXMPErr_BadXPath );
}
++stepEnd; // Absorb the leading quote.
while ( *stepEnd != 0 ) {
if ( *stepEnd == quote ) {
if ( *(stepEnd+1) != quote ) break;
++stepEnd;
//.........这里部分代码省略.........
开发者ID:crass,项目名称:dng4ps2,代码行数:101,代码来源:XMPCore_Impl.cpp
示例16: clientRefs
XMPIterator::XMPIterator ( const XMPMeta & xmpObj,
XMP_StringPtr schemaNS,
XMP_StringPtr propName,
XMP_OptionBits options ) : clientRefs(0), info(IterInfo(options,&xmpObj))
{
if ( (options & kXMP_IterClassMask) != kXMP_IterProperties ) {
XMP_Throw ( "Unsupported iteration kind", kXMPErr_BadOptions );
}
// *** Lock the XMPMeta object if we ever stop using a full DLL lock.
if ( *propName != 0 ) {
// An iterator rooted at a specific node.
#if TraceIterators
printf ( "\nNew XMP property iterator for \"%s\", options = %X\n Schema = %s, root = %s\n",
xmpObj.tree.name.c_str(), options, schemaNS, propName );
#endif
XMP_ExpandedXPath propPath;
ExpandXPath ( schemaNS, propName, &propPath );
XMP_Node * propNode = FindConstNode ( &xmpObj.tree, propPath ); // If not found get empty iteration.
if ( propNode != 0 ) {
XMP_VarString rootName ( propPath[1].step ); // The schema is [0].
for ( size_t i = 2; i < propPath.size(); ++i ) {
XMP_OptionBits stepKind = GetStepKind ( propPath[i].options );
if ( stepKind <= kXMP_QualifierStep ) rootName += '/';
rootName += propPath[i].step;
}
propName = rootName.c_str();
size_t leafOffset = rootName.size();
while ( (leafOffset > 0) && (propName[leafOffset] != '
|
请发表评论