本文整理汇总了C++中nsString::AppendASCII方法的典型用法代码示例。如果您正苦于以下问题:C++ nsString::AppendASCII方法的具体用法?C++ nsString::AppendASCII怎么用?C++ nsString::AppendASCII使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsString
的用法示例。
在下文中一共展示了nsString::AppendASCII方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
nsFrameUtil::Tag::ToString(nsString& aResult)
{
aResult.Truncate();
aResult.Append(PRUnichar('<'));
if (type == close) {
aResult.Append(PRUnichar('/'));
}
aResult.AppendASCII(name);
if (0 != num) {
PRInt32 i, n = num;
for (i = 0; i < n; i++) {
aResult.Append(PRUnichar(' '));
aResult.AppendASCII(attributes[i]);
if (values[i]) {
aResult.AppendLiteral("=\"");
aResult.AppendASCII(values[i]);
aResult.Append(PRUnichar('\"'));
}
}
}
if (type == openClose) {
aResult.Append(PRUnichar('/'));
}
aResult.Append(PRUnichar('>'));
}
示例2: if
// NOTE: the converted html for the phrase is appended to aOutString
// tagHTML and attributeHTML are plain ASCII (literal strings, in fact)
bool
mozTXTToHTMLConv::StructPhraseHit(const PRUnichar * aInString, PRInt32 aInStringLength, bool col0,
const PRUnichar* tagTXT, PRInt32 aTagTXTLen,
const char* tagHTML, const char* attributeHTML,
nsString& aOutString, PRUint32& openTags)
{
/* We're searching for the following pattern:
LT_DELIMITER - "*" - ALPHA -
[ some text (maybe more "*"-pairs) - ALPHA ] "*" - LT_DELIMITER.
<strong> is only inserted, if existence of a pair could be verified
We use the first opening/closing tag, if we can choose */
const PRUnichar * newOffset = aInString;
PRInt32 newLength = aInStringLength;
if (!col0) // skip the first element?
{
newOffset = &aInString[1];
newLength = aInStringLength - 1;
}
// opening tag
if
(
ItMatchesDelimited(aInString, aInStringLength, tagTXT, aTagTXTLen,
(col0 ? LT_IGNORE : LT_DELIMITER), LT_ALPHA) // is opening tag
&& NumberOfMatches(newOffset, newLength, tagTXT, aTagTXTLen,
LT_ALPHA, LT_DELIMITER) // remaining closing tags
> openTags
)
{
openTags++;
aOutString.AppendLiteral("<");
aOutString.AppendASCII(tagHTML);
aOutString.Append(PRUnichar(' '));
aOutString.AppendASCII(attributeHTML);
aOutString.AppendLiteral("><span class=\"moz-txt-tag\">");
aOutString.Append(tagTXT);
aOutString.AppendLiteral("</span>");
return true;
}
// closing tag
else if (openTags > 0
&& ItMatchesDelimited(aInString, aInStringLength, tagTXT, aTagTXTLen, LT_ALPHA, LT_DELIMITER))
{
openTags--;
aOutString.AppendLiteral("<span class=\"moz-txt-tag\">");
aOutString.Append(tagTXT);
aOutString.AppendLiteral("</span></");
aOutString.AppendASCII(tagHTML);
aOutString.Append(PRUnichar('>'));
return true;
}
return false;
}
示例3:
static nsresult
AppendErrorPointer(const int32_t aColNumber,
const char16_t *aSourceLine,
nsString& aSourceString)
{
aSourceString.Append(char16_t('\n'));
// Last character will be '^'.
int32_t last = aColNumber - 1;
int32_t i;
uint32_t minuses = 0;
for (i = 0; i < last; ++i) {
if (aSourceLine[i] == '\t') {
// Since this uses |white-space: pre;| a tab stop equals 8 spaces.
uint32_t add = 8 - (minuses % 8);
aSourceString.AppendASCII("--------", add);
minuses += add;
}
else {
aSourceString.Append(char16_t('-'));
++minuses;
}
}
aSourceString.Append(char16_t('^'));
return NS_OK;
}
示例4: error_id
nsresult
nsNSSErrors::getErrorMessageFromCode(PRErrorCode err,
nsINSSComponent *component,
nsString &returnedMessage)
{
NS_ENSURE_ARG_POINTER(component);
returnedMessage.Truncate();
const char *nss_error_id_str = getDefaultErrorStringName(err);
const char *id_str = getOverrideErrorStringName(err);
if (id_str || nss_error_id_str)
{
nsString defMsg;
nsresult rv;
if (id_str)
{
rv = component->GetPIPNSSBundleString(id_str, defMsg);
}
else
{
rv = component->GetNSSBundleString(nss_error_id_str, defMsg);
}
if (NS_SUCCEEDED(rv))
{
returnedMessage.Append(defMsg);
returnedMessage.Append(NS_LITERAL_STRING("\n"));
}
}
if (returnedMessage.IsEmpty())
{
// no localized string available, use NSS' internal
returnedMessage.AppendASCII(PR_ErrorToString(err, PR_LANGUAGE_EN));
returnedMessage.Append(NS_LITERAL_STRING("\n"));
}
if (nss_error_id_str)
{
nsresult rv;
nsCString error_id(nss_error_id_str);
ToLowerCase(error_id);
NS_ConvertASCIItoUTF16 idU(error_id);
const PRUnichar *params[1];
params[0] = idU.get();
nsString formattedString;
rv = component->PIPBundleFormatStringFromName("certErrorCodePrefix",
params, 1,
formattedString);
if (NS_SUCCEEDED(rv)) {
returnedMessage.Append(NS_LITERAL_STRING("\n"));
returnedMessage.Append(formattedString);
returnedMessage.Append(NS_LITERAL_STRING("\n"));
}
else {
returnedMessage.Append(NS_LITERAL_STRING("("));
returnedMessage.Append(idU);
returnedMessage.Append(NS_LITERAL_STRING(")"));
}
}
return NS_OK;
}