本文整理汇总了C++中nsAString::Assign方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAString::Assign方法的具体用法?C++ nsAString::Assign怎么用?C++ nsAString::Assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAString
的用法示例。
在下文中一共展示了nsAString::Assign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: obj
NS_IMETHODIMP
nsJSON::EncodeFromJSVal(JS::Value *value, JSContext *cx, nsAString &result)
{
result.Truncate();
mozilla::Maybe<JSAutoCompartment> ac;
if (value->isObject()) {
JS::Rooted<JSObject*> obj(cx, &value->toObject());
ac.construct(cx, obj);
}
nsJSONWriter writer;
JS::Rooted<JS::Value> vp(cx, *value);
if (!JS_Stringify(cx, &vp, JS::NullPtr(), JS::NullHandleValue, WriteCallback, &writer)) {
return NS_ERROR_XPC_BAD_CONVERT_JS;
}
*value = vp;
NS_ENSURE_TRUE(writer.DidWrite(), NS_ERROR_UNEXPECTED);
writer.FlushBuffer();
result.Assign(writer.mOutputString);
return NS_OK;
}
示例2: ar
NS_IMETHODIMP
nsJSON::EncodeFromJSVal(JS::Value *value, JSContext *cx, nsAString &result)
{
result.Truncate();
// Begin a new request
JSAutoRequest ar(cx);
mozilla::Maybe<JSAutoCompartment> ac;
if (value->isObject()) {
ac.construct(cx, &value->toObject());
}
nsJSONWriter writer;
if (!JS_Stringify(cx, value, NULL, JSVAL_NULL, WriteCallback, &writer)) {
return NS_ERROR_XPC_BAD_CONVERT_JS;
}
NS_ENSURE_TRUE(writer.DidWrite(), NS_ERROR_UNEXPECTED);
writer.FlushBuffer();
result.Assign(writer.mOutputString);
return NS_OK;
}
示例3: while
NS_IMETHODIMP
nsAOLCiter::StripCites(const nsAString& aInString, nsAString& aOutString)
{
// Remove the beginning cites, if any:
nsAutoString tOutputString;
nsReadingIterator <PRUnichar> iter, enditer;
aInString.BeginReading(iter);
aInString.EndReading(enditer);
if (StringBeginsWith(aInString, NS_LITERAL_STRING(">>")))
{
iter.advance(2);
while (nsCRT::IsAsciiSpace(*iter))
++iter;
AppendUnicodeTo(iter, enditer, tOutputString);
}
else
CopyUnicodeTo(iter, enditer, tOutputString);
// Remove the end cites, if any:
tOutputString.Trim("<", PR_FALSE, PR_TRUE, PR_FALSE);
aOutString.Assign(tOutputString);
return NS_OK;
}
示例4: promptSvc
NS_IMETHODIMP
nsNSSDialogs::GetPKCS12FilePassword(nsIInterfaceRequestor* ctx,
nsAString& _password,
bool* _retval)
{
*_retval = false;
nsCOMPtr<nsIPromptService> promptSvc(
do_GetService(NS_PROMPTSERVICE_CONTRACTID));
if (!promptSvc) {
return NS_ERROR_FAILURE;
}
nsAutoString msg;
nsresult rv = mPIPStringBundle->GetStringFromName(
MOZ_UTF16("getPKCS12FilePasswordMessage"), getter_Copies(msg));
if (NS_FAILED(rv)) {
return rv;
}
// Get the parent window for the dialog
nsCOMPtr<mozIDOMWindowProxy> parent = do_GetInterface(ctx);
bool ignored = false;
char16_t* pwTemp = nullptr;
rv = promptSvc->PromptPassword(parent, nullptr, msg.get(), &pwTemp, nullptr,
&ignored, _retval);
if (NS_FAILED(rv)) {
return rv;
}
if (*_retval) {
_password.Assign(pwTemp);
free(pwTemp);
}
return NS_OK;
}
示例5: GetAttr
void
HTMLStyleElement::GetStyleSheetInfo(nsAString& aTitle,
nsAString& aType,
nsAString& aMedia,
bool* aIsScoped,
bool* aIsAlternate)
{
aTitle.Truncate();
aType.Truncate();
aMedia.Truncate();
*aIsAlternate = false;
nsAutoString title;
GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
title.CompressWhitespace();
aTitle.Assign(title);
GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
// The HTML5 spec is formulated in terms of the CSSOM spec, which specifies
// that media queries should be ASCII lowercased during serialization.
nsContentUtils::ASCIIToLower(aMedia);
GetAttr(kNameSpaceID_None, nsGkAtoms::type, aType);
*aIsScoped = HasAttr(kNameSpaceID_None, nsGkAtoms::scoped);
nsAutoString mimeType;
nsAutoString notUsed;
nsContentUtils::SplitMimeType(aType, mimeType, notUsed);
if (!mimeType.IsEmpty() && !mimeType.LowerCaseEqualsLiteral("text/css")) {
return;
}
// If we get here we assume that we're loading a css file, so set the
// type to 'text/css'
aType.AssignLiteral("text/css");
}
示例6:
/* AString error (); */
NS_IMETHODIMP jxMySQL50Statement::Error(nsAString & aError)
{
if (mSTMT == nsnull)
{
SET_ERROR_RETURN (JX_MYSQL50_ERROR_STMT_NULL);
}
if (mErrno == JX_MYSQL50_MYSQL_ERROR)
{
const char *sError =mysql_stmt_error(mSTMT);
aError.Assign(NS_ConvertUTF8toUTF16(sError));
return NS_OK;
}
NON_MYSQL_ERROR(mErrno, aError);
if (aError.Length() == 0)
{
const char* me = mysql_stmt_error(mSTMT);
AppendUTF8toUTF16(nsPrintfCString(0x1000, "Unknown error 0x%0x. Last MYSQL error is %s", mErrno, (me && *me) ? me : ""), aError);
}
//_retval.Assign(NS_ConvertUTF8toUTF16(mysql_stmt_error(mSTMT)));
return NS_OK;
}
示例7: switch
NS_IMETHODIMP
nsROCSSPrimitiveValue::GetStringValue(nsAString& aReturn)
{
switch (mType) {
case CSS_IDENT:
CopyUTF8toUTF16(nsCSSKeywords::GetStringValue(mValue.mKeyword), aReturn);
break;
case CSS_STRING:
case CSS_ATTR:
aReturn.Assign(mValue.mString);
break;
case CSS_URI: {
nsAutoCString spec;
if (mValue.mURI)
mValue.mURI->GetSpec(spec);
CopyUTF8toUTF16(spec, aReturn);
}
break;
default:
aReturn.Truncate();
return NS_ERROR_DOM_INVALID_ACCESS_ERR;
}
return NS_OK;
}
示例8: GetInfoForFile
virtual void
GetInfoForFile(nsCString& aFileName, nsAString& aFaceList,
PRUint32 *aTimestamp, PRUint32 *aFileSize,
IndexList &aIndexList)
{
if (!mMap.ops)
return;
PLDHashEntryHdr *hdr = PL_DHashTableOperate(&mMap, aFileName.get(), PL_DHASH_LOOKUP);
if (!hdr)
return;
FNCMapEntry* entry = static_cast<FNCMapEntry*>(hdr);
if (entry && entry->mTimestamp && entry->mFilesize) {
*aTimestamp = entry->mTimestamp;
*aFileSize = entry->mFilesize;
char* indexes = const_cast<char*>(entry->mIndexes.get());
char* endptr = indexes + 1;
unsigned long index = strtoul(indexes, &endptr, 10);
while (indexes < endptr && indexes[0] != '\0') {
aIndexList.AppendElement(index);
indexes = endptr + 1;
}
aFaceList.Assign(entry->mFaces);
}
}
示例9: classStr
// Removes the value aRemoveValue from the string list of white-space separated
// values aValueList
void
ChangeStyleTransaction::RemoveValueFromListOfValues(
nsAString& aValues,
const nsAString& aRemoveValue)
{
nsAutoString classStr(aValues);
nsAutoString outString;
// put an extra null at the end
classStr.Append(kNullCh);
char16_t* start = classStr.BeginWriting();
char16_t* end = start;
while (kNullCh != *start) {
while (kNullCh != *start && nsCRT::IsAsciiSpace(*start)) {
// skip leading space
start++;
}
end = start;
while (kNullCh != *end && !nsCRT::IsAsciiSpace(*end)) {
// look for space or end
end++;
}
// end string here
*end = kNullCh;
if (start < end && !aRemoveValue.Equals(start)) {
outString.Append(start);
outString.Append(char16_t(' '));
}
start = ++end;
}
aValues.Assign(outString);
}
示例10:
NS_IMETHODIMP
nsMIMEInfoAndroid::GetDescription(nsAString& aDesc)
{
aDesc.Assign(mDescription);
return NS_OK;
}
示例11: ArrayLength
/* readonly attribute DOMString cleartypeParameters; */
NS_IMETHODIMP
GfxInfo::GetCleartypeParameters(nsAString & aCleartypeParams)
{
nsTArray<ClearTypeParameterInfo> clearTypeParams;
gfxWindowsPlatform::GetPlatform()->GetCleartypeParams(clearTypeParams);
PRUint32 d, numDisplays = clearTypeParams.Length();
bool displayNames = (numDisplays > 1);
bool foundData = false;
nsString outStr;
WCHAR valStr[256];
for (d = 0; d < numDisplays; d++) {
ClearTypeParameterInfo& params = clearTypeParams[d];
if (displayNames) {
swprintf_s(valStr, ArrayLength(valStr),
L"%s [ ", params.displayName.get());
outStr.Append(valStr);
}
if (params.gamma >= 0) {
foundData = true;
swprintf_s(valStr, ArrayLength(valStr),
L"Gamma: %d ", params.gamma);
outStr.Append(valStr);
}
if (params.pixelStructure >= 0) {
foundData = true;
if (params.pixelStructure == PIXEL_STRUCT_RGB ||
params.pixelStructure == PIXEL_STRUCT_BGR)
{
swprintf_s(valStr, ArrayLength(valStr),
L"Pixel Structure: %s ",
(params.pixelStructure == PIXEL_STRUCT_RGB ?
L"RGB" : L"BGR"));
} else {
swprintf_s(valStr, ArrayLength(valStr),
L"Pixel Structure: %d ", params.pixelStructure);
}
outStr.Append(valStr);
}
if (params.clearTypeLevel >= 0) {
foundData = true;
swprintf_s(valStr, ArrayLength(valStr),
L"ClearType Level: %d ", params.clearTypeLevel);
outStr.Append(valStr);
}
if (params.enhancedContrast >= 0) {
foundData = true;
swprintf_s(valStr, ArrayLength(valStr),
L"Enhanced Contrast: %d ", params.enhancedContrast);
outStr.Append(valStr);
}
if (displayNames) {
outStr.Append(L"] ");
}
}
if (foundData) {
aCleartypeParams.Assign(outStr);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
示例12: while
nsresult
nsSOAPUtils::MakeNamespacePrefix(nsISOAPEncoding * aEncoding,
nsIDOMElement * aScope,
const nsAString & aURI,
nsAString & aPrefix)
{
// This may change for level 3 serialization, so be sure to gut this
// and call the standardized level 3 method when it is available.
nsAutoString externalURI;
if (aEncoding) {
nsresult rc = aEncoding->GetExternalSchemaURI(aURI,externalURI);
if (NS_FAILED(rc))
return rc;
}
else {
externalURI.Assign(aURI);
}
aPrefix.Truncate();
if (externalURI.IsEmpty())
return NS_OK;
if (externalURI.Equals(gSOAPStrings->kXMLNamespaceURI)) {
aPrefix.Assign(gSOAPStrings->kXMLPrefix);
return NS_OK;
}
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsAutoString tstr;
nsresult rc;
PRUint32 maxns = 0; // Keep track of max generated NS
for (;;) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc))
return rc;
if (attrs) {
PRUint32 i;
PRUint32 count;
rc = attrs->GetLength(&count);
if (NS_FAILED(rc))
return PR_FALSE;
for (i = 0;i < count;i++) {
attrs->Item(i, getter_AddRefs(temp));
if (!temp)
break;
temp->GetNamespaceURI(tstr);
if (!tstr.Equals(gSOAPStrings->kXMLNamespaceNamespaceURI))
continue;
temp->GetNodeValue(tstr);
if (tstr.Equals(externalURI)) {
nsAutoString prefix;
rc = temp->GetLocalName(prefix);
if (NS_FAILED(rc))
return rc;
nsCOMPtr<nsIDOMNode> check = aScope;
PRBool hasDecl;
nsCOMPtr<nsIDOMElement> echeck;
while (check != current) { // Make sure prefix is not overridden
echeck = do_QueryInterface(check);
if (echeck) {
rc = echeck->
HasAttributeNS(gSOAPStrings->kXMLNamespaceNamespaceURI, prefix,
&hasDecl);
if (NS_FAILED(rc))
return rc;
if (hasDecl)
break;
echeck->GetParentNode(getter_AddRefs(check));
}
}
if (check == current) {
aPrefix.Assign(prefix);
return NS_OK;
}
}
rc = temp->GetLocalName(tstr);
if (NS_FAILED(rc))
return rc;
else { // Decode the generated namespace into a number
nsReadingIterator < PRUnichar > i1;
nsReadingIterator < PRUnichar > i2;
tstr.BeginReading(i1);
tstr.EndReading(i2);
if (i1 == i2 || *i1 != 'n')
continue;
i1++;
if (i1 == i2 || *i1 != 's')
continue;
i1++;
PRUint32 n = 0;
while (i1 != i2) {
PRUnichar c = *i1;
i1++;
if (c < '0' || c > '9') {
n = 0;
break;
}
n = n * 10 + (c - '0');
}
if (n > maxns)
maxns = n;
//.........这里部分代码省略.........
示例13: GetTitle
/* readonly attribute AString title; */
NS_IMETHOD GetTitle(nsAString & aTitle) override {
aTitle.Assign(mTitle);
return NS_OK;
}
示例14: if
nsresult
nsMacUtilsImpl::GetArchString(nsAString& aArchString)
{
if (!mBinaryArchs.IsEmpty()) {
aArchString.Assign(mBinaryArchs);
return NS_OK;
}
aArchString.Truncate();
bool foundPPC = false,
foundX86 = false,
foundPPC64 = false,
foundX86_64 = false;
CFBundleRef mainBundle = ::CFBundleGetMainBundle();
if (!mainBundle) {
return NS_ERROR_FAILURE;
}
CFArrayRef archList = ::CFBundleCopyExecutableArchitectures(mainBundle);
if (!archList) {
return NS_ERROR_FAILURE;
}
CFIndex archCount = ::CFArrayGetCount(archList);
for (CFIndex i = 0; i < archCount; i++) {
CFNumberRef arch = static_cast<CFNumberRef>(::CFArrayGetValueAtIndex(archList, i));
int archInt = 0;
if (!::CFNumberGetValue(arch, kCFNumberIntType, &archInt)) {
::CFRelease(archList);
return NS_ERROR_FAILURE;
}
if (archInt == kCFBundleExecutableArchitecturePPC) {
foundPPC = true;
} else if (archInt == kCFBundleExecutableArchitectureI386) {
foundX86 = true;
} else if (archInt == kCFBundleExecutableArchitecturePPC64) {
foundPPC64 = true;
} else if (archInt == kCFBundleExecutableArchitectureX86_64) {
foundX86_64 = true;
}
}
::CFRelease(archList);
// The order in the string must always be the same so
// don't do this in the loop.
if (foundPPC) {
mBinaryArchs.AppendLiteral("ppc");
}
if (foundX86) {
if (!mBinaryArchs.IsEmpty()) {
mBinaryArchs.Append('-');
}
mBinaryArchs.AppendLiteral("i386");
}
if (foundPPC64) {
if (!mBinaryArchs.IsEmpty()) {
mBinaryArchs.Append('-');
}
mBinaryArchs.AppendLiteral("ppc64");
}
if (foundX86_64) {
if (!mBinaryArchs.IsEmpty()) {
mBinaryArchs.Append('-');
}
mBinaryArchs.AppendLiteral("x86_64");
}
aArchString.Assign(mBinaryArchs);
return (aArchString.IsEmpty() ? NS_ERROR_FAILURE : NS_OK);
}
示例15:
/* readonly attribute AString addonId; */
NS_IMETHODIMP
nsPerformanceGroupDetails::GetAddonId(nsAString& aAddonId) {
aAddonId.Assign(AddonId());
return NS_OK;
};