当前位置: 首页>>代码示例>>C++>>正文


C++ nsCString::Last方法代码示例

本文整理汇总了C++中nsCString::Last方法的典型用法代码示例。如果您正苦于以下问题:C++ nsCString::Last方法的具体用法?C++ nsCString::Last怎么用?C++ nsCString::Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nsCString的用法示例。


在下文中一共展示了nsCString::Last方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: temp

int32_t
nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
{
  NS_ASSERTION(gEntityToUnicode, "no lookup table, needs addref");
  if (!gEntityToUnicode) {
    return -1;
  }

  //this little piece of code exists because entities may or may not have the terminating ';'.
  //if we see it, strip if off for this test...

  if(';'==aEntity.Last()) {
    nsAutoCString temp(aEntity);
    temp.Truncate(aEntity.Length()-1);
    return EntityToUnicode(temp);
  }

  auto entry =
    static_cast<EntityNodeEntry*>(gEntityToUnicode->Search(aEntity.get()));

  return entry ? entry->node->mUnicode : -1;
}
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:22,代码来源:nsHTMLEntities.cpp

示例2: while

nsresult
nsMorkReader::ReadLine(nsCString &aLine)
{
    PRBool res;
    nsresult rv = mStream->ReadLine(aLine, &res);
    NS_ENSURE_SUCCESS(rv, rv);
    if (!res) {
        return NS_ERROR_NOT_AVAILABLE;
    }

    while (!aLine.IsEmpty() &&  aLine.Last() == '\\') {
        // There is a continuation for this line.  Read it and append.
        nsCLineString line2;
        rv = mStream->ReadLine(line2, &res);
        NS_ENSURE_SUCCESS(rv, rv);
        if (!res) {
            return NS_ERROR_NOT_AVAILABLE;
        }
        aLine.Truncate(aLine.Length() - 1);
        aLine.Append(line2);
    }

    return NS_OK;
}
开发者ID:rhencke,项目名称:mozilla-cvs-history,代码行数:24,代码来源:nsMorkReader.cpp

示例3: strchr

// Finds the base domain for a host, with requested number of additional parts.
// This will fail, generating an error, if the host is an IPv4/IPv6 address,
// if more subdomain parts are requested than are available, or if the hostname
// includes characters that are not valid in a URL. Normalization is performed
// on the host string and the result will be in UTF8.
nsresult
nsEffectiveTLDService::GetBaseDomainInternal(nsCString  &aHostname,
                                             int32_t    aAdditionalParts,
                                             nsACString &aBaseDomain)
{
  if (aHostname.IsEmpty())
    return NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS;

  // chomp any trailing dot, and keep track of it for later
  bool trailingDot = aHostname.Last() == '.';
  if (trailingDot)
    aHostname.Truncate(aHostname.Length() - 1);

  // check the edge cases of the host being '.' or having a second trailing '.',
  // since subsequent checks won't catch it.
  if (aHostname.IsEmpty() || aHostname.Last() == '.')
    return NS_ERROR_INVALID_ARG;

  // Check if we're dealing with an IPv4/IPv6 hostname, and return
  PRNetAddr addr;
  PRStatus result = PR_StringToNetAddr(aHostname.get(), &addr);
  if (result == PR_SUCCESS)
    return NS_ERROR_HOST_IS_IP_ADDRESS;

  // Walk up the domain tree, most specific to least specific,
  // looking for matches at each level.  Note that a given level may
  // have multiple attributes (e.g. IsWild() and IsNormal()).
  const char *prevDomain = nullptr;
  const char *currDomain = aHostname.get();
  const char *nextDot = strchr(currDomain, '.');
  const char *end = currDomain + aHostname.Length();
  // Default value of *eTLD is currDomain as set in the while loop below
  const char *eTLD = nullptr;
  while (1) {
    // sanity check the string we're about to look up: it should not begin with
    // a '.'; this would mean the hostname began with a '.' or had an
    // embedded '..' sequence.
    if (*currDomain == '.')
      return NS_ERROR_INVALID_ARG;

    // Perform the lookup.
    const ETLDEntry* entry = ETLDEntry::GetEntry(currDomain);
    if (entry) {
      if (entry->IsWild() && prevDomain) {
        // wildcard rules imply an eTLD one level inferior to the match.
        eTLD = prevDomain;
        break;

      } else if (entry->IsNormal() || !nextDot) {
        // specific match, or we've hit the top domain level
        eTLD = currDomain;
        break;

      } else if (entry->IsException()) {
        // exception rules imply an eTLD one level superior to the match.
        eTLD = nextDot + 1;
        break;
      }
    }

    if (!nextDot) {
      // we've hit the top domain level; use it by default.
      eTLD = currDomain;
      break;
    }

    prevDomain = currDomain;
    currDomain = nextDot + 1;
    nextDot = strchr(currDomain, '.');
  }

  const char *begin, *iter;
  if (aAdditionalParts < 0) {
    NS_ASSERTION(aAdditionalParts == -1,
                 "aAdditionalParts can't be negative and different from -1");

    for (iter = aHostname.get(); iter != eTLD && *iter != '.'; iter++);

    if (iter != eTLD) {
      iter++;
    }
    if (iter != eTLD) {
      aAdditionalParts = 0;
    }
  } else {
    // count off the number of requested domains.
    begin = aHostname.get();
    iter = eTLD;

    while (1) {
      if (iter == begin)
        break;

      if (*(--iter) == '.' && aAdditionalParts-- == 0) {
        ++iter;
//.........这里部分代码省略.........
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:101,代码来源:nsEffectiveTLDService.cpp


注:本文中的nsCString::Last方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。