本文整理汇总了C++中nsCString::EndWriting方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCString::EndWriting方法的具体用法?C++ nsCString::EndWriting怎么用?C++ nsCString::EndWriting使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsCString
的用法示例。
在下文中一共展示了nsCString::EndWriting方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
static void
rdf_EscapeAmpersandsAndAngleBrackets(nsCString& s)
{
uint32_t newLength, origLength;
newLength = origLength = s.Length();
// Compute the length of the result string.
const char* start = s.BeginReading();
const char* end = s.EndReading();
const char* c = start;
while (c != end) {
switch (*c) {
case '&' :
newLength += sizeof(amp) - 2;
break;
case '<':
case '>':
newLength += sizeof(gt) - 2;
break;
default:
break;
}
++c;
}
if (newLength == origLength) {
// nothing to escape
return;
}
// escape the chars from the end back to the front.
s.SetLength(newLength);
// Buffer might have changed, get the pointers again
start = s.BeginReading(); // begin of string
c = start + origLength - 1; // last char in original string
char* w = s.EndWriting() - 1; // last char in grown buffer
while (c >= start) {
switch (*c) {
case '&' :
w -= 4;
nsCharTraits<char>::copy(w, amp, sizeof(amp) - 1);
break;
case '<':
w -= 3;
nsCharTraits<char>::copy(w, lt, sizeof(lt) - 1);
break;
case '>':
w -= 3;
nsCharTraits<char>::copy(w, gt, sizeof(gt) - 1);
break;
default:
*w = *c;
}
--w;
--c;
}
}
示例2: while
// Does an in place rotation of the line
static void
Rot13Line(nsCString &line)
{
nsCString::iterator start, end;
line.BeginWriting(start);
line.EndWriting(end);
while (start != end) {
*start = kRot13Table[NS_STATIC_CAST(PRInt32, *start)];
++start;
}
}