當前位置: 首頁>>代碼示例>>C++>>正文


C++ BeginReading函數代碼示例

本文整理匯總了C++中BeginReading函數的典型用法代碼示例。如果您正苦於以下問題:C++ BeginReading函數的具體用法?C++ BeginReading怎麽用?C++ BeginReading使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BeginReading函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: bool

int32_t
nsAString::Find(const char *aStr, uint32_t aOffset, bool aIgnoreCase) const
{
  bool (*match)(const PRUnichar*, const char*, uint32_t) =
    aIgnoreCase ? ns_strnimatch : ns_strnmatch;

  const char_type *begin, *end;
  uint32_t selflen = BeginReading(&begin, &end);

  if (aOffset > selflen)
    return -1;

  uint32_t otherlen = strlen(aStr);

  if (otherlen > selflen - aOffset)
    return -1;

  // We want to stop searching otherlen characters before the end of the string
  end -= otherlen;

  for (const char_type *cur = begin + aOffset; cur <= end; ++cur) {
    if (match(cur, aStr, otherlen)) {
      return cur - begin;
    }
  }
  return -1;
}
開發者ID:mikeaich,項目名稱:releases-mozilla-central,代碼行數:27,代碼來源:nsStringAPI.cpp

示例2: BeginReading

int32_t
nsACString::Find(const self_type& aStr, uint32_t aOffset,
                 ComparatorFunc c) const
{
  const char_type *begin, *end;
  uint32_t selflen = BeginReading(&begin, &end);

  if (aOffset > selflen)
    return -1;

  const char_type *other;
  uint32_t otherlen = aStr.BeginReading(&other);

  if (otherlen > selflen - aOffset)
    return -1;

  // We want to stop searching otherlen characters before the end of the string
  end -= otherlen;

  for (const char_type *cur = begin + aOffset; cur <= end; ++cur) {
    if (!c(cur, other, otherlen))
      return cur - begin;
  }
  return -1;
}
開發者ID:mikeaich,項目名稱:releases-mozilla-central,代碼行數:25,代碼來源:nsStringAPI.cpp

示例3: BeginReading

int32_t
nsACString::RFind(const char_type* aStr, int32_t aLen,
                  ComparatorFunc aComparator) const
{
  const char_type* begin;
  const char_type* end;
  uint32_t selflen = BeginReading(&begin, &end);

  if (aLen <= 0) {
    NS_WARNING("Searching for zero-length string.");
    return -1;
  }

  if (uint32_t(aLen) > selflen) {
    return -1;
  }

  // We want to start searching otherlen characters before the end of the string
  end -= aLen;

  for (const char_type* cur = end; cur >= begin; --cur) {
    if (!aComparator(cur, aStr, aLen)) {
      return cur - begin;
    }
  }
  return -1;
}
開發者ID:Andrel322,項目名稱:gecko-dev,代碼行數:27,代碼來源:nsStringAPI.cpp

示例4: PRBool

PRInt32
nsAString::RFind(const char *aStr, PRInt32 aOffset, PRBool aIgnoreCase) const
{
  PRBool (*match)(const PRUnichar*, const char*, PRUint32) =
    aIgnoreCase ? ns_strnimatch : ns_strnmatch;

  const char_type *begin, *end;
  PRUint32 selflen = BeginReading(&begin, &end);
  PRUint32 otherlen = strlen(aStr);
  
  if (selflen < otherlen)
    return -1;

  if (aOffset < 0 || aOffset > (selflen - otherlen))
    end -= otherlen;
  else
    end = begin + aOffset;

  for (const char_type *cur = end; cur >= begin; --cur) {
    if (match(cur, aStr, otherlen)) {
      return cur - begin;
    }
  }
  return -1;
}
開發者ID:fortunto2,項目名稱:celtx,代碼行數:25,代碼來源:nsStringAPI.cpp

示例5: NS_ASSERTION

