本文整理汇总了C++中nsString::AppendWithConversion方法的典型用法代码示例。如果您正苦于以下问题:C++ nsString::AppendWithConversion方法的具体用法?C++ nsString::AppendWithConversion怎么用?C++ nsString::AppendWithConversion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsString
的用法示例。
在下文中一共展示了nsString::AppendWithConversion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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));
}
示例2: CreateViewSourceURL
nsresult CViewSourceHTML::CreateViewSourceURL(const nsAString& linkUrl,
nsString& viewSourceUrl) {
nsCOMPtr<nsIURI> baseURI;
nsCOMPtr<nsIURI> hrefURI;
nsresult rv;
// Default the view source URL to the empty string in case we fail.
viewSourceUrl.Truncate();
// Get the BaseURI.
rv = GetBaseURI(getter_AddRefs(baseURI));
NS_ENSURE_SUCCESS(rv, rv);
// Use the link URL and the base URI to build a URI for the link. Note that
// the link URL may have untranslated entities in it.
nsAutoString expandedLinkUrl;
ExpandEntities(linkUrl, expandedLinkUrl);
rv = NS_NewURI(getter_AddRefs(hrefURI), expandedLinkUrl, mCharset.get(), baseURI);
NS_ENSURE_SUCCESS(rv, rv);
// Get the absolute URL from the link URI.
nsCString absoluteLinkUrl;
hrefURI->GetSpec(absoluteLinkUrl);
// URLs that execute script (e.g. "javascript:" URLs) should just be
// ignored. There's nothing reasonable we can do with them, and allowing
// them to execute in the context of the view-source window presents a
// security risk. Just return the empty string in this case.
PRBool openingExecutesScript = PR_FALSE;
rv = NS_URIChainHasFlags(hrefURI, nsIProtocolHandler::URI_OPENING_EXECUTES_SCRIPT,
&openingExecutesScript);
NS_ENSURE_SUCCESS(rv, NS_OK); // if there's an error, return the empty string
if (openingExecutesScript) {
return NS_OK;
}
// URLs that return data (e.g. "http:" URLs) should be prefixed with
// "view-source:". URLs that don't return data should just be returned
// undecorated.
PRBool doesNotReturnData = PR_FALSE;
rv = NS_URIChainHasFlags(hrefURI, nsIProtocolHandler::URI_DOES_NOT_RETURN_DATA,
&doesNotReturnData);
NS_ENSURE_SUCCESS(rv, NS_OK); // if there's an error, return the empty string
if (!doesNotReturnData) {
viewSourceUrl.AssignLiteral("view-source:");
}
viewSourceUrl.AppendWithConversion(absoluteLinkUrl);
return NS_OK;
}