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


C++ nsACString::Insert方法代码示例

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


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

示例1: if

void
FileLocation::GetURIString(nsACString &result) const
{
  if (mBaseFile) {
    net_GetURLSpecFromActualFile(mBaseFile, result);
  } else if (mBaseZip) {
    nsRefPtr<nsZipHandle> handler = mBaseZip->GetFD();
    handler->mFile.GetURIString(result);
  }
  if (IsZip()) {
    result.Insert("jar:", 0);
    result += "!/";
    result += mPath;
  }
}
开发者ID:Type-of-Tool,项目名称:ExMail,代码行数:15,代码来源:FileLocation.cpp

示例2: LOG

/* static */
nsresult
sbURIChecker::CheckDomain( nsACString &aDomain, nsIURI *aSiteURI )
{
  NS_ENSURE_ARG_POINTER(aSiteURI);
  LOG(( "sbURIChecker::CheckDomain(%s)", aDomain.BeginReading() ));

  // get host from URI
  nsCString host;
  nsresult rv = aSiteURI->GetHost(host);
  NS_ENSURE_SUCCESS( rv, rv );

  nsCString fixedHost;
  rv = sbURIChecker::FixupDomain( host, fixedHost );
  NS_ENSURE_SUCCESS( rv, rv );

  host.Assign(fixedHost);

  if ( !aDomain.IsEmpty() ) {
    LOG(("sbURIChecker::CheckDomain() -- Have a domain from the user"));
    // remove trailing dots, lowercase it
    nsCString fixedDomain;
    rv = sbURIChecker::FixupDomain( aDomain, fixedDomain );
    NS_ENSURE_SUCCESS( rv, rv );

    aDomain.Assign(fixedDomain);

    // Deal first with numerical ip addresses
    PRNetAddr addr;
    if ( PR_StringToNetAddr( host.get(), &addr ) == PR_SUCCESS ) {
      // numerical ip address
      LOG(("sbURIChecker::CheckDomain() -- Numerical Address "));
      if ( !aDomain.Equals(host) ) {
        LOG(("sbURIChecker::CheckDomain() -- FAILED ip address check"));
        return NS_ERROR_FAILURE;
      }
    } else {
      // domain based host, check it against host from URI
      LOG(("sbURIChecker::CheckDomain() -- Domain based host "));

      // make sure the domain wasn't '.com' - it should have a dot in it
      // we need to skip this check if the host is localhost
      PRInt32 dot = aDomain.FindChar('.');
      if ( dot < 0 && !host.Equals("localhost")) {
        LOG(("sbURIChecker::CheckDomain() -- FAILED dot test "));
        return NS_ERROR_FAILURE;
      }

      // prepend a dot so bar.com doesn't match foobar.com but does foo.bar.com
      aDomain.Insert( NS_LITERAL_CSTRING("."), 0 );

      PRInt32 domainLength = aDomain.Length();
      PRInt32 lengthDiff = host.Length() - domainLength;
      if ( lengthDiff == -1 ) {
        LOG(("sbURIChecker::CheckDomain() -- long domain check"));
        // special case:  from user: .bar.com   vs. from URI:  bar.com
        // XXXredfive - I actually think we'll see this most often because
        //             of the prepending of the dot to the user supplied domain
        if ( !StringEndsWith(aDomain, host) ) {
          LOG(("sbURIChecker::CheckDomain() -- FAILED long domain check"));
          return NS_ERROR_FAILURE;
        }
      } else if ( lengthDiff == 0 ) {
        LOG(("sbURIChecker::CheckDomain() -- same length check"));
        // same length better be the same strings
        if ( !aDomain.Equals(host) ) {
          LOG(("sbURIChecker::CheckDomain() -- FAILED same length check"));
          return NS_ERROR_FAILURE;
        }
      } else if ( lengthDiff > 0 ) {
        LOG(("sbURIChecker::CheckDomain() -- parent domain check"));
        // normal case URI host is longer that host from user
        //   from user: .bar.com   from URI:  foo.bar.com
        if ( !StringEndsWith(host, aDomain) ) {
          LOG(("sbURIChecker::CheckDomain() -- FAILED parent domain check"));
          return NS_ERROR_FAILURE;
        }
      } else {
        // domains are WAY off, the user domain is more than 1 char longer than
        // the URI domain. ie: user: jgaunt.com URI: ""
        LOG(("sbURIChecker::CheckDomain() -- FAILED, user domain is superset"));
        return NS_ERROR_FAILURE;
      }

      // remove the leading dot we added
      aDomain.Cut( 0, 1 );
    }
  } else {
    LOG(( "sbURIChecker::CheckDomain() -- NO domain from the user"));
    // If the user didn't specify a host
    // if the URI host is empty, make sure we're file://
    if ( host.IsEmpty() ) {
      PRBool isFileURI;
      rv = aSiteURI->SchemeIs( "file", &isFileURI );
      NS_ENSURE_SUCCESS( rv, rv );

      if (!isFileURI) {
        // non-file URI without a host!!!
        LOG(("sbURIChecker::CheckDomain() -- FAILED file scheme check"));
        return NS_ERROR_FAILURE;
//.........这里部分代码省略.........
开发者ID:AntoineTurmel,项目名称:nightingale-hacking,代码行数:101,代码来源:sbURIChecker.cpp


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