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


C++ StringEndsWith函数代码示例

本文整理汇总了C++中StringEndsWith函数的典型用法代码示例。如果您正苦于以下问题:C++ StringEndsWith函数的具体用法?C++ StringEndsWith怎么用?C++ StringEndsWith使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: while

bool WMSettings::getOEacctFiles(nsILocalFile* file,
                                  nsCOMArray<nsILocalFile>& fileArray)
{
  nsresult rv;
  nsCOMPtr<nsISimpleEnumerator> entries;
  rv = file->GetDirectoryEntries(getter_AddRefs(entries));
  if (NS_FAILED(rv) || !entries)
    return false;

  bool hasMore;
  while (NS_SUCCEEDED(entries->HasMoreElements(&hasMore)) && hasMore) {
    nsCOMPtr<nsISupports> sup;
    entries->GetNext(getter_AddRefs(sup));
    if (!sup)
      return false;
    nsCOMPtr<nsILocalFile> fileX = do_QueryInterface(sup);
    if (!fileX)
      return false;
    nsString name;
    if (NS_FAILED(fileX->GetLeafName(name)))
      return false;
    bool isDir;
    if (NS_FAILED(fileX->IsDirectory(&isDir)))
      return false;
    if (isDir) {
      getOEacctFiles(fileX, fileArray);
    }
    else {
      if (StringEndsWith(name, NS_LITERAL_STRING(".oeaccount")))
        fileArray.AppendObject(fileX);
    }
  }
  return true;
}
开发者ID:vanto,项目名称:comm-central,代码行数:34,代码来源:nsWMSettings.cpp

示例2: GetUniformsAndPossibleNames

void LuaMatUniforms::Parse(lua_State* L, const int tableIdx)
{
	auto uniformAndNames = GetUniformsAndPossibleNames();
	decltype(uniformAndNames) uniformAndNamesLower;
	for (auto& p: uniformAndNames) {
		uniformAndNamesLower[StringToLower(p.first)] = p.second;
	}

	for (lua_pushnil(L); lua_next(L, tableIdx) != 0; lua_pop(L, 1)) {
		if (!lua_israwstring(L, -2) || !lua_isnumber(L, -1))
			continue;

		// get the lua table key
		// and remove the "loc" at the end (cameraPosLoc -> camerapos)
		std::string uniformLocStr = luaL_tosstring(L, -2);
		StringToLowerInPlace(uniformLocStr);
		if (StringEndsWith(uniformLocStr, "loc")) {
			uniformLocStr.resize(uniformLocStr.size() - 3);
		}

		const auto uniformLocIt = uniformAndNamesLower.find(uniformLocStr);
		if (uniformLocIt == uniformAndNamesLower.end()) {
			LOG_L(L_WARNING, "LuaMaterial: unknown uniform \"%s\"", lua_tostring(L, -2));
			continue;
		}

		uniformLocIt->second->loc = static_cast<GLint>(lua_tonumber(L, -1));
	}
}
开发者ID:Liuyangbiao,项目名称:spring,代码行数:29,代码来源:LuaMaterial.cpp

示例3: NOTIFY_OBSERVERS

nsresult
nsNetscapeProfileMigratorBase::CopyAddressBookDirectories(PBStructArray &aLdapServers,
                                                          nsIPrefService* aPrefService)
{
  // each server has a pref ending with .filename. The value of that pref
  // points to a profile which we need to migrate.
  nsAutoString index;
  index.AppendInt(nsISuiteProfileMigrator::ADDRESSBOOK_DATA);
  NOTIFY_OBSERVERS(MIGRATION_ITEMBEFOREMIGRATE, index.get());

  uint32_t count = aLdapServers.Length();
  for (uint32_t i = 0; i < count; ++i) {
    PrefBranchStruct* pref = aLdapServers.ElementAt(i);
    nsDependentCString prefName(pref->prefName);

    if (StringEndsWith(prefName, NS_LITERAL_CSTRING(".filename"))) {
      CopyFile(pref->stringValue, pref->stringValue);
    }

    // we don't need to do anything to the fileName pref itself
  }

  NOTIFY_OBSERVERS(MIGRATION_ITEMAFTERMIGRATE, index.get());

  return NS_OK;
}
开发者ID:aleth,项目名称:releases-comm-central,代码行数:26,代码来源:nsNetscapeProfileMigratorBase.cpp

