本文整理汇总了C++中nsACString::AssignLiteral方法的典型用法代码示例。如果您正苦于以下问题:C++ nsACString::AssignLiteral方法的具体用法?C++ nsACString::AssignLiteral怎么用?C++ nsACString::AssignLiteral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsACString
的用法示例。
在下文中一共展示了nsACString::AssignLiteral方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
NS_IMETHODIMP
HttpBaseChannel::GetContentType(nsACString& aContentType)
{
if (!mResponseHead) {
aContentType.Truncate();
return NS_ERROR_NOT_AVAILABLE;
}
if (!mResponseHead->ContentType().IsEmpty()) {
aContentType = mResponseHead->ContentType();
return NS_OK;
}
aContentType.AssignLiteral(UNKNOWN_CONTENT_TYPE);
return NS_OK;
}
示例2: ArrayLength
static nsresult
ConvertLocaleToCharsetUsingDeprecatedConfig(const nsACString& locale,
nsACString& oResult)
{
if (!(locale.IsEmpty())) {
nsCAutoString localeKey;
localeKey.AssignLiteral("locale.all.");
localeKey.Append(locale);
if (NS_SUCCEEDED(nsUConvPropertySearch::SearchPropertyValue(kUnixCharsets,
ArrayLength(kUnixCharsets), localeKey, oResult))) {
return NS_OK;
}
}
NS_ERROR("unable to convert locale to charset using deprecated config");
oResult.AssignLiteral("ISO-8859-1");
return NS_SUCCESS_USING_FALLBACK_LOCALE;
}
示例3: GetDefaultFavicon
NS_IMETHODIMP
nsFaviconService::GetFaviconData(nsIURI* aFaviconURI, nsACString& aMimeType,
PRUint32* aDataLen, PRUint8** aData)
{
NS_ENSURE_ARG(aFaviconURI);
NS_ENSURE_ARG_POINTER(aDataLen);
NS_ENSURE_ARG_POINTER(aData);
nsCOMPtr<nsIURI> defaultFaviconURI;
nsresult rv = GetDefaultFavicon(getter_AddRefs(defaultFaviconURI));
NS_ENSURE_SUCCESS(rv, rv);
PRBool isDefaultFavicon = PR_FALSE;
rv = defaultFaviconURI->Equals(aFaviconURI, &isDefaultFavicon);
NS_ENSURE_SUCCESS(rv, rv);
// If we're getting the default favicon, we need to handle it separately since
// it's not in the database.
if (isDefaultFavicon) {
nsCAutoString defaultData;
rv = GetDefaultFaviconData(defaultData);
NS_ENSURE_SUCCESS(rv, rv);
PRUint8* bytes = reinterpret_cast<PRUint8*>(ToNewCString(defaultData));
NS_ENSURE_STATE(bytes);
*aData = bytes;
*aDataLen = defaultData.Length();
aMimeType.AssignLiteral(DEFAULT_MIME_TYPE);
return NS_OK;
}
DECLARE_AND_ASSIGN_SCOPED_LAZY_STMT(stmt, mDBGetData);
rv = URIBinder::Bind(stmt, NS_LITERAL_CSTRING("icon_url"), aFaviconURI);
NS_ENSURE_SUCCESS(rv, rv);
PRBool hasResult = PR_FALSE;
if (NS_SUCCEEDED(stmt->ExecuteStep(&hasResult)) && hasResult) {
rv = stmt->GetUTF8String(1, aMimeType);
NS_ENSURE_SUCCESS(rv, rv);
return stmt->GetBlob(0, aDataLen, aData);
}
return NS_ERROR_NOT_AVAILABLE;
}
示例4: PreprocessHostname
static inline bool PreprocessHostname(bool aLocalDomain,
const nsACString &aInput,
nsIIDNService *aIDN,
nsACString &aACE)
{
if (aLocalDomain) {
aACE.AssignLiteral("localhost");
return true;
}
if (!aIDN || IsASCII(aInput)) {
aACE = aInput;
return true;
}
return IsUTF8(aInput) && NS_SUCCEEDED(aIDN->ConvertUTF8toACE(aInput, aACE));
}
示例5:
nsresult
nsExpandedPrincipal::GetOriginInternal(nsACString& aOrigin)
{
aOrigin.AssignLiteral("[Expanded Principal [");
for (size_t i = 0; i < mPrincipals.Length(); ++i) {
if (i != 0) {
aOrigin.AppendLiteral(", ");
}
nsAutoCString subOrigin;
nsresult rv = mPrincipals.ElementAt(i)->GetOrigin(subOrigin);
NS_ENSURE_SUCCESS(rv, rv);
aOrigin.Append(subOrigin);
}
aOrigin.Append("]]");
return NS_OK;
}
示例6: guard
nsresult
nsPlatformCharset::ConvertLocaleToCharsetUsingDeprecatedConfig(nsAString& locale, nsACString& oResult)
{
// locked for thread safety
{
nsAutoLock guard(gLock);
if (!gInfo_deprecated) {
nsGREResProperties *info =
new nsGREResProperties(NS_LITERAL_CSTRING("unixcharset.properties"));
NS_ASSERTION(info, "cannot create nsGREResProperties");
gInfo_deprecated = info;
}
}
if (gInfo_deprecated && !(locale.IsEmpty())) {
nsAutoString platformLocaleKey;
// note: NS_LITERAL_STRING("locale." OSTYPE ".") does not compile on AIX
platformLocaleKey.AssignLiteral("locale.");
platformLocaleKey.AppendWithConversion(OSTYPE);
platformLocaleKey.AppendLiteral(".");
platformLocaleKey.Append(locale);
nsAutoString charset;
nsresult res = gInfo_deprecated->Get(platformLocaleKey, charset);
if (NS_SUCCEEDED(res)) {
LossyCopyUTF16toASCII(charset, oResult);
return NS_OK;
}
nsAutoString localeKey;
localeKey.AssignLiteral("locale.all.");
localeKey.Append(locale);
res = gInfo_deprecated->Get(localeKey, charset);
if (NS_SUCCEEDED(res)) {
LossyCopyUTF16toASCII(charset, oResult);
return NS_OK;
}
}
NS_ERROR("unable to convert locale to charset using deprecated config");
mCharset.AssignLiteral("ISO-8859-1");
oResult.AssignLiteral("ISO-8859-1");
return NS_SUCCESS_USING_FALLBACK_LOCALE;
}
示例7: switch
/* attribute long type; */
NS_IMETHODIMP
calRecurrenceRule::GetType(nsACString &aType)
{
switch (mIcalRecur.freq) {
#define RECUR_HELPER(x) \
case ICAL_##x##_RECURRENCE: aType.AssignLiteral( #x ); break
RECUR_HELPER(SECONDLY);
RECUR_HELPER(MINUTELY);
RECUR_HELPER(HOURLY);
RECUR_HELPER(DAILY);
RECUR_HELPER(WEEKLY);
RECUR_HELPER(MONTHLY);
RECUR_HELPER(YEARLY);
#undef RECUR_HELPER
default:
aType.AssignLiteral("");
}
return NS_OK;
}
示例8:
NS_IMETHODIMP
nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACString &oResult)
{
nsresult rv;
nsCOMPtr<nsIMacLocale> pMacLocale;
pMacLocale = do_GetService(NS_MACLOCALE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
short script, language, region;
rv = pMacLocale->GetPlatformLocale(localeName, &script, &language, ®ion);
if (NS_SUCCEEDED(rv)) {
if (NS_SUCCEEDED(MapToCharset(script, region, oResult))) {
return NS_OK;
}
}
}
// fallback
oResult.AssignLiteral("x-mac-roman");
return NS_SUCCESS_USING_FALLBACK_LOCALE;
}
示例9:
void
MediaEngineWebRTCAudioCaptureSource::GetUUID(nsACString &aUUID) const
{
nsID uuid;
char uuidBuffer[NSID_LENGTH];
nsCString asciiString;
ErrorResult rv;
rv = nsContentUtils::GenerateUUIDInPlace(uuid);
if (rv.Failed()) {
aUUID.AssignLiteral("");
return;
}
uuid.ToProvidedString(uuidBuffer);
asciiString.AssignASCII(uuidBuffer);
// Remove {} and the null terminator
aUUID.Assign(Substring(asciiString, 1, NSID_LENGTH - 3));
}
示例10: EmptyString
// nsFaviconService::OptimizeFaviconImage
//
// Given a blob of data (a image file already read into a buffer), optimize
// its size by recompressing it as a 16x16 PNG.
nsresult
nsFaviconService::OptimizeFaviconImage(const uint8_t* aData, uint32_t aDataLen,
const nsACString& aMimeType,
nsACString& aNewData,
nsACString& aNewMimeType)
{
nsresult rv;
nsCOMPtr<imgITools> imgtool = do_CreateInstance("@mozilla.org/image/tools;1");
nsCOMPtr<nsIInputStream> stream;
rv = NS_NewByteInputStream(getter_AddRefs(stream),
reinterpret_cast<const char*>(aData), aDataLen,
NS_ASSIGNMENT_DEPEND);
NS_ENSURE_SUCCESS(rv, rv);
// decode image
nsCOMPtr<imgIContainer> container;
rv = imgtool->DecodeImageData(stream, aMimeType, getter_AddRefs(container));
NS_ENSURE_SUCCESS(rv, rv);
aNewMimeType.AssignLiteral(DEFAULT_MIME_TYPE);
// scale and recompress
nsCOMPtr<nsIInputStream> iconStream;
rv = imgtool->EncodeScaledImage(container, aNewMimeType,
mOptimizedIconDimension,
mOptimizedIconDimension,
EmptyString(),
getter_AddRefs(iconStream));
NS_ENSURE_SUCCESS(rv, rv);
// Read the stream into a new buffer.
rv = NS_ConsumeStream(iconStream, UINT32_MAX, aNewData);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
示例11: while
static void
GetSubmitCharset(nsGenericHTMLElement* aForm,
nsACString& oCharset)
{
oCharset.AssignLiteral("UTF-8"); // default to utf-8
nsAutoString acceptCharsetValue;
aForm->GetAttr(kNameSpaceID_None, nsGkAtoms::acceptcharset,
acceptCharsetValue);
PRInt32 charsetLen = acceptCharsetValue.Length();
if (charsetLen > 0) {
PRInt32 offset=0;
PRInt32 spPos=0;
// get charset from charsets one by one
do {
spPos = acceptCharsetValue.FindChar(PRUnichar(' '), offset);
PRInt32 cnt = ((-1==spPos)?(charsetLen-offset):(spPos-offset));
if (cnt > 0) {
nsAutoString uCharset;
acceptCharsetValue.Mid(uCharset, offset, cnt);
if (NS_SUCCEEDED(nsCharsetAlias::GetPreferred(NS_LossyConvertUTF16toASCII(uCharset),
oCharset)))
return;
}
offset = spPos + 1;
} while (spPos != -1);
}
// if there are no accept-charset or all the charset are not supported
// Get the charset from document
nsIDocument* doc = aForm->GetDocument();
if (doc) {
oCharset = doc->GetDocumentCharacterSet();
}
}
示例12: GetStoreType
NS_IMETHODIMP nsMsgBrkMBoxStore::GetStoreType(nsACString& aType)
{
aType.AssignLiteral("mbox");
return NS_OK;
}
示例13: GetPropertiesChromeURI
NS_IMETHODIMP nsAbLDAPDirectory::GetPropertiesChromeURI(nsACString &aResult)
{
aResult.AssignLiteral("chrome://messenger/content/addressbook/pref-directory-add.xul");
return NS_OK;
}
示例14: GetContentType
NS_IMETHODIMP nsIconChannel::GetContentType(nsACString &aContentType)
{
aContentType.AssignLiteral(IMAGE_ICO);
return NS_OK;
}
示例15:
NS_IMETHODIMP
SimpleTimer::GetName(nsACString& aName)
{
aName.AssignLiteral("SimpleTimer");
return NS_OK;
}