本文整理汇总了C++中nsString::Append方法的典型用法代码示例。如果您正苦于以下问题:C++ nsString::Append方法的具体用法?C++ nsString::Append怎么用?C++ nsString::Append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsString
的用法示例。
在下文中一共展示了nsString::Append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
nsCSSScanner::StopRecording(nsString& aBuffer)
{
NS_ASSERTION(mRecording, "haven't started recording");
mRecording = false;
aBuffer.Append(mReadPointer + mRecordStartOffset,
mOffset - mPushbackCount - mRecordStartOffset);
}
示例2:
void
ReverseString(const nsString& aInput, nsString& aReversed)
{
aReversed.Truncate(0);
for (PRInt32 i = aInput.Length() - 1; i >= 0; i--) {
aReversed.Append(aInput[i]);
}
}
示例3:
void
nsCSSScanner::StopRecording(nsString& aBuffer)
{
MOZ_ASSERT(mRecording, "haven't started recording");
mRecording = false;
aBuffer.Append(mBuffer + mRecordStartOffset,
mOffset - mRecordStartOffset);
}
示例4: if
/**
* Gather up the characters in an identifier. The identfier was
* started by "aChar" which will be appended to aIdent. The result
* will be aIdent with all of the identifier characters appended
* until the first non-identifier character is seen. The termination
* character is unread for the future re-reading.
*
* Returns failure when the character sequence does not form an ident at
* all, in which case the caller is responsible for pushing back or
* otherwise handling aChar. (This occurs only when aChar is '\'.)
*/
bool
nsCSSScanner::GatherIdent(PRInt32 aChar, nsString& aIdent)
{
if (aChar == '\\') {
if (!ParseAndAppendEscape(aIdent, false)) {
return false;
}
}
else if (0 < aChar) {
aIdent.Append(aChar);
}
for (;;) {
// If nothing in pushback, first try to get as much as possible in one go
if (!mPushbackCount && mOffset < mCount) {
// See how much we can consume and append in one go
PRUint32 n = mOffset;
// Count number of Ident characters that can be processed
while (n < mCount && IsIdent(mReadPointer[n])) {
++n;
}
// Add to the token what we have so far
if (n > mOffset) {
#ifdef CSS_REPORT_PARSE_ERRORS
mColNumber += n - mOffset;
#endif
aIdent.Append(&mReadPointer[mOffset], n - mOffset);
mOffset = n;
}
}
aChar = Read();
if (aChar < 0) break;
if (aChar == '\\') {
if (!ParseAndAppendEscape(aIdent, false)) {
Pushback(aChar);
break;
}
} else if (IsIdent(aChar)) {
aIdent.Append(PRUnichar(aChar));
} else {
Pushback(aChar);
break;
}
}
return true;
}
示例5:
void
txResultTreeFragment::stringValue(nsString& aResult)
{
if (!mBuffer) {
return;
}
aResult.Append(mBuffer->mStringValue);
}
示例6: while
/**
* Gather up the characters in an identifier. The identfier was
* started by "aChar" which will be appended to aIdent. The result
* will be aIdent with all of the identifier characters appended
* until the first non-identifier character is seen. The termination
* character is unread for the future re-reading.
*
* Returns failure when the character sequence does not form an ident at
* all, in which case the caller is responsible for pushing back or
* otherwise handling aChar. (This occurs only when aChar is '\'.)
*/
bool
nsCSSScanner::GatherIdent(int32_t aChar, nsString& aIdent)
{
if (aChar == '\\') {
if (!ParseAndAppendEscape(aIdent, false)) {
return false;
}
} else {
MOZ_ASSERT(aChar > 0);
aIdent.Append(aChar);
}
for (;;) {
// If nothing in pushback, first try to get as much as possible in one go
if (!mPushbackCount && mOffset < mCount) {
// See how much we can consume and append in one go
uint32_t n = mOffset;
// Count number of Ident characters that can be processed
while (n < mCount && IsIdent(mReadPointer[n])) {
++n;
}
// Add to the token what we have so far
if (n > mOffset) {
aIdent.Append(&mReadPointer[mOffset], n - mOffset);
mOffset = n;
}
}
aChar = Read();
if (aChar < 0) break;
if (aChar == '\\') {
if (!ParseAndAppendEscape(aIdent, false)) {
Pushback(aChar);
break;
}
} else if (IsIdent(aChar)) {
aIdent.Append(PRUnichar(aChar));
} else {
Pushback(aChar);
break;
}
}
MOZ_ASSERT(aIdent.Length() > 0);
return true;
}
示例7: strlen
bool
mozTXTToHTMLConv::SmilyHit(const PRUnichar * aInString, PRInt32 aLength, bool col0,
const char* tagTXT, const char* imageName,
nsString& outputHTML, PRInt32& glyphTextLen)
{
if ( !aInString || !tagTXT || !imageName )
return false;
PRInt32 tagLen = strlen(tagTXT);
PRUint32 delim = (col0 ? 0 : 1) + tagLen;
if
(
(col0 || IsSpace(aInString[0]))
&&
(
aLength <= PRInt32(delim) ||
IsSpace(aInString[delim]) ||
(aLength > PRInt32(delim + 1)
&&
(
aInString[delim] == '.' ||
aInString[delim] == ',' ||
aInString[delim] == ';' ||
aInString[delim] == '8' ||
aInString[delim] == '>' ||
aInString[delim] == '!' ||
aInString[delim] == '?'
)
&& IsSpace(aInString[delim + 1]))
)
&& ItMatchesDelimited(aInString, aLength, NS_ConvertASCIItoUTF16(tagTXT).get(), tagLen,
col0 ? LT_IGNORE : LT_DELIMITER, LT_IGNORE)
// Note: tests at different pos for LT_IGNORE and LT_DELIMITER
)
{
if (!col0)
{
outputHTML.Truncate();
outputHTML.Append(PRUnichar(' '));
}
outputHTML.AppendLiteral("<span class=\""); // <span class="
AppendASCIItoUTF16(imageName, outputHTML); // e.g. smiley-frown
outputHTML.AppendLiteral("\" title=\""); // " title="
AppendASCIItoUTF16(tagTXT, outputHTML); // smiley tooltip
outputHTML.AppendLiteral("\"><span>"); // "><span>
AppendASCIItoUTF16(tagTXT, outputHTML); // original text
outputHTML.AppendLiteral("</span></span>"); // </span></span>
glyphTextLen = (col0 ? 0 : 1) + tagLen;
return true;
}
return false;
}
示例8: if
void
mozTXTToHTMLConv::UnescapeStr(const PRUnichar * aInString, PRInt32 aStartPos, PRInt32 aLength, nsString& aOutString)
{
const PRUnichar * subString = nsnull;
for (PRUint32 i = aStartPos; PRInt32(i) - aStartPos < aLength;)
{
PRInt32 remainingChars = i - aStartPos;
if (aInString[i] == '&')
{
subString = &aInString[i];
if (!nsCRT::strncmp(subString, NS_LITERAL_STRING("<").get(), MinInt(4, aLength - remainingChars)))
{
aOutString.Append(PRUnichar('<'));
i += 4;
}
else if (!nsCRT::strncmp(subString, NS_LITERAL_STRING(">").get(), MinInt(4, aLength - remainingChars)))
{
aOutString.Append(PRUnichar('>'));
i += 4;
}
else if (!nsCRT::strncmp(subString, NS_LITERAL_STRING("&").get(), MinInt(5, aLength - remainingChars)))
{
aOutString.Append(PRUnichar('&'));
i += 5;
}
else if (!nsCRT::strncmp(subString, NS_LITERAL_STRING(""").get(), MinInt(6, aLength - remainingChars)))
{
aOutString.Append(PRUnichar('"'));
i += 6;
}
else
{
aOutString += aInString[i];
i++;
}
}
else
{
aOutString += aInString[i];
i++;
}
}
}
示例9: if
void
mozTXTToHTMLConv::UnescapeStr(const char16_t * aInString, int32_t aStartPos, int32_t aLength, nsString& aOutString)
{
const char16_t * subString = nullptr;
for (uint32_t i = aStartPos; int32_t(i) - aStartPos < aLength;)
{
int32_t remainingChars = i - aStartPos;
if (aInString[i] == '&')
{
subString = &aInString[i];
if (!nsCRT::strncmp(subString, MOZ_UTF16("<"), std::min(4, aLength - remainingChars)))
{
aOutString.Append(char16_t('<'));
i += 4;
}
else if (!nsCRT::strncmp(subString, MOZ_UTF16(">"), std::min(4, aLength - remainingChars)))
{
aOutString.Append(char16_t('>'));
i += 4;
}
else if (!nsCRT::strncmp(subString, MOZ_UTF16("&"), std::min(5, aLength - remainingChars)))
{
aOutString.Append(char16_t('&'));
i += 5;
}
else if (!nsCRT::strncmp(subString, MOZ_UTF16("""), std::min(6, aLength - remainingChars)))
{
aOutString.Append(char16_t('"'));
i += 6;
}
else
{
aOutString += aInString[i];
i++;
}
}
else
{
aOutString += aInString[i];
i++;
}
}
}
示例10: switch
void
mozTXTToHTMLConv::CalculateURLBoundaries(const PRUnichar * aInString, PRInt32 aInStringLength,
const PRUint32 pos, const PRUint32 whathasbeendone,
const modetype check, const PRUint32 start, const PRUint32 end,
nsString& txtURL, nsString& desc,
PRInt32& replaceBefore, PRInt32& replaceAfter)
{
PRUint32 descstart = start;
switch(check)
{
case RFC1738:
{
descstart = start - 5;
desc.Append(&aInString[descstart], end - descstart + 2); // include "<URL:" and ">"
replaceAfter = end - pos + 1;
} break;
case RFC2396E:
{
descstart = start - 1;
desc.Append(&aInString[descstart], end - descstart + 2); // include brackets
replaceAfter = end - pos + 1;
} break;
case freetext:
case abbreviated:
{
descstart = start;
desc.Append(&aInString[descstart], end - start + 1); // don't include brackets
replaceAfter = end - pos;
} break;
default: break;
} //switch
EscapeStr(desc, false);
txtURL.Append(&aInString[start], end - start + 1);
txtURL.StripWhitespace();
// FIX ME
nsAutoString temp2;
ScanTXT(&aInString[descstart], pos - descstart, ~kURLs /*prevents loop*/ & whathasbeendone, temp2);
replaceBefore = temp2.Length();
return;
}
示例11:
void
txDriver::createErrorString()
{
XML_Error errCode = XML_GetErrorCode(mExpatParser);
mErrorString.AppendWithConversion(XML_ErrorString(errCode));
mErrorString.AppendLiteral(" at line ");
mErrorString.AppendInt(XML_GetCurrentLineNumber(mExpatParser));
mErrorString.AppendLiteral(" in ");
mErrorString.Append((const PRUnichar*)XML_GetBase(mExpatParser));
}
示例12:
void
URL::GetProtocol(nsString& aProtocol, ErrorResult& aRv) const
{
nsCString protocol;
if (NS_SUCCEEDED(mURI->GetScheme(protocol))) {
aProtocol.Truncate();
}
CopyASCIItoUTF16(protocol, aProtocol);
aProtocol.Append(char16_t(':'));
}
示例13:
bool TextAttrsMgr::FontFamilyTextAttr::GetFontFamily(nsIFrame* aFrame,
nsString& aFamily) {
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetFontMetricsForFrame(aFrame, 1.0f);
gfxFontGroup* fontGroup = fm->GetThebesFontGroup();
gfxFont* font = fontGroup->GetFirstValidFont();
gfxFontEntry* fontEntry = font->GetFontEntry();
aFamily.Append(NS_ConvertUTF8toUTF16(fontEntry->FamilyName()));
return true;
}
示例14:
void
URL::GetProtocol(nsString& aProtocol) const
{
nsCString protocol;
if (NS_SUCCEEDED(mURI->GetScheme(protocol))) {
aProtocol.Truncate();
}
CopyASCIItoUTF16(protocol, aProtocol);
aProtocol.Append(PRUnichar(':'));
}
示例15: while
ENameValueFlag
XULTreeGridRowAccessible::Name(nsString& aName)
{
aName.Truncate();
// XXX: the row name sholdn't be a concatenation of cell names (bug 664384).
nsCOMPtr<nsITreeColumn> column = nsCoreUtils::GetFirstSensibleColumn(mTree);
while (column) {
if (!aName.IsEmpty())
aName.Append(' ');
nsAutoString cellName;
GetCellName(column, cellName);
aName.Append(cellName);
column = nsCoreUtils::GetNextSensibleColumn(column);
}
return eNameOK;
}