示例4: gtk_print_settings_set

NS_IMETHODIMP
nsPrintSettingsGTK::SetToFileName(const char16_t * aToFileName)
{
  if (aToFileName[0] == 0) {
    mToFileName.SetLength(0);
    gtk_print_settings_set(mPrintSettings, GTK_PRINT_SETTINGS_OUTPUT_URI,
                           nullptr);
    return NS_OK;
  }

  if (StringEndsWith(nsDependentString(aToFileName), NS_LITERAL_STRING(".ps"))) {
    gtk_print_settings_set(mPrintSettings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT, "ps");
  } else {
    gtk_print_settings_set(mPrintSettings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT, "pdf");
  }

  nsCOMPtr<nsIFile> file;
  nsresult rv = NS_NewLocalFile(nsDependentString(aToFileName), true,
                                getter_AddRefs(file));
  NS_ENSURE_SUCCESS(rv, rv);

  // Convert the nsIFile to a URL
  nsAutoCString url;
  rv = NS_GetURLSpecFromFile(file, url);
  NS_ENSURE_SUCCESS(rv, rv);

  gtk_print_settings_set(mPrintSettings, GTK_PRINT_SETTINGS_OUTPUT_URI, url.get());
  mToFileName = aToFileName;

  return NS_OK;
}
开发者ID:giota-cliqz,项目名称:browser-f,代码行数:31,代码来源:nsPrintSettingsGTK.cpp

示例5: HashDirectoryTreeCallback

int HashDirectoryTreeCallback(const char *filename, ARG_UNUSED const struct stat *sb, void *user_data)
{
    HashDirectoryTreeState *state = user_data;
    bool ignore = true;
    for (size_t i = 0; state->extensions_filter[i]; i++)
    {
        if (StringEndsWith(filename, state->extensions_filter[i]))
        {
            ignore = false;
            break;
        }
    }

    if (ignore)
    {
        return 0;
    }

    FILE *file = fopen(filename, "rb");
    if (!file)
    {
        Log(LOG_LEVEL_ERR, "Cannot open file for hashing '%s'. (fopen: %s)", filename, GetErrorStr());
        return -1;
    }

    size_t len = 0;
    char buffer[1024];
    while ((len = fread(buffer, 1, 1024, file)))
    {
        EVP_DigestUpdate(state->crypto_context, state->buffer, len);
    }

    fclose(file);
    return 0;
}
开发者ID:amousset,项目名称:core,代码行数:35,代码来源:files_lib.c

示例6: NS_LITERAL_CSTRING

NS_IMETHODIMP
nsFileProtocolHandler::ReadURLFile(nsIFile* aFile, nsIURI** aURI)
{
    // We only support desktop files that end in ".desktop" like the spec says:
    // http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html
    nsAutoCString leafName;
    nsresult rv = aFile->GetNativeLeafName(leafName);
    if (NS_FAILED(rv) ||
	!StringEndsWith(leafName, NS_LITERAL_CSTRING(".desktop")))
        return NS_ERROR_NOT_AVAILABLE;

    nsINIParser parser;
    rv = parser.Init(aFile);
    if (NS_FAILED(rv))
        return rv;

    nsAutoCString type;
    parser.GetString(DESKTOP_ENTRY_SECTION, "Type", type);
    if (!type.EqualsLiteral("Link"))
        return NS_ERROR_NOT_AVAILABLE;

    nsAutoCString url;
    rv = parser.GetString(DESKTOP_ENTRY_SECTION, "URL", url);
    if (NS_FAILED(rv) || url.IsEmpty())
        return NS_ERROR_NOT_AVAILABLE;

    return NS_NewURI(aURI, url);
}
开发者ID:bcharbonnier,项目名称:mozilla-central,代码行数:28,代码来源:nsFileProtocolHandler.cpp

