本文整理汇总了C++中nsString::ReplaceSubstring方法的典型用法代码示例。如果您正苦于以下问题:C++ nsString::ReplaceSubstring方法的具体用法?C++ nsString::ReplaceSubstring怎么用?C++ nsString::ReplaceSubstring使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsString
的用法示例。
在下文中一共展示了nsString::ReplaceSubstring方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SanitizeValue
void nsOutlookMail::SanitizeValue( nsString& val)
{
val.ReplaceSubstring(NS_LITERAL_STRING("\x0D\x0A").get(),
NS_LITERAL_STRING(", ").get());
val.ReplaceChar( 13, ',');
val.ReplaceChar( 10, ',');
}
示例2: bundleService
nsresult
nsMsgBuildErrorMessageByID(PRInt32 msgID, nsString& retval, nsString* param0, nsString* param1)
{
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1", &rv));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundle> bundle;
rv = bundleService->CreateBundle("chrome://messenger/locale/messengercompose/composeMsgs.properties", getter_AddRefs(bundle));
NS_ENSURE_SUCCESS(rv, rv);
nsString msg;
rv = bundle->GetStringFromID(NS_IS_MSG_ERROR(msgID) ? NS_ERROR_GET_CODE(msgID) : msgID,
getter_Copies(retval));
NS_ENSURE_SUCCESS(rv, rv);
if (param0)
retval.ReplaceSubstring(NS_LITERAL_STRING("%P0%"), *param0);
if (param1)
retval.ReplaceSubstring(NS_LITERAL_STRING("%P1%"), *param1);
return rv;
}
示例3: EmptyString
void
nsPageFrame::ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr)
{
aNewStr = aStr;
// Search to see if the &D code is in the string
// then subst in the current date/time
NS_NAMED_LITERAL_STRING(kDate, "&D");
if (aStr.Find(kDate) != kNotFound) {
if (mPD->mDateTimeStr != nsnull) {
aNewStr.ReplaceSubstring(kDate.get(), mPD->mDateTimeStr);
} else {
aNewStr.ReplaceSubstring(kDate.get(), EmptyString().get());
}
}
// NOTE: Must search for &PT before searching for &P
//
// Search to see if the "page number and page" total code are in the string
// and replace the page number and page total code with the actual
// values
NS_NAMED_LITERAL_STRING(kPageAndTotal, "&PT");
if (aStr.Find(kPageAndTotal) != kNotFound) {
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumAndTotalsFormat, mPageNum, mTotNumPages);
aNewStr.ReplaceSubstring(kPageAndTotal.get(), uStr);
nsMemory::Free(uStr);
}
// Search to see if the page number code is in the string
// and replace the page number code with the actual value
NS_NAMED_LITERAL_STRING(kPage, "&P");
if (aStr.Find(kPage) != kNotFound) {
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumFormat, mPageNum);
aNewStr.ReplaceSubstring(kPage.get(), uStr);
nsMemory::Free(uStr);
}
NS_NAMED_LITERAL_STRING(kTitle, "&T");
if (aStr.Find(kTitle) != kNotFound) {
if (mPD->mDocTitle != nsnull) {
aNewStr.ReplaceSubstring(kTitle.get(), mPD->mDocTitle);
} else {
aNewStr.ReplaceSubstring(kTitle.get(), EmptyString().get());
}
}
NS_NAMED_LITERAL_STRING(kDocURL, "&U");
if (aStr.Find(kDocURL) != kNotFound) {
if (mPD->mDocURL != nsnull) {
aNewStr.ReplaceSubstring(kDocURL.get(), mPD->mDocURL);
} else {
aNewStr.ReplaceSubstring(kDocURL.get(), EmptyString().get());
}
}
NS_NAMED_LITERAL_STRING(kPageTotal, "&L");
if (aStr.Find(kPageTotal) != kNotFound) {
PRUnichar * uStr = nsTextFormatter::smprintf(mPD->mPageNumFormat, mTotNumPages);
aNewStr.ReplaceSubstring(kPageTotal.get(), uStr);
nsMemory::Free(uStr);
}
}