nsStringKey::nsStringKey(const nsAFlatString& str) : mStr((char16_t*)str.get()), mStrLen(str.Length()), mOwnership(OWN_CLONE) { NS_ASSERTION(mStr, "null string key"); #ifdef DEBUG mKeyType = StringKey; #endif MOZ_COUNT_CTOR(nsStringKey); }
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; }
/** * 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); }
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; }