本文整理汇总了C++中nsAString::AppendInt方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAString::AppendInt方法的具体用法?C++ nsAString::AppendInt怎么用?C++ nsAString::AppendInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAString
的用法示例。
在下文中一共展示了nsAString::AppendInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
nsSVGIntegerPair::GetBaseValueString(nsAString &aValueAsString) const
{
aValueAsString.Truncate();
aValueAsString.AppendInt(mBaseVal[0]);
if (mBaseVal[0] != mBaseVal[1]) {
aValueAsString.AppendLiteral(", ");
aValueAsString.AppendInt(mBaseVal[1]);
}
}
示例2: if
nsresult
GonkCameraParameters::MapIsoFromGonk(const char* aIso, nsAString& aIsoOut)
{
if (!aIso) {
return NS_ERROR_NOT_AVAILABLE;
}
if (strcmp(aIso, "ISO_HJR") == 0) {
aIsoOut.AssignASCII("hjr");
} else if (strcmp(aIso, "auto") == 0) {
aIsoOut.AssignASCII("auto");
} else {
unsigned int iso;
char ignored;
// Some camera libraries return ISO modes as "ISO100", others as "100".
if (sscanf(aIso, "ISO%u%c", &iso, &ignored) != 1 &&
sscanf(aIso, "%u%c", &iso, &ignored) != 1) {
return NS_ERROR_INVALID_ARG;
}
aIsoOut.Truncate(0);
aIsoOut.AppendInt(iso);
}
return NS_OK;
}
示例3: switch
/*
* This function maps attribute id and returns corresponding values
*/
static void
ConvertAttributeString(BluetoothAvrcpMediaAttribute aAttrId,
nsAString& aAttrStr)
{
BluetoothAvrcpManager* avrcp = BluetoothAvrcpManager::Get();
NS_ENSURE_TRUE_VOID(avrcp);
switch (aAttrId) {
case AVRCP_MEDIA_ATTRIBUTE_TITLE:
avrcp->GetTitle(aAttrStr);
/*
* bluedroid can only send string length AVRC_MAX_ATTR_STR_LEN - 1
*/
if (aAttrStr.Length() >= AVRC_MAX_ATTR_STR_LEN) {
aAttrStr.Truncate(AVRC_MAX_ATTR_STR_LEN - 1);
BT_WARNING("Truncate media item attribute title, length is over 255");
}
break;
case AVRCP_MEDIA_ATTRIBUTE_ARTIST:
avrcp->GetArtist(aAttrStr);
if (aAttrStr.Length() >= AVRC_MAX_ATTR_STR_LEN) {
aAttrStr.Truncate(AVRC_MAX_ATTR_STR_LEN - 1);
BT_WARNING("Truncate media item attribute artist, length is over 255");
}
break;
case AVRCP_MEDIA_ATTRIBUTE_ALBUM:
avrcp->GetAlbum(aAttrStr);
if (aAttrStr.Length() >= AVRC_MAX_ATTR_STR_LEN) {
aAttrStr.Truncate(AVRC_MAX_ATTR_STR_LEN - 1);
BT_WARNING("Truncate media item attribute album, length is over 255");
}
break;
case AVRCP_MEDIA_ATTRIBUTE_TRACK_NUM:
aAttrStr.AppendInt(avrcp->GetMediaNumber());
break;
case AVRCP_MEDIA_ATTRIBUTE_NUM_TRACKS:
aAttrStr.AppendInt(avrcp->GetTotalMediaNumber());
break;
case AVRCP_MEDIA_ATTRIBUTE_GENRE:
// TODO: we currently don't support genre from music player
aAttrStr.Truncate();
break;
case AVRCP_MEDIA_ATTRIBUTE_PLAYING_TIME:
aAttrStr.AppendInt(avrcp->GetDuration());
break;
}
}
示例4: ReversedUuidToString
void
GeneratePathFromGattId(const BluetoothGattId& aId,
nsAString& aPath,
nsAString& aUuidStr)
{
ReversedUuidToString(aId.mUuid, aUuidStr);
aPath.Assign(aUuidStr);
aPath.AppendLiteral("_");
aPath.AppendInt(aId.mInstanceId);
}
示例5: UuidToString
void
GeneratePathFromGattId(const BluetoothGattId& aId,
nsAString& aPath)
{
nsString uuidStr;
UuidToString(aId.mUuid, uuidStr);
aPath.Assign(uuidStr);
aPath.AppendLiteral("_");
aPath.AppendInt(aId.mInstanceId);
}
示例6: value
NS_IMETHODIMP
sbStatusPropertyInfo::GetCellValue(const nsAString& aValue,
nsAString& retval)
{
sbStatusPropertyValue value(aValue);
retval.Truncate();
if (value.GetMode() == sbStatusPropertyValue::eRipping) {
retval.AppendInt(value.GetCurrent());
}
return NS_OK;
}
示例7: escapedValue
NS_IMETHODIMP
sbSQLBuilderCriterionIn::ToString(nsAString& _retval)
{
AppendTableColumnTo(_retval);
_retval.AppendLiteral(" in (");
PRUint32 len = mInItems.Length();
for (PRUint32 i = 0; i < len; i++) {
const sbInItem& ii = mInItems[i];
switch(ii.type) {
case eIsNull:
/* not implemented */
break;
case eString:
{
nsAutoString escapedValue(ii.stringValue);
SB_EscapeSQL(escapedValue);
_retval.AppendLiteral("'");
_retval.Append(escapedValue);
_retval.AppendLiteral("'");
break;
}
case eInteger32:
_retval.AppendInt(ii.int32Value);
break;
case eSubquery:
{
nsresult rv;
nsAutoString sql;
rv = ii.subquery->ToString(sql);
NS_ENSURE_SUCCESS(rv, rv);
_retval.Append(sql);
break;
}
}
if (i + 1 < len) {
_retval.AppendLiteral(", ");
}
}
_retval.AppendLiteral(")");
return NS_OK;
}
示例8: if
nsresult
GonkCameraParameters::MapIsoFromGonk(const char* aIso, nsAString& aIsoOut)
{
if (strcmp(aIso, "ISO_HJR") == 0) {
aIsoOut.AssignASCII("hjr");
} else if (strcmp(aIso, "auto") == 0) {
aIsoOut.AssignASCII("auto");
} else {
unsigned int iso;
if (sscanf(aIso, "ISO%u", &iso) != 1) {
return NS_ERROR_INVALID_ARG;
}
aIsoOut.AppendInt(iso);
}
return NS_OK;
}
示例9: switch
static bool
AppendStandardNamespacePrefixToString(nsAString& aString, int32_t aNameSpace)
{
if (aNameSpace == kNameSpaceID_Unknown) {
// Wildcard namespace; no prefix to write.
return false;
}
switch (aNameSpace) {
case kNameSpaceID_None:
break;
case kNameSpaceID_XML:
aString.AppendLiteral("xml");
break;
case kNameSpaceID_XHTML:
aString.AppendLiteral("html");
break;
case kNameSpaceID_XLink:
aString.AppendLiteral("xlink");
break;
case kNameSpaceID_XSLT:
aString.AppendLiteral("xsl");
break;
case kNameSpaceID_XBL:
aString.AppendLiteral("xbl");
break;
case kNameSpaceID_MathML:
aString.AppendLiteral("math");
break;
case kNameSpaceID_RDF:
aString.AppendLiteral("rdf");
break;
case kNameSpaceID_XUL:
aString.AppendLiteral("xul");
break;
case kNameSpaceID_SVG:
aString.AppendLiteral("svg");
break;
default:
aString.AppendLiteral("ns");
aString.AppendInt(aNameSpace);
break;
}
return true;
}
示例10: Substring
nsresult
HTMLCanvasElement::ParseParams(JSContext* aCx,
const nsAString& aType,
const JS::Value& aEncoderOptions,
nsAString& aParams,
bool* usingCustomParseOptions)
{
// Quality parameter is only valid for the image/jpeg MIME type
if (aType.EqualsLiteral("image/jpeg")) {
if (aEncoderOptions.isNumber()) {
double quality = aEncoderOptions.toNumber();
// Quality must be between 0.0 and 1.0, inclusive
if (quality >= 0.0 && quality <= 1.0) {
aParams.AppendLiteral("quality=");
aParams.AppendInt(NS_lround(quality * 100.0));
}
}
}
// If we haven't parsed the aParams check for proprietary options.
// The proprietary option -moz-parse-options will take a image lib encoder
// parse options string as is and pass it to the encoder.
*usingCustomParseOptions = false;
if (aParams.Length() == 0 && aEncoderOptions.isString()) {
NS_NAMED_LITERAL_STRING(mozParseOptions, "-moz-parse-options:");
nsAutoJSString paramString;
if (!paramString.init(aCx, aEncoderOptions.toString())) {
return NS_ERROR_FAILURE;
}
if (StringBeginsWith(paramString, mozParseOptions)) {
nsDependentSubstring parseOptions = Substring(paramString,
mozParseOptions.Length(),
paramString.Length() -
mozParseOptions.Length());
aParams.Append(parseOptions);
*usingCustomParseOptions = true;
}
}
return NS_OK;
}
示例11: value
NS_IMETHODIMP
sbDownloadButtonPropertyInfo::GetCellValue(const nsAString& aValue,
nsAString& _retval)
{
sbDownloadButtonPropertyValue value(aValue);
switch(value.GetMode()) {
case sbDownloadButtonPropertyValue::eDownloading:
case sbDownloadButtonPropertyValue::ePaused:
if (value.GetTotal() > 0) {
PRFloat64 progress =
((PRFloat64) value.GetCurrent() / (PRFloat64) value.GetTotal()) * 100;
_retval.AppendInt((PRUint32) progress);
}
break;
default:
_retval.Truncate();
}
return NS_OK;
}
示例12: GetDisplayRAM
/* readonly attribute DOMString DisplayRAM; */
NS_IMETHODIMP nsSystemInfo::GetDisplayRAM(nsAString & aDisplayRAM)
{
aDisplayRAM.AppendInt(vram);
return NS_OK;
}
示例13: if
//.........这里部分代码省略.........
/* Append the function name. */
const nsCSSValue& functionName = array->Item(0);
if (functionName.GetUnit() == eCSSUnit_Enumerated) {
// We assume that the first argument is always of nsCSSKeyword type.
const nsCSSKeyword functionId =
static_cast<nsCSSKeyword>(functionName.GetIntValue());
nsStyleUtil::AppendEscapedCSSIdent(
NS_ConvertASCIItoUTF16(nsCSSKeywords::GetStringValue(functionId)),
aResult);
} else {
functionName.AppendToString(aProperty, aResult);
}
aResult.AppendLiteral("(");
/* Now, step through the function contents, writing each of them as we go. */
for (size_t index = 1; index < array->Count(); ++index) {
array->Item(index).AppendToString(aProperty, aResult);
/* If we're not at the final element, append a comma. */
if (index + 1 != array->Count())
aResult.AppendLiteral(", ");
}
/* Finally, append the closing parenthesis. */
aResult.AppendLiteral(")");
}
else if (IsCalcUnit()) {
NS_ABORT_IF_FALSE(GetUnit() == eCSSUnit_Calc, "unexpected unit");
CSSValueSerializeCalcOps ops(aProperty, aResult);
css::SerializeCalc(*this, ops);
}
else if (eCSSUnit_Integer == unit) {
aResult.AppendInt(GetIntValue(), 10);
}
else if (eCSSUnit_Enumerated == unit) {
if (eCSSProperty_text_decoration_line == aProperty) {
PRInt32 intValue = GetIntValue();
if (NS_STYLE_TEXT_DECORATION_LINE_NONE == intValue) {
AppendASCIItoUTF16(nsCSSProps::LookupPropertyValue(aProperty, intValue),
aResult);
} else {
// Ignore the "override all" internal value.
// (It doesn't have a string representation.)
intValue &= ~NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL;
nsStyleUtil::AppendBitmaskCSSValue(
aProperty, intValue,
NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE,
NS_STYLE_TEXT_DECORATION_LINE_PREF_ANCHORS,
aResult);
}
}
else if (eCSSProperty_marks == aProperty) {
PRInt32 intValue = GetIntValue();
if (intValue == NS_STYLE_PAGE_MARKS_NONE) {
AppendASCIItoUTF16(nsCSSProps::LookupPropertyValue(aProperty, intValue),
aResult);
} else {
nsStyleUtil::AppendBitmaskCSSValue(aProperty, intValue,
NS_STYLE_PAGE_MARKS_CROP,
NS_STYLE_PAGE_MARKS_REGISTER,
aResult);
}
}
else if (eCSSProperty_unicode_bidi == aProperty) {
PR_STATIC_ASSERT(NS_STYLE_UNICODE_BIDI_NORMAL == 0);
示例14:
void
nsSVGInteger::GetBaseValueString(nsAString & aValueAsString)
{
aValueAsString.Truncate();
aValueAsString.AppendInt(mBaseVal);
}
示例15: GetDisplayHeight
/* readonly attribute DOMString DisplayHeight; */
NS_IMETHODIMP nsSystemInfo::GetDisplayHeight(nsAString & aDisplayHeight)
{
aDisplayHeight.AppendInt(mHeight);
return NS_OK;
}