本文整理汇总了C++中nsacstring::const_iterator类的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator类的具体用法?C++ const_iterator怎么用?C++ const_iterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了const_iterator类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: end
// Reads over a boundary and sets start to the position after the end of the
// boundary. Returns false if no boundary is found immediately.
bool
PushOverBoundary(const nsACString& aBoundaryString,
nsACString::const_iterator& aStart,
nsACString::const_iterator& aEnd)
{
// We copy the end iterator to keep the original pointing to the real end
// of the string.
nsACString::const_iterator end(aEnd);
const char* beginning = aStart.get();
if (FindInReadable(aBoundaryString, aStart, end)) {
// We either should find the body immediately, or after 2 chars with the
// 2 chars being '-', everything else is failure.
if ((aStart.get() - beginning) == 0) {
aStart.advance(aBoundaryString.Length());
return true;
}
if ((aStart.get() - beginning) == 2) {
if (*(--aStart) == '-' && *(--aStart) == '-') {
aStart.advance(aBoundaryString.Length() + 2);
return true;
}
}
}
return false;
}
示例2: Substring
/**
* Reads one table of results from the response. Leaves begin pointing at the
* next table.
*/
nsresult
nsUrlClassifierHashCompleterRequest::HandleTable(nsACString::const_iterator& begin,
const nsACString::const_iterator& end)
{
nsACString::const_iterator iter;
iter = begin;
if (!FindCharInReadable(':', iter, end)) {
// No table line.
NS_WARNING("Received badly-formatted gethash response.");
return NS_ERROR_FAILURE;
}
const nsCSubstring& tableName = Substring(begin, iter);
iter++;
begin = iter;
if (!FindCharInReadable('\n', iter, end)) {
// Unterminated header line.
NS_WARNING("Received badly-formatted gethash response.");
return NS_ERROR_FAILURE;
}
const nsCSubstring& remaining = Substring(begin, iter);
iter++;
begin = iter;
PRUint32 chunkId;
PRInt32 size;
if (PR_sscanf(PromiseFlatCString(remaining).get(),
"%u:%d", &chunkId, &size) != 2) {
NS_WARNING("Received badly-formatted gethash response.");
return NS_ERROR_FAILURE;
}
if (size % COMPLETE_LENGTH != 0) {
NS_WARNING("Unexpected gethash response length");
return NS_ERROR_FAILURE;
}
// begin now refers to the hash data.
if (begin.size_forward() < size) {
NS_WARNING("Response does not match the expected response length.");
return NS_ERROR_FAILURE;
}
for (PRInt32 i = 0; i < (size / COMPLETE_LENGTH); i++) {
// Read the complete hash.
iter.advance(COMPLETE_LENGTH);
nsresult rv = HandleItem(Substring(begin, iter), tableName, chunkId);
NS_ENSURE_SUCCESS(rv, rv);
begin = iter;
}
// begin now points at the end of the hash data.
return NS_OK;
}
示例3: end
// static
bool
FetchUtil::ExtractHeader(nsACString::const_iterator& aStart,
nsACString::const_iterator& aEnd,
nsCString& aHeaderName,
nsCString& aHeaderValue,
bool* aWasEmptyHeader)
{
MOZ_ASSERT(aWasEmptyHeader);
// Set it to a valid value here so we don't forget later.
*aWasEmptyHeader = false;
const char* beginning = aStart.get();
nsACString::const_iterator end(aEnd);
if (!FindCRLF(aStart, end)) {
return false;
}
if (aStart.get() == beginning) {
*aWasEmptyHeader = true;
return true;
}
nsAutoCString header(beginning, aStart.get() - beginning);
nsACString::const_iterator headerStart, iter, headerEnd;
header.BeginReading(headerStart);
header.EndReading(headerEnd);
iter = headerStart;
if (!FindCharInReadable(':', iter, headerEnd)) {
return false;
}
aHeaderName.Assign(StringHead(header, iter - headerStart));
aHeaderName.CompressWhitespace();
if (!NS_IsValidHTTPToken(aHeaderName)) {
return false;
}
aHeaderValue.Assign(Substring(++iter, headerEnd));
if (!NS_IsReasonableHTTPHeaderValue(aHeaderValue)) {
return false;
}
aHeaderValue.CompressWhitespace();
return PushOverLine(aStart, aEnd);
}
示例4: PushOverLine
// Reads over a CRLF and positions start after it.
bool
PushOverLine(nsACString::const_iterator& aStart)
{
if (*aStart == nsCRT::CR && (aStart.size_forward() > 1) && *(++aStart) == nsCRT::LF) {
++aStart; // advance to after CRLF
return true;
}
return false;
}
示例5: spec
inline PRBool
nsSMILParserUtils::ParseMetricMultiplicand(nsACString::const_iterator& aSpec,
const nsACString::const_iterator& aEnd,
PRInt32& multiplicand)
{
PRBool result = PR_FALSE;
size_t len = aEnd.get() - aSpec.get();
nsACString::const_iterator spec(aSpec);
if (len) {
switch (*spec++)
{
case 'h':
multiplicand = MSEC_PER_HOUR;
result = PR_TRUE;
break;
case 'm':
if (len >= 2) {
if (*spec == 's') {
++spec;
multiplicand = 1;
result = PR_TRUE;
} else if (len >= 3 && *spec++ == 'i' && *spec++ == 'n') {
multiplicand = MSEC_PER_MIN;
result = PR_TRUE;
}
}
break;
case 's':
multiplicand = MSEC_PER_SEC;
result = PR_TRUE;
break;
}
}
if (result) {
aSpec = spec;
}
return result;
}
示例6:
inline PRBool
nsSMILParserUtils::ConsumeSubstring(nsACString::const_iterator& aIter,
const nsACString::const_iterator& aIterEnd,
const char *aSubstring)
{
size_t substrLen = PL_strlen(aSubstring);
typedef nsACString::const_iterator::difference_type diff_type;
if (aIterEnd.get() - aIter.get() < static_cast<diff_type>(substrLen))
return PR_FALSE;
PRBool result = PR_FALSE;
if (PL_strstr(aIter.get(), aSubstring) == aIter.get()) {
aIter.advance(substrLen);
result = PR_TRUE;
}
return result;
}
示例7: GetFloat
PRBool
nsSMILParserUtils::ParseClockComponent(nsACString::const_iterator& aSpec,
const nsACString::const_iterator& aEnd,
double& aResult,
PRBool& aIsReal,
PRBool& aCouldBeMin,
PRBool& aCouldBeSec)
{
nsresult rv;
char const *begin = aSpec.get();
double value = GetFloat(aSpec, aEnd, &rv);
// Check a number was found
if (NS_FAILED(rv))
return PR_FALSE;
// Check it's not expressed in exponential form
size_t len = aSpec.get() - begin;
PRBool isExp = (PL_strnpbrk(begin, "eE", len) != nsnull);
if (isExp)
return PR_FALSE;
// Don't allow real numbers of the form "23."
if (*(aSpec.get() - 1) == '.')
return PR_FALSE;
// Number looks good
aResult = value;
// Set some flags so we can check this number is valid once we know
// whether it's an hour, minute string etc.
aIsReal = (PL_strnchr(begin, '.', len) != nsnull);
aCouldBeMin = (value < 60.0 && (len == 2));
aCouldBeSec = (value < 60.0 ||
(value == 60.0 && begin[0] == '5')); // Take care of rounding error
aCouldBeSec &= (len >= 2 &&
(begin[2] == '\0' || begin[2] == '.' || IsSpace(begin[2])));
return PR_TRUE;
}