本文整理汇总了C++中nsAFlatString::CharAt方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAFlatString::CharAt方法的具体用法?C++ nsAFlatString::CharAt怎么用?C++ nsAFlatString::CharAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAFlatString
的用法示例。
在下文中一共展示了nsAFlatString::CharAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
nsresult
txFormattedCounter::getCounterFor(const nsAFlatString& aToken,
PRInt32 aGroupSize,
const nsAString& aGroupSeparator,
txFormattedCounter*& aCounter)
{
PRInt32 length = aToken.Length();
NS_ASSERTION(length, "getting counter for empty token");
aCounter = 0;
if (length == 1) {
PRUnichar ch = aToken.CharAt(0);
switch (ch) {
case 'i':
case 'I':
aCounter = new txRomanCounter(ch == 'I');
break;
case 'a':
case 'A':
aCounter = new txAlphaCounter(ch);
break;
case '1':
default:
// if we don't recognize the token then use "1"
aCounter = new txDecimalCounter(1, aGroupSize,
aGroupSeparator);
break;
}
return aCounter ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
// for now, the only multi-char token we support are decimals
PRInt32 i;
for (i = 0; i < length-1; ++i) {
if (aToken.CharAt(i) != '0')
break;
}
if (i == length-1 && aToken.CharAt(i) == '1') {
aCounter = new txDecimalCounter(length, aGroupSize, aGroupSeparator);
}
else {
// if we don't recognize the token then use '1'
aCounter = new txDecimalCounter(1, aGroupSize, aGroupSeparator);
}
return aCounter ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}