本文整理汇总了C++中nsString::Right方法的典型用法代码示例。如果您正苦于以下问题:C++ nsString::Right方法的具体用法?C++ nsString::Right怎么用?C++ nsString::Right使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsString
的用法示例。
在下文中一共展示了nsString::Right方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SplitString
void nsOutlookMail::SplitString( nsString& val1, nsString& val2)
{
nsString temp;
// Find the last line if there is more than one!
PRInt32 idx = val1.RFind( "\x0D\x0A");
PRInt32 cnt = 2;
if (idx == -1) {
cnt = 1;
idx = val1.RFindChar( 13);
}
if (idx == -1)
idx= val1.RFindChar( 10);
if (idx != -1) {
val1.Right( val2, val1.Length() - idx - cnt);
val1.Left( temp, idx);
val1 = temp;
SanitizeValue( val1);
}
}
示例2: ExtractCharset
void nsEudoraCompose::ExtractCharset( nsString& str)
{
nsString tStr;
PRInt32 idx = str.Find( "charset=", PR_TRUE);
if (idx != -1) {
idx += 8;
str.Right( tStr, str.Length() - idx);
idx = tStr.FindChar( ';');
if (idx != -1)
tStr.Left( str, idx);
else
str = tStr;
str.Trim( kWhitespace);
if ((str.CharAt( 0) == '"') && (str.Length() > 2)) {
str.Mid( tStr, 1, str.Length() - 2);
str = tStr;
str.Trim( kWhitespace);
}
}
else
str.Truncate();
}
示例3: if
// parse an input string in the following format (see bug 148326 for testcases):
// [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | css-unit | namedspace)
bool
nsMathMLmpaddedFrame::ParseAttribute(nsString& aString,
int32_t& aSign,
nsCSSValue& aCSSValue,
int32_t& aPseudoUnit)
{
aCSSValue.Reset();
aSign = NS_MATHML_SIGN_INVALID;
aPseudoUnit = NS_MATHML_PSEUDO_UNIT_UNSPECIFIED;
aString.CompressWhitespace(); // aString is not a const in this code
int32_t stringLength = aString.Length();
if (!stringLength)
return false;
nsAutoString number, unit;
//////////////////////
// see if the sign is there
int32_t i = 0;
if (aString[0] == '+') {
aSign = NS_MATHML_SIGN_PLUS;
i++;
}
else if (aString[0] == '-') {
aSign = NS_MATHML_SIGN_MINUS;
i++;
}
else
aSign = NS_MATHML_SIGN_UNSPECIFIED;
// get the number
bool gotDot = false, gotPercent = false;
for (; i < stringLength; i++) {
PRUnichar c = aString[i];
if (gotDot && c == '.') {
// error - two dots encountered
aSign = NS_MATHML_SIGN_INVALID;
return false;
}
if (c == '.')
gotDot = true;
else if (!nsCRT::IsAsciiDigit(c)) {
break;
}
number.Append(c);
}
// catch error if we didn't enter the loop above... we could simply initialize
// floatValue = 1, to cater for cases such as width="height", but that wouldn't
// be in line with the spec which requires an explicit number
if (number.IsEmpty()) {
aSign = NS_MATHML_SIGN_INVALID;
return false;
}
nsresult errorCode;
float floatValue = number.ToFloat(&errorCode);
if (NS_FAILED(errorCode)) {
aSign = NS_MATHML_SIGN_INVALID;
return false;
}
// see if this is a percentage-based value
if (i < stringLength && aString[i] == '%') {
i++;
gotPercent = true;
}
// the remainder now should be a css-unit, or a pseudo-unit, or a named-space
aString.Right(unit, stringLength - i);
if (unit.IsEmpty()) {
if (gotPercent) {
// case ["+"|"-"] unsigned-number "%"
aCSSValue.SetPercentValue(floatValue / 100.0f);
aPseudoUnit = NS_MATHML_PSEUDO_UNIT_ITSELF;
return true;
} else {
// case ["+"|"-"] unsigned-number
// XXXfredw: should we allow non-zero unitless values? See bug 757703.
if (!floatValue) {
aCSSValue.SetFloatValue(floatValue, eCSSUnit_Number);
aPseudoUnit = NS_MATHML_PSEUDO_UNIT_ITSELF;
return true;
}
}
}
else if (unit.EqualsLiteral("width")) aPseudoUnit = NS_MATHML_PSEUDO_UNIT_WIDTH;
else if (unit.EqualsLiteral("height")) aPseudoUnit = NS_MATHML_PSEUDO_UNIT_HEIGHT;
else if (unit.EqualsLiteral("depth")) aPseudoUnit = NS_MATHML_PSEUDO_UNIT_DEPTH;
else if (!gotPercent) { // percentage can only apply to a pseudo-unit
// see if the unit is a named-space
if (nsMathMLElement::ParseNamedSpaceValue(unit, aCSSValue,
//.........这里部分代码省略.........
示例4: if
// parse an input string in the following format (see bug 148326 for testcases):
// [+|-] unsigned-number (% [pseudo-unit] | pseudo-unit | css-unit | namedspace)
PRBool
nsMathMLmpaddedFrame::ParseAttribute(nsString& aString,
PRInt32& aSign,
nsCSSValue& aCSSValue,
PRInt32& aPseudoUnit)
{
aCSSValue.Reset();
aSign = NS_MATHML_SIGN_INVALID;
aPseudoUnit = NS_MATHML_PSEUDO_UNIT_UNSPECIFIED;
aString.CompressWhitespace(); // aString is not a const in this code
PRInt32 stringLength = aString.Length();
if (!stringLength)
return PR_FALSE;
nsAutoString number, unit;
//////////////////////
// see if the sign is there
PRInt32 i = 0;
if (aString[0] == '+') {
aSign = NS_MATHML_SIGN_PLUS;
i++;
}
else if (aString[0] == '-') {
aSign = NS_MATHML_SIGN_MINUS;
i++;
}
else
aSign = NS_MATHML_SIGN_UNSPECIFIED;
// skip any space after the sign
if (i < stringLength && nsCRT::IsAsciiSpace(aString[i]))
i++;
// get the number
PRBool gotDot = PR_FALSE, gotPercent = PR_FALSE;
for (; i < stringLength; i++) {
PRUnichar c = aString[i];
if (gotDot && c == '.') {
// error - two dots encountered
aSign = NS_MATHML_SIGN_INVALID;
return PR_FALSE;
}
if (c == '.')
gotDot = PR_TRUE;
else if (!nsCRT::IsAsciiDigit(c)) {
break;
}
number.Append(c);
}
// catch error if we didn't enter the loop above... we could simply initialize
// floatValue = 1, to cater for cases such as width="height", but that wouldn't
// be in line with the spec which requires an explicit number
if (number.IsEmpty()) {
#ifdef NS_DEBUG
printf("mpadded: attribute with bad numeric value: %s\n",
NS_LossyConvertUTF16toASCII(aString).get());
#endif
aSign = NS_MATHML_SIGN_INVALID;
return PR_FALSE;
}
PRInt32 errorCode;
float floatValue = number.ToFloat(&errorCode);
if (errorCode) {
aSign = NS_MATHML_SIGN_INVALID;
return PR_FALSE;
}
// skip any space after the number
if (i < stringLength && nsCRT::IsAsciiSpace(aString[i]))
i++;
// see if this is a percentage-based value
if (i < stringLength && aString[i] == '%') {
i++;
gotPercent = PR_TRUE;
// skip any space after the '%' sign
if (i < stringLength && nsCRT::IsAsciiSpace(aString[i]))
i++;
}
// the remainder now should be a css-unit, or a pseudo-unit, or a named-space
aString.Right(unit, stringLength - i);
if (unit.IsEmpty()) {
// also cater for the edge case of "0" for which the unit is optional
if (gotPercent || !floatValue) {
aCSSValue.SetPercentValue(floatValue / 100.0f);
aPseudoUnit = NS_MATHML_PSEUDO_UNIT_ITSELF;
return PR_TRUE;
}
//.........这里部分代码省略.........
示例5: if
/* static */ PRBool
nsMathMLFrame::ParseNumericValue(nsString& aString,
nsCSSValue& aCSSValue)
{
aCSSValue.Reset();
aString.CompressWhitespace(); // aString is not a const in this code...
PRInt32 stringLength = aString.Length();
if (!stringLength)
return PR_FALSE;
nsAutoString number, unit;
// Gather up characters that make up the number
PRBool gotDot = PR_FALSE;
PRUnichar c;
for (PRInt32 i = 0; i < stringLength; i++) {
c = aString[i];
if (gotDot && c == '.')
return PR_FALSE; // two dots encountered
else if (c == '.')
gotDot = PR_TRUE;
else if (!nsCRT::IsAsciiDigit(c)) {
aString.Right(unit, stringLength - i);
unit.CompressWhitespace(); // some authors leave blanks before the unit
break;
}
number.Append(c);
}
// on exit, also return a nicer string version of the value in case
// the caller wants it (e.g., this removes whitespace before units)
aString.Assign(number);
aString.Append(unit);
// Convert number to floating point
PRInt32 errorCode;
float floatValue = number.ToFloat(&errorCode);
if (errorCode)
return PR_FALSE;
nsCSSUnit cssUnit;
if (unit.IsEmpty()) {
cssUnit = eCSSUnit_Number; // no explicit unit, this is a number that will act as a multiplier
}
else if (unit.EqualsLiteral("%")) {
aCSSValue.SetPercentValue(floatValue / 100.0f);
return PR_TRUE;
}
else if (unit.EqualsLiteral("em")) cssUnit = eCSSUnit_EM;
else if (unit.EqualsLiteral("ex")) cssUnit = eCSSUnit_XHeight;
else if (unit.EqualsLiteral("px")) cssUnit = eCSSUnit_Pixel;
else if (unit.EqualsLiteral("in")) cssUnit = eCSSUnit_Inch;
else if (unit.EqualsLiteral("cm")) cssUnit = eCSSUnit_Centimeter;
else if (unit.EqualsLiteral("mm")) cssUnit = eCSSUnit_Millimeter;
else if (unit.EqualsLiteral("pt")) cssUnit = eCSSUnit_Point;
else if (unit.EqualsLiteral("pc")) cssUnit = eCSSUnit_Pica;
else // unexpected unit
return PR_FALSE;
aCSSValue.SetFloatValue(floatValue, cssUnit);
return PR_TRUE;
}
示例6: if
nsresult
FileSystemDataSource::getIEFavoriteURL(nsIRDFResource *source, nsString aFileURL, nsIRDFLiteral **urlLiteral)
{
nsresult rv = NS_OK;
*urlLiteral = nullptr;
nsCOMPtr<nsIFile> f;
NS_GetFileFromURLSpec(NS_ConvertUTF16toUTF8(aFileURL), getter_AddRefs(f));
bool value;
if (NS_SUCCEEDED(f->IsDirectory(&value)) && value)
{
if (isValidFolder(source))
return(NS_RDF_NO_VALUE);
aFileURL.AppendLiteral("desktop.ini");
}
else if (aFileURL.Length() > 4)
{
nsAutoString extension;
aFileURL.Right(extension, 4);
if (!extension.LowerCaseEqualsLiteral(".url"))
{
return(NS_RDF_NO_VALUE);
}
}
nsCOMPtr<nsIInputStream> strm;
NS_NewLocalFileInputStream(getter_AddRefs(strm),f);
nsCOMPtr<nsILineInputStream> linereader = do_QueryInterface(strm, &rv);
nsAutoString line;
nsAutoCString cLine;
while(NS_SUCCEEDED(rv))
{
bool isEOF;
rv = linereader->ReadLine(cLine, &isEOF);
CopyASCIItoUTF16(cLine, line);
if (isEOF)
{
if (line.Find("URL=", true) == 0)
{
line.Cut(0, 4);
rv = mRDFService->GetLiteral(line.get(), urlLiteral);
break;
}
else if (line.Find("CDFURL=", true) == 0)
{
line.Cut(0, 7);
rv = mRDFService->GetLiteral(line.get(), urlLiteral);
break;
}
line.Truncate();
}
}
return(rv);
}