本文整理汇总了C++中nsAString::EndReading方法的典型用法代码示例。如果您正苦于以下问题:C++ nsAString::EndReading方法的具体用法?C++ nsAString::EndReading怎么用?C++ nsAString::EndReading使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsAString
的用法示例。
在下文中一共展示了nsAString::EndReading方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AppendNonAsciiToNCR
static void AppendNonAsciiToNCR(const nsAString& in, nsCString& out)
{
nsAString::const_iterator start, end;
in.BeginReading(start);
in.EndReading(end);
while (start != end) {
if (*start < 128) {
out.Append(*start++);
} else {
out.AppendLiteral("&#x");
out.AppendInt(*start++, 16);
out.Append(';');
}
}
}
示例2: tokenStart
/* static */
bool
MatchAutoCompleteFunction::findOnBoundary(const nsDependentSubstring &aToken,
const nsAString &aSourceString)
{
// We cannot match anything if there is nothing to search.
if (aSourceString.IsEmpty())
return false;
// Define a const instance of this class so it is created once.
const nsCaseInsensitiveStringComparator caseInsensitiveCompare;
const_wchar_iterator tokenStart(aToken.BeginReading()),
tokenEnd(aToken.EndReading()),
sourceStart(aSourceString.BeginReading()),
sourceEnd(aSourceString.EndReading());
// The start of aSourceString is considered a word boundary, so start there.
do {
// We are on a word boundary, so start by copying the iterators.
const_wchar_iterator testTokenItr(tokenStart),
testSourceItr(sourceStart);
// Keep trying to match the token one by one until it doesn't match.
while (!caseInsensitiveCompare(*testTokenItr, *testSourceItr)) {
// We matched something, so move down one.
testTokenItr++;
testSourceItr++;
// Matched the full token, so we are done!
if (testTokenItr == tokenEnd)
return true;
// However, if we ran into the end of the source while matching the
// token, we will not find it.
if (testSourceItr == sourceEnd)
return false;
}
// Always advance our starting iterator, and if we are not currently on a
// word boundary, advance to the next word boundary.
if (!isWordBoundary(ToLowerCase(*sourceStart++)))
sourceStart = nextWordBoundary(sourceStart, sourceEnd);
} while (sourceStart != sourceEnd);
return false;
}
示例3: while
uint32_t
CountCharInReadable(const nsAString& aStr, char16_t aChar)
{
uint32_t count = 0;
nsAString::const_iterator begin, end;
aStr.BeginReading(begin);
aStr.EndReading(end);
while (begin != end) {
if (*begin == aChar) {
++count;
}
++begin;
}
return count;
}
示例4: iter
void
Link::SetProtocol(const nsAString &aProtocol, ErrorResult& aError)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
// Ignore failures to be compatible with NS4.
return;
}
nsAString::const_iterator start, end;
aProtocol.BeginReading(start);
aProtocol.EndReading(end);
nsAString::const_iterator iter(start);
(void)FindCharInReadable(':', iter, end);
(void)uri->SetScheme(NS_ConvertUTF16toUTF8(Substring(start, iter)));
SetHrefAttribute(uri);
}
示例5: versionStr
static bool
ParseKeySystem(const nsAString& aExpectedKeySystem,
const nsAString& aInputKeySystem,
int32_t& aOutCDMVersion)
{
if (!StringBeginsWith(aInputKeySystem, aExpectedKeySystem)) {
return false;
}
if (aInputKeySystem.Length() > aExpectedKeySystem.Length() + 8) {
// Allow up to 8 bytes for the ".version" field. 8 bytes should
// be enough for any versioning scheme...
NS_WARNING("Input KeySystem including was suspiciously long");
return false;
}
const char16_t* versionStart = aInputKeySystem.BeginReading() + aExpectedKeySystem.Length();
const char16_t* end = aInputKeySystem.EndReading();
if (versionStart == end) {
// No version supplied with keysystem.
aOutCDMVersion = NO_CDM_VERSION;
return true;
}
if (*versionStart != '.') {
// version not in correct format.
NS_WARNING("EME keySystem version string not prefixed by '.'");
return false;
}
versionStart++;
const nsAutoString versionStr(Substring(versionStart, end));
if (!ContainsOnlyDigits(versionStr)) {
NS_WARNING("Non-digit character in EME keySystem string's version suffix");
return false;
}
nsresult rv;
int32_t version = versionStr.ToInteger(&rv);
if (NS_FAILED(rv) || version < 0) {
NS_WARNING("Invalid version in EME keySystem string");
return false;
}
aOutCDMVersion = version;
return true;
}
示例6: while
nsresult
nsInternetCiter::StripCitesAndLinebreaks(const nsAString& aInString,
nsAString& aOutString,
bool aLinebreaksToo,
int32_t* aCiteLevel)
{
if (aCiteLevel)
*aCiteLevel = 0;
aOutString.Truncate();
nsReadingIterator <char16_t> beginIter,endIter;
aInString.BeginReading(beginIter);
aInString.EndReading(endIter);
while (beginIter!= endIter) // loop over lines
{
// Clear out cites first, at the beginning of the line:
int32_t thisLineCiteLevel = 0;
while (beginIter!= endIter && (*beginIter == gt || nsCRT::IsAsciiSpace(*beginIter)))
{
if (*beginIter == gt) ++thisLineCiteLevel;
++beginIter;
}
// Now copy characters until line end:
while (beginIter != endIter && (*beginIter != '\r' && *beginIter != '\n'))
{
aOutString.Append(*beginIter);
++beginIter;
}
if (aLinebreaksToo)
aOutString.Append(char16_t(' '));
else
aOutString.Append(char16_t('\n')); // DOM linebreaks, not NS_LINEBREAK
// Skip over any more consecutive linebreak-like characters:
while (beginIter != endIter && (*beginIter == '\r' || *beginIter == '\n'))
++beginIter;
// Done with this line -- update cite level
if (aCiteLevel && (thisLineCiteLevel > *aCiteLevel))
*aCiteLevel = thisLineCiteLevel;
}
return NS_OK;
}
示例7: while
nsresult
nsDOMTokenList::CheckToken(const nsAString& aStr)
{
if (aStr.IsEmpty()) {
return NS_ERROR_DOM_SYNTAX_ERR;
}
nsAString::const_iterator iter, end;
aStr.BeginReading(iter);
aStr.EndReading(end);
while (iter != end) {
if (nsContentUtils::IsHTMLWhitespace(*iter))
return NS_ERROR_DOM_INVALID_CHARACTER_ERR;
++iter;
}
return NS_OK;
}
示例8: PossiblyByteExpandedFileName
bool nsDefaultURIFixup::PossiblyByteExpandedFileName(const nsAString& aIn)
{
// XXXXX HACK XXXXX : please don't copy this code.
// There are cases where aIn contains the locale byte chars padded to short
// (thus the name "ByteExpanded"); whereas other cases
// have proper Unicode code points.
// This is a temporary fix. Please refer to 58866, 86948
nsReadingIterator<char16_t> iter;
nsReadingIterator<char16_t> iterEnd;
aIn.BeginReading(iter);
aIn.EndReading(iterEnd);
while (iter != iterEnd)
{
if (*iter >= 0x0080 && *iter <= 0x00FF)
return true;
++iter;
}
return false;
}
示例9: iter
nsresult
nsNodeInfoManager::GetNodeInfo(const nsAString& aQualifiedName,
const nsAString& aNamespaceURI,
nsINodeInfo** aNodeInfo)
{
NS_ENSURE_ARG(!aQualifiedName.IsEmpty());
nsAString::const_iterator start, end;
aQualifiedName.BeginReading(start);
aQualifiedName.EndReading(end);
nsCOMPtr<nsIAtom> prefixAtom;
nsAString::const_iterator iter(start);
if (FindCharInReadable(':', iter, end)) {
prefixAtom = do_GetAtom(Substring(start, iter));
NS_ENSURE_TRUE(prefixAtom, NS_ERROR_OUT_OF_MEMORY);
start = ++iter; // step over the ':'
if (iter == end) {
// No data after the ':'.
return NS_ERROR_INVALID_ARG;
}
}
nsCOMPtr<nsIAtom> nameAtom = do_GetAtom(Substring(start, end));
NS_ENSURE_TRUE(nameAtom, NS_ERROR_OUT_OF_MEMORY);
PRInt32 nsid = kNameSpaceID_None;
if (!aNamespaceURI.IsEmpty()) {
nsresult rv = nsContentUtils::NameSpaceManager()->
RegisterNameSpace(aNamespaceURI, nsid);
NS_ENSURE_SUCCESS(rv, rv);
}
return GetNodeInfo(nameAtom, prefixAtom, nsid, aNodeInfo);
}
示例10: normalizeFullStops
void nsIDNService::normalizeFullStops(nsAString& s)
{
nsAString::const_iterator start, end;
s.BeginReading(start);
s.EndReading(end);
int32_t index = 0;
while (start != end) {
switch (*start) {
case 0x3002:
case 0xFF0E:
case 0xFF61:
s.Replace(index, 1, NS_LITERAL_STRING("."));
break;
default:
break;
}
start++;
index++;
}
}
示例11: while
nsresult
nsTreeUtils::TokenizeProperties(const nsAString& aProperties, nsISupportsArray* aPropertiesArray)
{
NS_PRECONDITION(aPropertiesArray != nullptr, "null ptr");
if (! aPropertiesArray)
return NS_ERROR_NULL_POINTER;
nsAString::const_iterator end;
aProperties.EndReading(end);
nsAString::const_iterator iter;
aProperties.BeginReading(iter);
do {
// Skip whitespace
while (iter != end && nsCRT::IsAsciiSpace(*iter))
++iter;
// If only whitespace, we're done
if (iter == end)
break;
// Note the first non-whitespace character
nsAString::const_iterator first = iter;
// Advance to the next whitespace character
while (iter != end && ! nsCRT::IsAsciiSpace(*iter))
++iter;
// XXX this would be nonsensical
NS_ASSERTION(iter != first, "eh? something's wrong here");
if (iter == first)
break;
nsCOMPtr<nsIAtom> atom = do_GetAtom(Substring(first, iter));
aPropertiesArray->AppendElement(atom);
} while (iter != end);
return NS_OK;
}
示例12: if
void
Key::EncodeString(const nsAString& aString, PRUint8 aTypeOffset)
{
// First measure how long the encoded string will be.
// The +2 is for initial 3 and trailing 0. We'll compensate for multi-byte
// chars below.
PRUint32 size = aString.Length() + 2;
const PRUnichar* start = aString.BeginReading();
const PRUnichar* end = aString.EndReading();
for (const PRUnichar* iter = start; iter < end; ++iter) {
if (*iter > ONE_BYTE_LIMIT) {
size += *iter > TWO_BYTE_LIMIT ? 2 : 1;
}
}
// Allocate memory for the new size
PRUint32 oldLen = mBuffer.Length();
char* buffer;
if (!mBuffer.GetMutableData(&buffer, oldLen + size)) {
return;
}
buffer += oldLen;
// Write type marker
*(buffer++) = eString + aTypeOffset;
// Encode string
for (const PRUnichar* iter = start; iter < end; ++iter) {
if (*iter <= ONE_BYTE_LIMIT) {
*(buffer++) = *iter + ONE_BYTE_ADJUST;
}
else if (*iter <= TWO_BYTE_LIMIT) {
PRUnichar c = PRUnichar(*iter) + TWO_BYTE_ADJUST + 0x8000;
*(buffer++) = (char)(c >> 8);
*(buffer++) = (char)(c & 0xFF);
}
else {
示例13: SkipBeginWsp
PRInt32
nsSMILParserUtils::CheckForNegativeNumber(const nsAString& aStr)
{
PRInt32 absValLocation = -1;
nsAString::const_iterator start, end;
aStr.BeginReading(start);
aStr.EndReading(end);
// Skip initial whitespace
SkipBeginWsp(start, end);
// Check for dash
if (start != end && *start == '-') {
++start;
// Check for numeric character
if (start != end && NS_IS_DIGIT(*start)) {
absValLocation = start.get() - start.start();
}
}
return absValLocation;
}
示例14: langPrefix
bool
nsSynthVoiceRegistry::FindVoiceByLang(const nsAString& aLang,
VoiceData** aRetval)
{
nsAString::const_iterator dashPos, start, end;
aLang.BeginReading(start);
aLang.EndReading(end);
while (true) {
nsAutoString langPrefix(Substring(start, end));
for (int32_t i = mDefaultVoices.Length(); i > 0; ) {
VoiceData* voice = mDefaultVoices[--i];
if (StringBeginsWith(voice->mLang, langPrefix)) {
*aRetval = voice;
return true;
}
}
for (int32_t i = mVoices.Length(); i > 0; ) {
VoiceData* voice = mVoices[--i];
if (StringBeginsWith(voice->mLang, langPrefix)) {
*aRetval = voice;
return true;
}
}
dashPos = end;
end = start;
if (!RFindInReadable(NS_LITERAL_STRING("-"), end, dashPos)) {
break;
}
}
return false;
}
示例15: iter
void
Link::SetHost(const nsAString &aHost)
{
nsCOMPtr<nsIURI> uri(GetURIToMutate());
if (!uri) {
// Ignore failures to be compatible with NS4.
return;
}
// We cannot simply call nsIURI::SetHost because that would treat the name as
// an IPv6 address (like http:://[server:443]/). We also cannot call
// nsIURI::SetHostPort because that isn't implemented. Sadfaces.
// First set the hostname.
nsAString::const_iterator start, end;
aHost.BeginReading(start);
aHost.EndReading(end);
nsAString::const_iterator iter(start);
(void)FindCharInReadable(':', iter, end);
NS_ConvertUTF16toUTF8 host(Substring(start, iter));
(void)uri->SetHost(host);
// Also set the port if needed.
if (iter != end) {
iter++;
if (iter != end) {
nsAutoString portStr(Substring(iter, end));
nsresult rv;
int32_t port = portStr.ToInteger(&rv);
if (NS_SUCCEEDED(rv)) {
(void)uri->SetPort(port);
}
}
};
SetHrefAttribute(uri);
return;
}