void
nsACString::Trim(const char* aSet, bool aLeading, bool aTrailing)
{
  NS_ASSERTION(aLeading || aTrailing, "Ineffective Trim");

  const char* start;
  const char* end;
  uint32_t cutLen;

  if (aLeading) {
    BeginReading(&start, &end);
    for (cutLen = 0; start < end; ++start, ++cutLen) {
      const char* test;
      for (test = aSet; *test; ++test) {
        if (*test == *start) {
          break;
        }
      }
      if (!*test) {
        break;
      }
    }
    if (cutLen) {
      NS_CStringCutData(*this, 0, cutLen);
    }
  }
  if (aTrailing) {
    uint32_t len = BeginReading(&start, &end);
    --end;
    for (cutLen = 0; end >= start; --end, ++cutLen) {
      const char* test;
      for (test = aSet; *test; ++test) {
        if (*test == *end) {
          break;
        }
      }
      if (!*test) {
        break;
      }
    }
    if (cutLen) {
      NS_CStringCutData(*this, len - cutLen, cutLen);
    }
  }
}
開發者ID:Andrel322,項目名稱:gecko-dev,代碼行數:45,代碼來源:nsStringAPI.cpp

示例6: BeginReading

PRBool
nsAString::EqualsLiteral(const char *aASCIIString) const
{
  const PRUnichar *begin, *end;
  BeginReading(&begin, &end);

  for (; begin < end; ++begin, ++aASCIIString) {
    if (!*aASCIIString || !NS_IsAscii(*begin) ||
        (char) *begin != *aASCIIString) {
      return PR_FALSE;
    }
  }

  return *aASCIIString == nsnull;
}
開發者ID:fortunto2,項目名稱:celtx,代碼行數:15,代碼來源:nsStringAPI.cpp

示例7: BeginReading

bool
nsAString::EqualsLiteral(const char *aASCIIString) const
{
  const char16_t *begin, *end;
  BeginReading(&begin, &end);

  for (; begin < end; ++begin, ++aASCIIString) {
    if (!*aASCIIString || !NS_IsAscii(*begin) ||
        (char) *begin != *aASCIIString) {
      return false;
    }
  }

  return *aASCIIString == '\0';
}
開發者ID:abhishekvp,項目名稱:gecko-dev,代碼行數:15,代碼來源:nsStringAPI.cpp

示例8: NS_CONST_CAST

const nsSubstring&
nsScannerSubstring::AsString() const
  {
    if (mIsDirty)
      {
        nsScannerSubstring* mutable_this = NS_CONST_CAST(nsScannerSubstring*, this);

        if (mStart.mBuffer == mEnd.mBuffer) {
          // We only have a single fragment to deal with, so just return it
          // as a substring.
          mutable_this->mFlattenedRep.Rebind(mStart.mPosition, mEnd.mPosition);
        } else {
          // Otherwise, we need to copy the data into a flattened buffer.
          nsScannerIterator start, end;
          CopyUnicodeTo(BeginReading(start), EndReading(end), mutable_this->mFlattenedRep);
        }

        mutable_this->mIsDirty = PR_FALSE;
      }

    return mFlattenedRep;
  }
開發者ID:BigManager,項目名稱:platform,代碼行數:22,代碼來源:nsScannerString.cpp

示例9: Length

PRInt32
nsScannerSubstring::CountChar( PRUnichar c ) const
  {
      /*
        re-write this to use a counting sink
       */

    size_type result = 0;
    size_type lengthToExamine = Length();

    nsScannerIterator iter;
    for ( BeginReading(iter); ; )
      {
        PRInt32 lengthToExamineInThisFragment = iter.size_forward();
        const PRUnichar* fromBegin = iter.get();
        result += size_type(NS_COUNT(fromBegin, fromBegin+lengthToExamineInThisFragment, c));
        if ( !(lengthToExamine -= lengthToExamineInThisFragment) )
          return result;
        iter.advance(lengthToExamineInThisFragment);
      }
      // never reached; quiets warnings
    return 0;
  }
開發者ID:BigManager,項目名稱:platform,代碼行數:23,代碼來源:nsScannerString.cpp

示例10: BeginReading

PRInt32 
nsACString::RFind(const char_type *aStr, PRInt32 aLen, ComparatorFunc c) const
{
  const char_type *begin, *end;
  PRUint32 selflen = BeginReading(&begin, &end);

  if (aLen <= 0) {
    NS_WARNING("Searching for zero-length string.");
    return -1;
  }

  if (PRUint32(aLen) > selflen)
    return -1;

  // We want to start searching otherlen characters before the end of the string
  end -= aLen;

  for (const char_type *cur = end; cur >= begin; --cur) {
    if (!c(cur, aStr, aLen))
      return cur - begin;
  }
  return -1;
}
開發者ID:lofter2011,項目名稱:Icefox,代碼行數:23,代碼來源:nsStringAPI.cpp


注:本文中的BeginReading函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。