当前位置: 首页>>代码示例>>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;未经允许,请勿转载。