/** * Returns true if the given string has only whitespace characters */ bool XMLUtils::isWhitespace(const nsAFlatString& aText) { nsAFlatString::const_char_iterator start, end; aText.BeginReading(start); aText.EndReading(end); for ( ; start != end; ++start) { if (!isWhitespace(*start)) { return false; } } return true; }
/** * 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; } } }
void txStandaloneXSLTProcessor::parseStylesheetPI(const nsAFlatString& aData, nsAString& aType, nsAString& aHref) { nsAFlatString::const_char_iterator start, end; aData.BeginReading(start); aData.EndReading(end); nsAFlatString::const_char_iterator iter; PRInt8 found = 0; while (start != end) { SKIP_WHITESPACE(start, end); iter = start; SKIP_ATTR_NAME(iter, end); // Remember the attr name. const nsAString & attrName = Substring(start, iter); // Now check whether this is a valid name="value" pair. start = iter; SKIP_WHITESPACE(start, end); if (*start != '=') { // No '=', so this is not a name="value" pair. We don't know // what it is, and we have no way to handle it. break; } // Have to skip the value. ++start; SKIP_WHITESPACE(start, end); PRUnichar q = *start; if (q != QUOTE && q != APOSTROPHE) { // Not a valid quoted value, so bail. break; } ++start; // Point to the first char of the value. iter = start; while (iter != end && *iter != q) { ++iter; } if (iter == end) { // Oops, unterminated quoted string. break; } // At this point attrName holds the name of the "attribute" and // the value is between start and iter. if (attrName.EqualsLiteral("type")) { aType = Substring(start, iter); ++found; } else if (attrName.EqualsLiteral("href")) { aHref = Substring(start, iter); ++found; } // Stop if we found both attributes if (found == 2) { break; } // Resume scanning after the end of the attribute value. start = iter; ++start; // To move past the quote char. } }