本文整理汇总了C++中nsSubstring::CharAt方法的典型用法代码示例。如果您正苦于以下问题:C++ nsSubstring::CharAt方法的具体用法?C++ nsSubstring::CharAt怎么用?C++ nsSubstring::CharAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsSubstring
的用法示例。
在下文中一共展示了nsSubstring::CharAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
/**
* Check for a modifier flag of the following forms:
* "flag" (same as "true")
* "flag=yes|true|1"
* "flag="no|false|0"
* @param aFlag The flag to compare.
* @param aData The tokenized data to check; this is lowercased
* before being passed in.
* @param aResult If the flag is found, the value is assigned here.
* @return Whether the flag was handled.
*/
static bool
CheckFlag(const nsSubstring& aFlag, const nsSubstring& aData, bool& aResult)
{
if (!StringBeginsWith(aData, aFlag)) {
return false;
}
if (aFlag.Length() == aData.Length()) {
// the data is simply "flag", which is the same as "flag=yes"
aResult = true;
return true;
}
if (aData.CharAt(aFlag.Length()) != '=') {
// the data is "flag2=", which is not anything we care about
return false;
}
if (aData.Length() == aFlag.Length() + 1) {
aResult = false;
return true;
}
switch (aData.CharAt(aFlag.Length() + 1)) {
case '1':
case 't': //true
case 'y': //yes
aResult = true;
return true;
case '0':
case 'f': //false
case 'n': //no
aResult = false;
return true;
}
return false;
}
示例2:
// This is to fix characters that the spellchecker may not like
static void
NormalizeWord(const nsSubstring& aInput, int32_t aPos, int32_t aLen, nsAString& aOutput)
{
aOutput.Truncate();
for (int32_t i = 0; i < aLen; i++) {
PRUnichar ch = aInput.CharAt(i + aPos);
// remove ignorable characters from the word
if (IsIgnorableCharacter(ch))
continue;
// the spellchecker doesn't handle curly apostrophes in all languages
if (ch == 0x2019) { // RIGHT SINGLE QUOTATION MARK
ch = '\'';
}
aOutput.Append(ch);
}
}