本文整理汇总了C++中nsString::AppendFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ nsString::AppendFloat方法的具体用法?C++ nsString::AppendFloat怎么用?C++ nsString::AppendFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsString
的用法示例。
在下文中一共展示了nsString::AppendFloat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: MaxValue
void
ProgressMeterAccessible<Max>::Value(nsString& aValue)
{
LeafAccessible::Value(aValue);
if (!aValue.IsEmpty())
return;
double maxValue = MaxValue();
if (IsNaN(maxValue) || maxValue == 0)
return;
double curValue = CurValue();
if (IsNaN(curValue))
return;
// Treat the current value bigger than maximum as 100%.
double percentValue = (curValue < maxValue) ?
(curValue / maxValue) * 100 : 100;
aValue.AppendFloat(percentValue);
aValue.Append('%');
}
示例3: 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;
}
}
示例4: 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;
//.........这里部分代码省略.........
示例5: 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;
}
}