本文整理汇总了C++中nsAString::AppendASCII方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAString::AppendASCII方法的具体用法?C++ nsAString::AppendASCII怎么用?C++ nsAString::AppendASCII使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAString
的用法示例。
在下文中一共展示了nsAString::AppendASCII方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
nsCSPHostSrc::toString(nsAString& outStr) const
{
// If mHost is a single "*", we append the wildcard and return.
if (mHost.EqualsASCII("*") &&
mScheme.IsEmpty() &&
mPort.IsEmpty()) {
outStr.Append(mHost);
return;
}
// append scheme
outStr.Append(mScheme);
// append host
outStr.AppendASCII("://");
outStr.Append(mHost);
// append port
if (!mPort.IsEmpty()) {
outStr.AppendASCII(":");
outStr.Append(mPort);
}
// in CSP 1.1, paths are ignoed
// outStr.Append(mPath);
// outStr.Append(mFileAndArguments);
}
示例2: if
void
nsRequireSRIForDirective::toString(nsAString &outStr) const
{
outStr.AppendASCII(CSP_CSPDirectiveToString(
nsIContentSecurityPolicy::REQUIRE_SRI_FOR));
for (uint32_t i = 0; i < mTypes.Length(); i++) {
if (mTypes[i] == nsIContentPolicy::TYPE_SCRIPT) {
outStr.AppendASCII(" script");
}
else if (mTypes[i] == nsIContentPolicy::TYPE_STYLESHEET) {
outStr.AppendASCII(" style");
}
}
}
示例3:
void
nsCSPPolicy::toString(nsAString& outStr) const
{
uint32_t length = mDirectives.Length();
for (uint32_t i = 0; i < length; ++i) {
if (mDirectives[i]->equals(nsIContentSecurityPolicy::REFERRER_DIRECTIVE)) {
outStr.AppendASCII(CSP_CSPDirectiveToString(nsIContentSecurityPolicy::REFERRER_DIRECTIVE));
outStr.AppendASCII(" ");
outStr.Append(mReferrerPolicy);
} else {
mDirectives[i]->toString(outStr);
}
if (i != (length - 1)) {
outStr.AppendASCII("; ");
}
}
}
示例4: toString
void
nsCSPKeywordSrc::toString(nsAString& outStr) const
{
if (mInvalidated) {
MOZ_ASSERT(mKeyword == CSP_UNSAFE_INLINE,
"can only ignore 'unsafe-inline' within toString()");
return;
}
outStr.AppendASCII(CSP_EnumToKeyword(mKeyword));
}
示例5:
void
GeneratePermissionName(nsAString& aPermission,
const nsAString& aName,
const nsAString& aManifestURL)
{
aPermission.AssignASCII("indexedDB-chrome-");
aPermission.Append(aName);
aPermission.AppendASCII("|");
aPermission.Append(aManifestURL);
}
示例6: sizeof
/* static */ void
FeaturePolicyUtils::DefaultAllowListFeature(const nsAString& aFeatureName,
const nsAString& aDefaultOrigin,
nsAString& aDefaultAllowList)
{
uint32_t numFeatures = (sizeof(sSupportedFeatures) / sizeof(sSupportedFeatures[0]));
for (uint32_t i = 0; i < numFeatures; ++i) {
if (aFeatureName.LowerCaseEqualsASCII(sSupportedFeatures[i].mFeatureName)) {
switch (sSupportedFeatures[i].mDefaultAllowList) {
case FeatureMap::eAll:
aDefaultAllowList.AppendASCII("*");
return;
case FeatureMap::eSelf:
aDefaultAllowList = aDefaultOrigin;
return;
default:
MOZ_CRASH("Unknown default value");
}
}
}
}
示例7: initFunctionPointers
void
nsWin32Locale::GetXPLocale(LCID winLCID, nsAString& locale)
{
initFunctionPointers ();
if (lcidToLocaleName)
{
WCHAR ret_locale[LOCALE_NAME_MAX_LENGTH];
int rv = lcidToLocaleName(winLCID, ret_locale, LOCALE_NAME_MAX_LENGTH, 0);
// rv 0 means that the function failed to match up the LCID, so we fallback
// to the old function
if (rv != 0)
{
locale.Assign(ret_locale);
return;
}
}
DWORD lang_id, sublang_id;
size_t i, j;
lang_id = PRIMARYLANGID(LANGIDFROMLCID(winLCID));
sublang_id = SUBLANGID(LANGIDFROMLCID(winLCID));
/* Special-case Norwegian Bokmal and Norwegian Nynorsk, which have the same
LANG_ID on Windows, but have separate ISO-639-2 codes */
if (lang_id == LANG_NORWEGIAN) {
if (sublang_id == SUBLANG_NORWEGIAN_BOKMAL) {
locale.AssignASCII("nb-NO");
} else if (sublang_id == SUBLANG_NORWEGIAN_NYNORSK) {
locale.AssignASCII("nn-NO");
} else {
locale.AssignASCII("no-NO");
}
return;
}
for(i=0;i<LENGTH_MAPPING_LIST;i++) {
if (lang_id==iso_list[i].win_code) {
/* Special-case Croatian and Serbian, which have the same LANG_ID on
Windows, but have been split into separate ISO-639-2 codes */
if (lang_id == LANG_CROATIAN) {
if (sublang_id == SUBLANG_DEFAULT) {
locale.AssignLiteral(CROATIAN_ISO_CODE);
} else {
locale.AssignLiteral(SERBIAN_ISO_CODE);
}
} else {
locale.AssignASCII(iso_list[i].iso_code);
}
for(j=0;iso_list[i].sublang_list[j].win_code;j++) {
if (sublang_id == iso_list[i].sublang_list[j].win_code) {
locale.Append(PRUnichar('-'));
locale.AppendASCII(iso_list[i].sublang_list[j].iso_code);
break;
}
}
return;
}
}
//
// didn't find any match. fall back to en-US, which is better
// than unusable buttons without 'OK', 'Cancel', etc (bug 224546)
//
locale.AssignLiteral("en-US");
return;
}
示例8: if
void
nsHTMLContentSerializer::AppendAndTranslateEntities(const nsAString& aStr,
nsAString& aOutputStr)
{
if (mBodyOnly && !mInBody) {
return;
}
if (mDisableEntityEncoding) {
aOutputStr.Append(aStr);
return;
}
bool nonBasicEntities =
!!(mFlags & (nsIDocumentEncoder::OutputEncodeLatin1Entities |
nsIDocumentEncoder::OutputEncodeHTMLEntities |
nsIDocumentEncoder::OutputEncodeW3CEntities));
if (!nonBasicEntities &&
(mFlags & (nsIDocumentEncoder::OutputEncodeBasicEntities))) {
const char **entityTable = mInAttribute ? kAttrEntities : kEntities;
PRUint32 start = 0;
const PRUint32 len = aStr.Length();
for (PRUint32 i = 0; i < len; ++i) {
const char* entity = nsnull;
i = FindNextBasicEntity(aStr, len, i, entityTable, &entity);
PRUint32 normalTextLen = i - start;
if (normalTextLen) {
aOutputStr.Append(Substring(aStr, start, normalTextLen));
}
if (entity) {
aOutputStr.AppendASCII(entity);
start = i + 1;
}
}
return;
} else if (nonBasicEntities) {
nsIParserService* parserService = nsContentUtils::GetParserService();
if (!parserService) {
NS_ERROR("Can't get parser service");
return;
}
nsReadingIterator<PRUnichar> done_reading;
aStr.EndReading(done_reading);
// for each chunk of |aString|...
PRUint32 advanceLength = 0;
nsReadingIterator<PRUnichar> iter;
const char **entityTable = mInAttribute ? kAttrEntities : kEntities;
nsCAutoString entityReplacement;
for (aStr.BeginReading(iter);
iter != done_reading;
iter.advance(PRInt32(advanceLength))) {
PRUint32 fragmentLength = iter.size_forward();
PRUint32 lengthReplaced = 0; // the number of UTF-16 codepoints
// replaced by a particular entity
const PRUnichar* c = iter.get();
const PRUnichar* fragmentStart = c;
const PRUnichar* fragmentEnd = c + fragmentLength;
const char* entityText = nsnull;
const char* fullConstEntityText = nsnull;
char* fullEntityText = nsnull;
advanceLength = 0;
// for each character in this chunk, check if it
// needs to be replaced
for (; c < fragmentEnd; c++, advanceLength++) {
PRUnichar val = *c;
if (val <= kValNBSP && entityTable[val]) {
fullConstEntityText = entityTable[val];
break;
} else if (val > 127 &&
((val < 256 &&
mFlags & nsIDocumentEncoder::OutputEncodeLatin1Entities) ||
mFlags & nsIDocumentEncoder::OutputEncodeHTMLEntities)) {
entityReplacement.Truncate();
parserService->HTMLConvertUnicodeToEntity(val, entityReplacement);
if (!entityReplacement.IsEmpty()) {
entityText = entityReplacement.get();
break;
}
}
else if (val > 127 &&
mFlags & nsIDocumentEncoder::OutputEncodeW3CEntities &&
mEntityConverter) {
if (NS_IS_HIGH_SURROGATE(val) &&
c + 1 < fragmentEnd &&
NS_IS_LOW_SURROGATE(*(c + 1))) {
PRUint32 valUTF32 = SURROGATE_TO_UCS4(val, *(++c));
if (NS_SUCCEEDED(mEntityConverter->ConvertUTF32ToEntity(valUTF32,
nsIEntityConverter::entityW3C, &fullEntityText))) {
lengthReplaced = 2;
break;
}
else {
//.........这里部分代码省略.........
示例9: if
bool
nsHTMLContentSerializer::AppendAndTranslateEntities(const nsAString& aStr,
nsAString& aOutputStr)
{
if (mBodyOnly && !mInBody) {
return true;
}
if (mDisableEntityEncoding) {
return aOutputStr.Append(aStr, mozilla::fallible);
}
bool nonBasicEntities =
!!(mFlags & (nsIDocumentEncoder::OutputEncodeLatin1Entities |
nsIDocumentEncoder::OutputEncodeHTMLEntities |
nsIDocumentEncoder::OutputEncodeW3CEntities));
if (!nonBasicEntities &&
(mFlags & (nsIDocumentEncoder::OutputEncodeBasicEntities))) {
const uint8_t* entityTable = mInAttribute ? kAttrEntities : kEntities;
uint32_t start = 0;
const uint32_t len = aStr.Length();
for (uint32_t i = 0; i < len; ++i) {
const char* entity = nullptr;
i = FindNextBasicEntity(aStr, len, i, entityTable, &entity);
uint32_t normalTextLen = i - start;
if (normalTextLen) {
NS_ENSURE_TRUE(aOutputStr.Append(Substring(aStr, start, normalTextLen),
mozilla::fallible), false);
}
if (entity) {
NS_ENSURE_TRUE(aOutputStr.AppendASCII(entity, mozilla::fallible), false);
start = i + 1;
}
}
return true;
} else if (nonBasicEntities) {
nsIParserService* parserService = nsContentUtils::GetParserService();
if (!parserService) {
NS_ERROR("Can't get parser service");
return true;
}
nsReadingIterator<char16_t> done_reading;
aStr.EndReading(done_reading);
// for each chunk of |aString|...
uint32_t advanceLength = 0;
nsReadingIterator<char16_t> iter;
const uint8_t* entityTable = mInAttribute ? kAttrEntities : kEntities;
nsAutoCString entityReplacement;
for (aStr.BeginReading(iter);
iter != done_reading;
iter.advance(int32_t(advanceLength))) {
uint32_t fragmentLength = done_reading - iter;
uint32_t lengthReplaced = 0; // the number of UTF-16 codepoints
// replaced by a particular entity
const char16_t* c = iter.get();
const char16_t* fragmentStart = c;
const char16_t* fragmentEnd = c + fragmentLength;
const char* entityText = nullptr;
const char* fullConstEntityText = nullptr;
char* fullEntityText = nullptr;
advanceLength = 0;
// for each character in this chunk, check if it
// needs to be replaced
for (; c < fragmentEnd; c++, advanceLength++) {
char16_t val = *c;
if (val <= kValNBSP && entityTable[val]) {
fullConstEntityText = kEntityStrings[entityTable[val]];
break;
} else if (val > 127 &&
((val < 256 &&
mFlags & nsIDocumentEncoder::OutputEncodeLatin1Entities) ||
mFlags & nsIDocumentEncoder::OutputEncodeHTMLEntities)) {
entityReplacement.Truncate();
parserService->HTMLConvertUnicodeToEntity(val, entityReplacement);
if (!entityReplacement.IsEmpty()) {
entityText = entityReplacement.get();
break;
}
}
else if (val > 127 &&
mFlags & nsIDocumentEncoder::OutputEncodeW3CEntities &&
mEntityConverter) {
if (NS_IS_HIGH_SURROGATE(val) &&
c + 1 < fragmentEnd &&
NS_IS_LOW_SURROGATE(*(c + 1))) {
uint32_t valUTF32 = SURROGATE_TO_UCS4(val, *(++c));
if (NS_SUCCEEDED(mEntityConverter->ConvertUTF32ToEntity(valUTF32,
nsIEntityConverter::entityW3C, &fullEntityText))) {
lengthReplaced = 2;
break;
}
else {
//.........这里部分代码省略.........