本文整理汇总了C++中nsAFlatString::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAFlatString::Length方法的具体用法?C++ nsAFlatString::Length怎么用?C++ nsAFlatString::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAFlatString
的用法示例。
在下文中一共展示了nsAFlatString::Length方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RFindSubstring
PRInt32
nsString::RFind( const nsAFlatString& aString, PRInt32 aOffset, PRInt32 aCount ) const
{
// this method changes the meaning of aOffset and aCount:
RFind_ComputeSearchRange(mLength, aString.Length(), aOffset, aCount);
PRInt32 result = RFindSubstring(mData + aOffset, aCount, aString.get(), aString.Length(), false);
if (result != kNotFound)
result += aOffset;
return result;
}
示例2: RFindSubstring
int32_t
nsString::RFind( const nsAFlatString& aString, int32_t aOffset, int32_t aCount ) const
{
// this method changes the meaning of aOffset and aCount:
RFind_ComputeSearchRange(mLength, aString.Length(), aOffset, aCount);
int32_t result = RFindSubstring(mData + aOffset, aCount, static_cast<const char16_t*>(aString.get()), aString.Length(), false);
if (result != kNotFound)
result += aOffset;
return result;
}
示例3: 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;
}
示例4: getDocumentBase
/**
* Returns the document base of the href argument
* @return the document base of the given href
**/
void URIUtils::getDocumentBase(const nsAFlatString& href, nsAString& dest)
{
if (href.IsEmpty()) {
return;
}
nsAFlatString::const_char_iterator temp;
href.BeginReading(temp);
PRUint32 iter = href.Length();
while (iter > 0) {
if (temp[--iter] == HREF_PATH_SEP) {
dest.Append(Substring(href, 0, iter));
break;
}
}
}
示例5: Substring
/**
* Implementation of utility functions for parsing URLs.
* Just file paths for now.
*/
void
txParsedURL::init(const nsAFlatString& aSpec)
{
mPath.Truncate();
mName.Truncate();
mRef.Truncate();
PRUint32 specLength = aSpec.Length();
if (!specLength) {
return;
}
const PRUnichar* start = aSpec.get();
const PRUnichar* end = start + specLength;
const PRUnichar* c = end - 1;
// check for #ref
for (; c >= start; --c) {
if (*c == '#') {
// we could eventually unescape this, too.
mRef = Substring(c + 1, end);
end = c;
--c;
if (c == start) {
// we're done,
return;
}
break;
}
}
for (c = end - 1; c >= start; --c) {
if (*c == '/') {
mName = Substring(c + 1, end);
mPath = Substring(start, c + 1);
return;
}
}
mName = Substring(start, end);
}