本文整理汇总了C++中XMP_VarString::append方法的典型用法代码示例。如果您正苦于以下问题:C++ XMP_VarString::append方法的具体用法?C++ XMP_VarString::append怎么用?C++ XMP_VarString::append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMP_VarString
的用法示例。
在下文中一共展示了XMP_VarString::append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
static void
AppendNodeValue ( XMP_VarString & outputStr, const XMP_VarString & value, bool forAttribute )
{
unsigned char * runStart = (unsigned char *) value.c_str();
unsigned char * runLimit = runStart + value.size();
unsigned char * runEnd;
unsigned char ch;
while ( runStart < runLimit ) {
for ( runEnd = runStart; runEnd < runLimit; ++runEnd ) {
ch = *runEnd;
if ( forAttribute && (ch == '"') ) break;
if ( (ch < 0x20) || (ch == '&') || (ch == '<') || (ch == '>') ) break;
}
outputStr.append ( (char *) runStart, (runEnd - runStart) );
if ( runEnd < runLimit ) {
if ( ch < 0x20 ) {
XMP_Assert ( (ch == kTab) || (ch == kLF) || (ch == kCR) );
char hexBuf[16];
memcpy ( hexBuf, "&#xn;", 6 ); // AUDIT: Length of "&#xn;" is 5, hexBuf size is 16.
hexBuf[3] = kHexDigits[ch&0xF];
outputStr.append ( hexBuf, 5 );
} else {
if ( ch == '"' ) {
outputStr += """;
} else if ( ch == '<' ) {
outputStr += "<";
} else if ( ch == '>' ) {
outputStr += ">";
} else {
XMP_Assert ( ch == '&' );
outputStr += "&";
}
}
++runEnd;
}
runStart = runEnd;
}
} // AppendNodeValue
示例2: oldChildren
//.........这里部分代码省略.........
if ( (charKind == UCK_normal) || (charKind == UCK_quote) ) break;
}
if ( itemStart >= endPos ) break;
if ( charKind != UCK_quote ) {
// This is not a quoted value. Scan for the end, create an array item from the substring.
for ( itemEnd = itemStart; itemEnd < endPos; itemEnd += charSize ) {
ClassifyCharacter ( catedStr, itemEnd, &charKind, &charSize, &uniChar );
if ( (charKind == UCK_normal) || (charKind == UCK_quote) ) continue;
if ( (charKind == UCK_comma) && preserveCommas ) continue;
if ( charKind != UCK_space ) break;
if ( (itemEnd + charSize) >= endPos ) break; // Anything left?
ClassifyCharacter ( catedStr, (itemEnd+charSize), &nextKind, &nextSize, &nextChar );
if ( (nextKind == UCK_normal) || (nextKind == UCK_quote) ) continue;
if ( (nextKind == UCK_comma) && preserveCommas ) continue;
break; // Have multiple spaces, or a space followed by a separator.
}
itemValue.assign ( catedStr, itemStart, (itemEnd - itemStart) );
} else {
// Accumulate quoted values into a local string, undoubling internal quotes that
// match the surrounding quotes. Do not undouble "unmatching" quotes.
UniCodePoint openQuote = uniChar;
UniCodePoint closeQuote = GetClosingQuote ( openQuote );
itemStart += charSize; // Skip the opening quote;
itemValue.erase();
for ( itemEnd = itemStart; itemEnd < endPos; itemEnd += charSize ) {
ClassifyCharacter ( catedStr, itemEnd, &charKind, &charSize, &uniChar );
if ( (charKind != UCK_quote) || (! IsSurroundingQuote ( uniChar, openQuote, closeQuote)) ) {
// This is not a matching quote, just append it to the item value.
itemValue.append ( catedStr, itemEnd, charSize );
} else {
// This is a "matching" quote. Is it doubled, or the final closing quote? Tolerate
// various edge cases like undoubled opening (non-closing) quotes, or end of input.
if ( (itemEnd + charSize) < endPos ) {
ClassifyCharacter ( catedStr, itemEnd+charSize, &nextKind, &nextSize, &nextChar );
} else {
nextKind = UCK_semicolon; nextSize = 0; nextChar = 0x3B;
}
if ( uniChar == nextChar ) {
// This is doubled, copy it and skip the double.
itemValue.append ( catedStr, itemEnd, charSize );
itemEnd += nextSize; // Loop will add in charSize.
} else if ( ! IsClosingingQuote ( uniChar, openQuote, closeQuote ) ) {
// This is an undoubled, non-closing quote, copy it.
itemValue.append ( catedStr, itemEnd, charSize );
} else {
// This is an undoubled closing quote, skip it and exit the loop.
itemEnd += charSize;
break;
}
}
} // Loop to accumulate the quoted value.
}
// Add the separated item to the array. Keep a matching old value in case it had separators.
size_t oldChild;
for ( oldChild = 0; oldChild < oldChildCount; ++oldChild ) {
if ( (oldChildren[oldChild] != 0) && (itemValue == oldChildren[oldChild]->value) ) break;
}
XMP_Node * newItem = 0;
if ( oldChild == oldChildCount ) {
newItem = new XMP_Node ( arrayNode, kXMP_ArrayItemName, itemValue.c_str(), 0 );
} else {
newItem = oldChildren[oldChild];
oldChildren[oldChild] = 0; // ! Don't match again, let duplicates be seen.
}
arrayNode->children.push_back ( newItem );
} // Loop through all of the returned items.
// Delete any of the old children that were not kept.
for ( size_t i = 0; i < oldChildCount; ++i ) {
if ( oldChildren[i] != 0 ) delete oldChildren[i];
}
} // SeparateArrayItems
示例3:
static void
ApplyQuotes ( XMP_VarString * item, UniCodePoint openQuote, UniCodePoint closeQuote, bool allowCommas )
{
bool prevSpace = false;
size_t charOffset, charLen;
UniCharKind charKind;
UniCodePoint uniChar;
// -----------------------------------------------------------------------------------------
// See if there are any separators in the value. Stop at the first occurrance. This is a bit
// tricky in order to make typical typing work conveniently. The purpose of applying quotes
// is to preserve the values when splitting them back apart. That is CatenateContainerItems
// and SeparateContainerItems must round trip properly. For the most part we only look for
// separators here. Internal quotes, as in -- Irving "Bud" Jones -- won't cause problems in
// the separation. An initial quote will though, it will make the value look quoted.
charOffset = 0;
ClassifyCharacter ( item->c_str(), charOffset, &charKind, &charLen, &uniChar );
if ( charKind != UCK_quote ) {
for ( charOffset = 0; size_t(charOffset) < item->size(); charOffset += charLen ) {
ClassifyCharacter ( item->c_str(), charOffset, &charKind, &charLen, &uniChar );
if ( charKind == UCK_space ) {
if ( prevSpace ) break; // Multiple spaces are a separator.
prevSpace = true;
} else {
prevSpace = false;
if ( (charKind == UCK_semicolon) || (charKind == UCK_control) ) break;
if ( (charKind == UCK_comma) && (! allowCommas) ) break;
}
}
}
if ( size_t(charOffset) < item->size() ) {
// --------------------------------------------------------------------------------------
// Create a quoted copy, doubling any internal quotes that match the outer ones. Internal
// quotes did not stop the "needs quoting" search, but they do need doubling. So we have
// to rescan the front of the string for quotes. Handle the special case of U+301D being
// closed by either U+301E or U+301F.
XMP_VarString newItem;
size_t splitPoint;
for ( splitPoint = 0; splitPoint <= charOffset; ++splitPoint ) {
ClassifyCharacter ( item->c_str(), splitPoint, &charKind, &charLen, &uniChar );
if ( charKind == UCK_quote ) break;
}
CodePointToUTF8 ( openQuote, newItem );
newItem.append ( *item, 0, splitPoint ); // Copy the leading "normal" portion.
for ( charOffset = splitPoint; size_t(charOffset) < item->size(); charOffset += charLen ) {
ClassifyCharacter ( item->c_str(), charOffset, &charKind, &charLen, &uniChar );
newItem.append ( *item, charOffset, charLen );
if ( (charKind == UCK_quote) && IsSurroundingQuote ( uniChar, openQuote, closeQuote ) ) {
newItem.append ( *item, charOffset, charLen );
}
}
XMP_VarString closeStr;
CodePointToUTF8 ( closeQuote, closeStr );
newItem.append ( closeStr );
*item = newItem;
}
} // ApplyQuotes