本文整理汇总了C++中nsSubstring::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ nsSubstring::Length方法的具体用法?C++ nsSubstring::Length怎么用?C++ nsSubstring::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsSubstring
的用法示例。
在下文中一共展示了nsSubstring::Length方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: txCharacterTransaction
nsresult
txBufferingHandler::characters(const nsSubstring& aData, PRBool aDOE)
{
NS_ENSURE_TRUE(mBuffer, NS_ERROR_OUT_OF_MEMORY);
mCanAddAttribute = PR_FALSE;
txOutputTransaction::txTransactionType type =
aDOE ? txOutputTransaction::eCharacterNoOETransaction
: txOutputTransaction::eCharacterTransaction;
txOutputTransaction* transaction = mBuffer->getLastTransaction();
if (transaction && transaction->mType == type) {
mBuffer->mStringValue.Append(aData);
static_cast<txCharacterTransaction*>(transaction)->mLength +=
aData.Length();
return NS_OK;
}
transaction = new txCharacterTransaction(type, aData.Length());
NS_ENSURE_TRUE(transaction, NS_ERROR_OUT_OF_MEMORY);
mBuffer->mStringValue.Append(aData);
return mBuffer->addTransaction(transaction);
}
示例2: Substring
/**
* Check for a modifier flag of the following form:
* "flag=string"
* "flag!=string"
* @param aFlag The flag to compare.
* @param aData The tokenized data to check; this is lowercased
* before being passed in.
* @param aValue The value that is expected.
* @param aResult If this is "ok" when passed in, this is left alone.
* Otherwise if the flag is found it is set to eBad or eOK.
* @return Whether the flag was handled.
*/
static bool
CheckStringFlag(const nsSubstring& aFlag, const nsSubstring& aData,
const nsSubstring& aValue, TriState& aResult)
{
if (aData.Length() < aFlag.Length() + 1) {
return false;
}
if (!StringBeginsWith(aData, aFlag)) {
return false;
}
bool comparison = true;
if (aData[aFlag.Length()] != '=') {
if (aData[aFlag.Length()] == '!' &&
aData.Length() >= aFlag.Length() + 2 &&
aData[aFlag.Length() + 1] == '=') {
comparison = false;
} else {
return false;
}
}
if (aResult != eOK) {
nsDependentSubstring testdata =
Substring(aData, aFlag.Length() + (comparison ? 1 : 2));
if (testdata.Equals(aValue)) {
aResult = comparison ? eOK : eBad;
} else {
aResult = comparison ? eBad : eOK;
}
}
return true;
}
示例3:
void
mozInlineSpellWordUtil::NormalizeWord(nsSubstring& aWord)
{
nsAutoString result;
::NormalizeWord(aWord, 0, aWord.Length(), result);
aWord = result;
}
示例4: 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;
}