本文整理汇总了C++中nsString::AppendInt方法的典型用法代码示例。如果您正苦于以下问题:C++ nsString::AppendInt方法的具体用法?C++ nsString::AppendInt怎么用?C++ nsString::AppendInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsString
的用法示例。
在下文中一共展示了nsString::AppendInt方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AppendToString
void nsStyleCoord::AppendToString(nsString& aBuffer) const
{
if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) {
aBuffer.AppendFloat(mValue.mFloat);
}
else if ((eStyleUnit_Coord == mUnit) ||
(eStyleUnit_Enumerated == mUnit) ||
(eStyleUnit_Integer == mUnit)) {
aBuffer.AppendInt(mValue.mInt, 10);
aBuffer.AppendLiteral("[0x");
aBuffer.AppendInt(mValue.mInt, 16);
aBuffer.Append(PRUnichar(']'));
}
switch (mUnit) {
case eStyleUnit_Null: aBuffer.AppendLiteral("Null"); break;
case eStyleUnit_Coord: aBuffer.AppendLiteral("tw"); break;
case eStyleUnit_Percent: aBuffer.AppendLiteral("%"); break;
case eStyleUnit_Factor: aBuffer.AppendLiteral("f"); break;
case eStyleUnit_Normal: aBuffer.AppendLiteral("Normal"); break;
case eStyleUnit_Auto: aBuffer.AppendLiteral("Auto"); break;
case eStyleUnit_None: aBuffer.AppendLiteral("None"); break;
case eStyleUnit_Enumerated: aBuffer.AppendLiteral("enum"); break;
case eStyleUnit_Integer: aBuffer.AppendLiteral("int"); break;
case eStyleUnit_Chars: aBuffer.AppendLiteral("chars"); break;
}
aBuffer.Append(PRUnichar(' '));
}
示例2:
void
StyleInfo::FormatColor(const nscolor& aValue, nsString& aFormattedValue)
{
// Combine the string like rgb(R, G, B) from nscolor.
aFormattedValue.AppendLiteral("rgb(");
aFormattedValue.AppendInt(NS_GET_R(aValue));
aFormattedValue.AppendLiteral(", ");
aFormattedValue.AppendInt(NS_GET_G(aValue));
aFormattedValue.AppendLiteral(", ");
aFormattedValue.AppendInt(NS_GET_B(aValue));
aFormattedValue.Append(')');
}
示例3:
void
nsPerformanceSnapshot::GetGroupId(JSContext* cx,
uint64_t uid,
nsString& groupId)
{
JSRuntime* rt = JS_GetRuntime(cx);
uint64_t runtimeId = reinterpret_cast<uintptr_t>(rt);
groupId.AssignLiteral("process: ");
groupId.AppendInt(mProcessId);
groupId.AppendLiteral(", thread: ");
groupId.AppendInt(runtimeId);
groupId.AppendLiteral(", group: ");
groupId.AppendInt(uid);
}
示例4: if
nsresult
nsLoggingSink::QuoteText(const nsAString& aValue, nsString& aResult) {
aResult.Truncate();
/*
if you're stepping through the string anyway, why not use iterators instead of forcing the string to copy?
*/
const nsPromiseFlatString& flat = PromiseFlatString(aValue);
const PRUnichar* cp = flat.get();
const PRUnichar* end = cp + aValue.Length();
while (cp < end) {
PRUnichar ch = *cp++;
if (ch == '"') {
aResult.AppendLiteral(""");
}
else if (ch == '&') {
aResult.AppendLiteral("&");
}
else if ((ch < 32) || (ch >= 127)) {
aResult.AppendLiteral("&#");
aResult.AppendInt(PRInt32(ch), 10);
aResult.Append(PRUnichar(';'));
}
else {
aResult.Append(ch);
}
}
return NS_OK;
}
示例5:
/* static */ void
PromiseDebugging::GetPromiseID(GlobalObject&,
Promise& aPromise,
nsString& aID)
{
uint64_t promiseID = aPromise.GetID();
aID = sIDPrefix;
aID.AppendInt(promiseID);
}
示例6:
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));
}
示例7: FormatSizeString
void nsIndexedToHTML::FormatSizeString(PRInt64 inSize, nsString& outSizeString)
{
outSizeString.Truncate();
if (inSize > PRInt64(0)) {
// round up to the nearest Kilobyte
PRInt64 upperSize = (inSize + PRInt64(1023)) / PRInt64(1024);
outSizeString.AppendInt(upperSize);
outSizeString.AppendLiteral(" KB");
}
}
示例8: UnwrapPromise
/* static */ void
PromiseDebugging::GetPromiseID(GlobalObject&,
JS::Handle<JSObject*> aPromise,
nsString& aID,
ErrorResult& aRv)
{
Promise* promise = UnwrapPromise(aPromise, aRv);
if (aRv.Failed()) {
return;
}
uint64_t promiseID = promise->GetID();
aID = sIDPrefix;
aID.AppendInt(promiseID);
}
示例9: switch
void
nsCSSToken::AppendToString(nsString& aBuffer)
{
switch (mType) {
case eCSSToken_AtKeyword:
aBuffer.Append(PRUnichar('@')); // fall through intentional
case eCSSToken_Ident:
case eCSSToken_WhiteSpace:
case eCSSToken_Function:
case eCSSToken_HTMLComment:
case eCSSToken_URange:
aBuffer.Append(mIdent);
if (mType == eCSSToken_Function)
aBuffer.Append(PRUnichar('('));
break;
case eCSSToken_URL:
case eCSSToken_Bad_URL:
aBuffer.AppendLiteral("url(");
if (mSymbol != PRUnichar(0)) {
aBuffer.Append(mSymbol);
}
aBuffer.Append(mIdent);
if (mSymbol != PRUnichar(0)) {
aBuffer.Append(mSymbol);
}
if (mType == eCSSToken_URL) {
aBuffer.Append(PRUnichar(')'));
}
break;
case eCSSToken_Number:
if (mIntegerValid) {
aBuffer.AppendInt(mInteger, 10);
}
else {
aBuffer.AppendFloat(mNumber);
}
break;
case eCSSToken_Percentage:
NS_ASSERTION(!mIntegerValid, "How did a percentage token get this set?");
aBuffer.AppendFloat(mNumber * 100.0f);
aBuffer.Append(PRUnichar('%'));
break;
case eCSSToken_Dimension:
if (mIntegerValid) {
aBuffer.AppendInt(mInteger, 10);
}
else {
aBuffer.AppendFloat(mNumber);
}
aBuffer.Append(mIdent);
break;
case eCSSToken_String:
aBuffer.Append(mSymbol);
aBuffer.Append(mIdent); // fall through intentional
case eCSSToken_Symbol:
aBuffer.Append(mSymbol);
break;
case eCSSToken_ID:
case eCSSToken_Ref:
aBuffer.Append(PRUnichar('#'));
aBuffer.Append(mIdent);
break;
case eCSSToken_Includes:
aBuffer.AppendLiteral("~=");
break;
case eCSSToken_Dashmatch:
aBuffer.AppendLiteral("|=");
break;
case eCSSToken_Beginsmatch:
aBuffer.AppendLiteral("^=");
break;
case eCSSToken_Endsmatch:
aBuffer.AppendLiteral("$=");
break;
case eCSSToken_Containsmatch:
aBuffer.AppendLiteral("*=");
break;
case eCSSToken_Bad_String:
aBuffer.Append(mSymbol);
aBuffer.Append(mIdent);
break;
default:
NS_ERROR("invalid token type");
break;
}
}
示例10: wordToUnicode
static void wordToUnicode(WORD aWord, nsString& aUnicode)
{
aUnicode.Truncate() ;
aUnicode.AppendInt((PRInt32) aWord) ;
}
示例11: switch
/**
* Append the textual representation of |this| to |aBuffer|.
*/
void
nsCSSToken::AppendToString(nsString& aBuffer) const
{
switch (mType) {
case eCSSToken_Ident:
nsStyleUtil::AppendEscapedCSSIdent(mIdent, aBuffer);
break;
case eCSSToken_AtKeyword:
aBuffer.Append('@');
nsStyleUtil::AppendEscapedCSSIdent(mIdent, aBuffer);
break;
case eCSSToken_ID:
case eCSSToken_Hash:
aBuffer.Append('#');
nsStyleUtil::AppendEscapedCSSIdent(mIdent, aBuffer);
break;
case eCSSToken_Function:
nsStyleUtil::AppendEscapedCSSIdent(mIdent, aBuffer);
aBuffer.Append('(');
break;
case eCSSToken_URL:
case eCSSToken_Bad_URL:
aBuffer.AppendLiteral("url(");
if (mSymbol != PRUnichar(0)) {
nsStyleUtil::AppendEscapedCSSString(mIdent, aBuffer, mSymbol);
} else {
aBuffer.Append(mIdent);
}
if (mType == eCSSToken_URL) {
aBuffer.Append(PRUnichar(')'));
}
break;
case eCSSToken_Number:
if (mIntegerValid) {
aBuffer.AppendInt(mInteger, 10);
} else {
aBuffer.AppendFloat(mNumber);
}
break;
case eCSSToken_Percentage:
aBuffer.AppendFloat(mNumber * 100.0f);
aBuffer.Append(PRUnichar('%'));
break;
case eCSSToken_Dimension:
if (mIntegerValid) {
aBuffer.AppendInt(mInteger, 10);
} else {
aBuffer.AppendFloat(mNumber);
}
nsStyleUtil::AppendEscapedCSSIdent(mIdent, aBuffer);
break;
case eCSSToken_Bad_String:
nsStyleUtil::AppendEscapedCSSString(mIdent, aBuffer, mSymbol);
// remove the trailing quote character
aBuffer.Truncate(aBuffer.Length() - 1);
break;
case eCSSToken_String:
nsStyleUtil::AppendEscapedCSSString(mIdent, aBuffer, mSymbol);
break;
case eCSSToken_Symbol:
aBuffer.Append(mSymbol);
break;
case eCSSToken_Whitespace:
aBuffer.Append(' ');
break;
case eCSSToken_HTMLComment:
case eCSSToken_URange:
aBuffer.Append(mIdent);
break;
case eCSSToken_Includes:
aBuffer.AppendLiteral("~=");
break;
case eCSSToken_Dashmatch:
aBuffer.AppendLiteral("|=");
break;
case eCSSToken_Beginsmatch:
aBuffer.AppendLiteral("^=");
break;
case eCSSToken_Endsmatch:
aBuffer.AppendLiteral("$=");
break;
case eCSSToken_Containsmatch:
aBuffer.AppendLiteral("*=");
break;
//.........这里部分代码省略.........
示例12: switch
void
nsCSSToken::AppendToString(nsString& aBuffer)
{
switch (mType) {
case eCSSToken_AtKeyword:
aBuffer.Append(PRUnichar('@')); // fall through intentional
case eCSSToken_Ident:
case eCSSToken_WhiteSpace:
case eCSSToken_Function:
case eCSSToken_URL:
case eCSSToken_InvalidURL:
case eCSSToken_HTMLComment:
aBuffer.Append(mIdent);
break;
case eCSSToken_Number:
if (mIntegerValid) {
aBuffer.AppendInt(mInteger, 10);
}
else {
aBuffer.AppendFloat(mNumber);
}
break;
case eCSSToken_Percentage:
NS_ASSERTION(!mIntegerValid, "How did a percentage token get this set?");
aBuffer.AppendFloat(mNumber * 100.0f);
aBuffer.Append(PRUnichar('%')); // STRING USE WARNING: technically, this should be |AppendWithConversion|
break;
case eCSSToken_Dimension:
if (mIntegerValid) {
aBuffer.AppendInt(mInteger, 10);
}
else {
aBuffer.AppendFloat(mNumber);
}
aBuffer.Append(mIdent);
break;
case eCSSToken_String:
aBuffer.Append(mSymbol);
aBuffer.Append(mIdent); // fall through intentional
case eCSSToken_Symbol:
aBuffer.Append(mSymbol);
break;
case eCSSToken_ID:
case eCSSToken_Ref:
aBuffer.Append(PRUnichar('#'));
aBuffer.Append(mIdent);
break;
case eCSSToken_Includes:
aBuffer.AppendLiteral("~=");
break;
case eCSSToken_Dashmatch:
aBuffer.AppendLiteral("|=");
break;
case eCSSToken_Error:
aBuffer.Append(mSymbol);
aBuffer.Append(mIdent);
break;
default:
NS_ERROR("invalid token type");
break;
}
}
示例13: HashHdr
nsresult nsMsgGroupView::HashHdr(nsIMsgDBHdr *msgHdr, nsString& aHashKey)
{
nsCString cStringKey;
aHashKey.Truncate();
nsresult rv = NS_OK;
bool rcvDate = false;
switch (m_sortType)
{
case nsMsgViewSortType::bySubject:
(void) msgHdr->GetSubject(getter_Copies(cStringKey));
CopyASCIItoUTF16(cStringKey, aHashKey);
break;
case nsMsgViewSortType::byAuthor:
rv = nsMsgDBView::FetchAuthor(msgHdr, aHashKey);
break;
case nsMsgViewSortType::byRecipient:
(void) msgHdr->GetRecipients(getter_Copies(cStringKey));
CopyASCIItoUTF16(cStringKey, aHashKey);
break;
case nsMsgViewSortType::byAccount:
case nsMsgViewSortType::byTags:
{
nsCOMPtr <nsIMsgDatabase> dbToUse = m_db;
if (!dbToUse) // probably search view
GetDBForViewIndex(0, getter_AddRefs(dbToUse));
rv = (m_sortType == nsMsgViewSortType::byAccount)
? FetchAccount(msgHdr, aHashKey)
: FetchTags(msgHdr, aHashKey);
}
break;
case nsMsgViewSortType::byAttachments:
{
uint32_t flags;
msgHdr->GetFlags(&flags);
aHashKey.Assign(flags & nsMsgMessageFlags::Attachment ? '1' : '0');
break;
}
case nsMsgViewSortType::byFlagged:
{
uint32_t flags;
msgHdr->GetFlags(&flags);
aHashKey.Assign(flags & nsMsgMessageFlags::Marked ? '1' : '0');
break;
}
case nsMsgViewSortType::byPriority:
{
nsMsgPriorityValue priority;
msgHdr->GetPriority(&priority);
aHashKey.AppendInt(priority);
}
break;
case nsMsgViewSortType::byStatus:
{
uint32_t status = 0;
GetStatusSortValue(msgHdr, &status);
aHashKey.AppendInt(status);
}
break;
case nsMsgViewSortType::byReceived:
rcvDate = true;
case nsMsgViewSortType::byDate:
{
uint32_t ageBucket;
rv = GetAgeBucketValue(msgHdr, &ageBucket, rcvDate);
if (NS_SUCCEEDED(rv))
aHashKey.AppendInt(ageBucket);
break;
}
case nsMsgViewSortType::byCustom:
{
nsIMsgCustomColumnHandler* colHandler = GetCurColumnHandlerFromDBInfo();
if (colHandler)
{
rv = colHandler->GetSortStringForRow(msgHdr, aHashKey);
break;
}
}
case nsMsgViewSortType::byCorrespondent:
if (IsOutgoingMsg(msgHdr))
rv = FetchRecipients(msgHdr, aHashKey);
else
rv = FetchAuthor(msgHdr, aHashKey);
break;
default:
NS_ASSERTION(false, "no hash key for this type");
rv = NS_ERROR_FAILURE;
}
return rv;
}