示例7: SelectLuaFile

static const TCHAR *
SelectLuaFile(TCHAR *buffer, const TCHAR *path)
{
  if (StringIsEmpty(path)) {
    /* no parameter: let user select a *.lua file */
    LuaFileVisitor visitor;

    Directory::VisitSpecificFiles(LocalPath(buffer, _T("lua")), _T("*.lua"),
                                  visitor, true);
    if (visitor.combo_list.empty()) {
      ShowMessageBox(_("Not found"), _T("RunLuaFile"),
                     MB_OK|MB_ICONINFORMATION);
      return nullptr;
    }

    int i = ComboPicker(_("Select a file"), visitor.combo_list);
    if (i < 0)
      return nullptr;

    UnsafeCopyString(buffer, visitor.combo_list[i].string_value);
    return buffer;
  } else if (StringEndsWith(path, _T(".lua"))) {
    /* *.lua file specified: run this file */
    return IsAbsolutePath(path)
      ? path
      : LocalPath(buffer, _T("lua"), path);
  } else {
    ShowMessageBox(_T("RunLuaFile expects *.lua parameter"),
                   _T("RunLuaFile"), MB_OK|MB_ICONINFORMATION);
    return nullptr;
  }
}
开发者ID:ThomasXBMC,项目名称:XCSoar,代码行数:32,代码来源:InputEventsLua.cpp

示例8: NS_ENSURE_ARG

NS_IMETHODIMP MsgMailNewsUrlBase::GetIsMessageUri(bool *aIsMessageUri)
{
  NS_ENSURE_ARG(aIsMessageUri);
  nsAutoCString scheme;
  m_baseURL->GetScheme(scheme);
  *aIsMessageUri = StringEndsWith(scheme, NS_LITERAL_CSTRING("-message"));
  return NS_OK;
}
开发者ID:stonewell,项目名称:exchange-ews-thunderbird,代码行数:8,代码来源:MsgMailNewsUrlBase.cpp

示例9: Reset

PRBool nsOEScanBoxes::Scan50MailboxDir( nsIFile * srcDir)
{
  Reset();

  MailboxEntry *  pEntry;
  PRInt32      index = 1;
  char *      pLeaf;

  PRBool hasMore;
  nsCOMPtr<nsISimpleEnumerator> directoryEnumerator;
  nsresult rv = srcDir->GetDirectoryEntries(getter_AddRefs(directoryEnumerator));
  NS_ENSURE_SUCCESS(rv, rv);

  directoryEnumerator->HasMoreElements(&hasMore);
  PRBool            isFile;
  nsCOMPtr<nsIFile> entry;
  nsCString         fName;

  while (hasMore && NS_SUCCEEDED(rv))
  {
    nsCOMPtr<nsISupports> aSupport;
    rv = directoryEnumerator->GetNext(getter_AddRefs(aSupport));
    nsCOMPtr<nsILocalFile> entry(do_QueryInterface(aSupport, &rv));
    directoryEnumerator->HasMoreElements(&hasMore);

    isFile = PR_FALSE;
    rv = entry->IsFile( &isFile);
    if (NS_SUCCEEDED( rv) && isFile) {
      pLeaf = nsnull;
      rv = entry->GetNativeLeafName( fName);
      if (NS_SUCCEEDED( rv)  &&
        (StringEndsWith(fName, NS_LITERAL_CSTRING(".dbx")))) {
          // This is a *.dbx file in the mail directory
          if (nsOE5File::IsLocalMailFile(entry)) {
            pEntry = new MailboxEntry;
            pEntry->index = index;
            index++;
            pEntry->parent = 0;
            pEntry->child = 0;
            pEntry->sibling = index;
            pEntry->type = -1;
            fName.SetLength(fName.Length() - 4);
            pEntry->fileName = fName.get();
            NS_CopyNativeToUnicode(fName, pEntry->mailName);
            m_entryArray.AppendElement( pEntry);
          }
      }
    }
  }

  if (m_entryArray.Count() > 0) {
    pEntry = (MailboxEntry *)m_entryArray.ElementAt( m_entryArray.Count() - 1);
    pEntry->sibling = -1;
    return( PR_TRUE);
  }

  return( PR_FALSE);
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:58,代码来源:nsOEScanBoxes.cpp

示例10: RulesHandlerStartElement

/* code borrow from kde-workspace/kcontrol/keyboard/xkb_rules.cpp */
void RulesHandlerStartElement(void *ctx, const xmlChar *name,
                              const xmlChar **atts)
{
    FcitxXkbRulesHandler* ruleshandler = (FcitxXkbRulesHandler*) ctx;
    FcitxXkbRules* rules = ruleshandler->rules;
    utarray_push_back(ruleshandler->path, &name);

    char* strPath = fcitx_utils_join_string_list(ruleshandler->path, '/');
    if ( StringEndsWith(strPath, "layoutList/layout/configItem") ) {
        utarray_extend_back(rules->layoutInfos);
    }
    else if ( StringEndsWith(strPath, "layoutList/layout/variantList/variant") ) {
        FcitxXkbLayoutInfo* layoutInfo = (FcitxXkbLayoutInfo*) utarray_back(rules->layoutInfos);
        utarray_extend_back(layoutInfo->variantInfos);
    }
    else if ( StringEndsWith(strPath, "modelList/model") ) {
        utarray_extend_back(rules->modelInfos);
    }
    else if ( StringEndsWith(strPath, "optionList/group") ) {
        utarray_extend_back(rules->optionGroupInfos);
        FcitxXkbOptionGroupInfo* optionGroupInfo = (FcitxXkbOptionGroupInfo*) utarray_back(rules->optionGroupInfos);
        int i = 0;
        while(atts && atts[i*2] != 0) {
            if (strcmp(XMLCHAR_CAST atts[i*2], "allowMultipleSelection") == 0) {
                optionGroupInfo->exclusive = (strcmp(XMLCHAR_CAST atts[i*2 + 1], "true") != 0);
            }
            i++;
        }
    }
    else if ( StringEndsWith(strPath, "optionList/group/option") ) {
        FcitxXkbOptionGroupInfo* optionGroupInfo = (FcitxXkbOptionGroupInfo*) utarray_back(rules->optionGroupInfos);
        utarray_extend_back(optionGroupInfo->optionInfos);
    }
    else if ( strcmp(strPath, "xkbConfigRegistry") == 0 ) {
        int i = 0;
        while(atts && atts[i*2] != 0) {
            if (strcmp(XMLCHAR_CAST atts[i*2], "version") == 0 && strlen(XMLCHAR_CAST atts[i*2 + 1]) != 0) {
                rules->version = strdup(XMLCHAR_CAST atts[i*2 + 1]);
            }
            i++;
        }
    }
    free(strPath);
}
开发者ID:farseerfc,项目名称:fcitx,代码行数:45,代码来源:rules.c

示例11: NS_NAMED_LITERAL_CSTRING

PRBool nsPluginsDir::IsPluginFile(nsIFile* file)
{
    nsCAutoString filename;
    if (NS_FAILED(file->GetNativeLeafName(filename)))
        return PR_FALSE;

    NS_NAMED_LITERAL_CSTRING(dllSuffix, LOCAL_PLUGIN_DLL_SUFFIX);
    if (filename.Length() > dllSuffix.Length() &&
        StringEndsWith(filename, dllSuffix))
        return PR_TRUE;
    
#ifdef LOCAL_PLUGIN_DLL_ALT_SUFFIX
    NS_NAMED_LITERAL_CSTRING(dllAltSuffix, LOCAL_PLUGIN_DLL_ALT_SUFFIX);
    if (filename.Length() > dllAltSuffix.Length() &&
        StringEndsWith(filename, dllAltSuffix))
        return PR_TRUE;
#endif
    return PR_FALSE;
}
开发者ID:amyvmiwei,项目名称:firefox,代码行数:19,代码来源:nsPluginsDirUnix.cpp

示例12: IsInNoProxyList

static PRBool
IsInNoProxyList(const nsACString& aHost, PRInt32 aPort, const char* noProxyVal)
{
  NS_ASSERTION(aPort >= 0, "Negative port?");
  
  nsCAutoString noProxy(noProxyVal);
  if (noProxy.EqualsLiteral("*"))
    return PR_TRUE;
    
  noProxy.StripWhitespace();
  
  nsReadingIterator<char> pos;
  nsReadingIterator<char> end;
  noProxy.BeginReading(pos);
  noProxy.EndReading(end);
  while (pos != end) {
    nsReadingIterator<char> last = pos;
    nsReadingIterator<char> nextPos;
    if (FindCharInReadable(',', last, end)) {
      nextPos = last;
      ++nextPos;
    } else {
      last = end;
      nextPos = end;
    }
    
    nsReadingIterator<char> colon = pos;
    PRInt32 port = -1;
    if (FindCharInReadable(':', colon, last)) {
      ++colon;
      nsDependentCSubstring portStr(colon, last);
      nsCAutoString portStr2(portStr); // We need this for ToInteger. String API's suck.
      PRInt32 err;
      port = portStr2.ToInteger(&err);
      if (NS_FAILED(err)) {
        port = -2; // don't match any port, so we ignore this pattern
      }
      --colon;
    } else {
      colon = last;
    }
    
    if (port == -1 || port == aPort) {
      nsDependentCSubstring hostStr(pos, colon);
      // By using StringEndsWith instead of an equality comparator, we can include sub-domains
      if (StringEndsWith(aHost, hostStr, nsCaseInsensitiveCStringComparator()))
        return PR_TRUE;
    }
    
    pos = nextPos;
  }
  
  return PR_FALSE;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:54,代码来源:nsUnixSystemProxySettings.cpp

示例13: CheckFileExtension

//==============================================================================
bool
CheckFileExtension(
const char* extension,  ///< file extension
const char* FileName )  ///< file name
{
  // first check extension
  if ( ! StringEndsWith(extension, FileName) ) return false;
  
  // then check separator
  return FileName[ strlen(FileName) - strlen(extension) - 1 ] == '.';
}
开发者ID:AntoineD,项目名称:spaf,代码行数:12,代码来源:file_system.c

示例14: Open

// caller passes in upgrading==true if they want back a db even if the db is out of date.
// If so, they'll extract out the interesting info from the db, close it, delete it, and
// then try to open the db again, prior to reparsing.
nsresult nsMailDatabase::Open(nsIFile *aSummaryFile, bool aCreate,
                              bool aUpgrading)
{
#ifdef DEBUG
  nsString leafName;
  aSummaryFile->GetLeafName(leafName);
  if (!StringEndsWith(leafName, NS_LITERAL_STRING(".msf"),
                     nsCaseInsensitiveStringComparator()))
    NS_ERROR("non summary file passed into open\n");
#endif
  return nsMsgDatabase::Open(aSummaryFile, aCreate, aUpgrading);
}
开发者ID:dualsky,项目名称:FossaMail,代码行数:15,代码来源:nsMailDatabase.cpp

示例15: AttrHasSuffix

static bool
AttrHasSuffix(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName,
              nsIAtom* aStr_)
{
  FakeRef<nsIAtom> aStr(aStr_);
  auto match = [aStr](const nsAttrValue* aValue) {
    nsAutoString str;
    aValue->ToString(str);
    return StringEndsWith(str, nsDependentAtomString(aStr));
  };
  return DoMatch(aElement, aNS, aName, match);
}
开发者ID:cliqz-oss,项目名称:browser-f,代码行数:12,代码来源:ServoBindings.cpp


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