const char* CAddonCallbacksAddon::GetDVDMenuLanguage(const void* addonData) { CAddonCallbacks* helper = (CAddonCallbacks*) addonData; if (!helper) return NULL; CStdString string = g_langInfo.GetDVDMenuLanguage(); char *buffer = (char*) malloc (string.length()+1); strcpy(buffer, string.c_str()); return buffer; }
bool CNfsConnection::splitUrlIntoExportAndPath(const CURL& url, CStdString &exportPath, CStdString &relativePath) { bool ret = false; if(m_exportList.empty()) { m_exportList = GetExportList(url); } if(!m_exportList.empty()) { relativePath = ""; exportPath = ""; CStdString path = url.GetFileName(); //GetFileName returns path without leading "/" //but we need it because the export paths start with "/" //and path.Find(*it) wouldn't work else if(path[0] != '/') { path = "/" + path; } std::list<CStdString>::iterator it; for(it=m_exportList.begin();it!=m_exportList.end();it++) { //if path starts with the current export path if( path.Find(*it) == 0 ) { exportPath = *it; relativePath = "//" + path.Right((path.length()-1) - exportPath.length()); ret = true; break; } } } return ret; }
////////////////////////////////////////////////////////////////////////////////////// // // 函数功能描述:处理获取本地或服务器的网站最后更新时间成功的需要做的操作 // 输入:szResult 网站最后更新时间字符串 // 输出: // 返回值:1 成功 ; 0 失败 // 其它说明: // ////////////////////////////////////////////////////////////////////////////////////// DWORD CWebService::GetAllStationLastUpdateALLOK(const CStdString &szResult) { if (szResult.length() ==0) { CStdString strBack; g_log.Trace(LOGL_TOP, LOGT_ERROR,__TFILE__, __LINE__,_T("1.bin文件下载失败,主控退出")); strBack.Format(_T("BackResult(;0)1.bin下载失败(;0)(;0)")); BYTE * pByData = (BYTE *)strBack.c_str(); g_ServerSocket->SendData(strBack.size() * 2,E_GET_EXCUTE_TASK_RESULT,(char*)pByData); g_ServerSocket->UnInit(); ExitProcess(0); //退出主控 return 1; } std::map<DWORD, T_ServerNetStationInfo*> *pMapLastUpdateTime = NULL; pMapLastUpdateTime = new std::map<DWORD, T_ServerNetStationInfo*>; ASSERT(pMapLastUpdateTime != NULL); m_dwNetLastupdateIndex = g_GlobalDataBlock->GetGlobalID(); g_GlobalDataBlock->WriteRealData(m_dwNetLastupdateIndex, E_ServerNetStationInfoGroup, pMapLastUpdateTime, E_WEBSERVICE_CLASS,eWithoutUse); SaveLastUpdateToMap(m_dwNetLastupdateIndex, szResult); g_log.Trace(LOGL_LOW, LOGT_PROMPT, __TFILE__, __LINE__,\ _T("GetAllStationLastUpdateALLOK,size: %d ") ,pMapLastUpdateTime->size()); if (0 == pMapLastUpdateTime->size()) { g_log.Trace(LOGL_LOW, LOGT_PROMPT, __TFILE__, __LINE__,\ _T("GetAllStationLastUpdateALLOK, %s") ,szResult.c_str()); } dwIsAllNetstationLastUpdateGetted = 1; if (1 == dwIsAllNetstationLastUpdateGetted && 0 == m_dwWebServiceAllStationLastUpdateSended) //最新的网站列表获取了 && 最新的网站最后时间也获取了 &&独立三代任务数据的最后时间也获取了 && 还没有向PPD发送数据已经全部准备好的信息 { PostMessage(E_DATAPRE_THREAD,E_PPD_LASTUPDATE_GETTED_MSG, m_dwNetLastupdateIndex); //网站最后更新时间已经获取了,通知准备线程更新 m_dwWebServiceAllStationLastUpdateSended = 1; } return BIZMC_OK; }
// helper void TestEMFDecoding::CellTesting(RTFTable* pTable, int iIndex, int iRows, int iCols, const CStdString& sText, int iText/*==1*/) { RTFCell* pCell =(RTFCell *)GetNthObject(pTable, rotCellcontent, iIndex); NUnit::Framework::Assert::IsTrue(pCell->GetColsSpanned() == iCols, "Spans incorrect cells"); NUnit::Framework::Assert::IsTrue(pCell->GetRowsSpanned() == iRows, "Spans bad rows"); if (sText.length() != 0) { RTFPCData* pData =(RTFPCData*)GetNthObject(pCell, rotPcdata, iText); CWideString s = pData->GetContent(); NUnit::Framework::Assert::IsTrue(s == sText, "Should have the given Text"); } }
void CURL::SetProtocolOptions(const CStdString& strOptions) { m_strProtocolOptions.Empty(); m_protocolOptions.Clear(); if (strOptions.length() > 0) { if (strOptions[0] == '|') m_strProtocolOptions = strOptions.Mid(1); else m_strProtocolOptions = strOptions; m_protocolOptions.AddOptions(m_strProtocolOptions); } }
void CURL::SetOptions(const CStdString& strOptions) { m_strOptions.Empty(); if( strOptions.length() > 0) { if( strOptions[0] == '?' || strOptions[0] == '#' || strOptions[0] == ';' || strOptions.Find("xml") >=0 ) { m_strOptions = strOptions; } else CLog::Log(LOGWARNING, "%s - Invalid options specified for url %s", __FUNCTION__, strOptions.c_str()); } }
void CEpgInfoTag::SetPlot(const CStdString &strPlot) { CStdString strPlotClean = (m_strPlotOutline.length() > 0 && strPlot.Left(m_strPlotOutline.length()).Equals(m_strPlotOutline)) ? strPlot.Right(strPlot.length() - m_strPlotOutline.length()) : strPlot; if (m_strPlot != strPlotClean) { m_strPlot = strPlotClean; m_bChanged = true; UpdatePath(); } }
CFileItemPtr CPVRChannelGroups::GetByPath(const CStdString &strPath) const { // get the filename from curl CURL url(strPath); CStdString strFileName = url.GetFileName(); URIUtils::RemoveSlashAtEnd(strFileName); CStdString strCheckPath; for (std::vector<CPVRChannelGroupPtr>::const_iterator it = m_groups.begin(); it != m_groups.end(); it++) { // check if the path matches strCheckPath.Format("channels/%s/%s/", (*it)->IsRadio() ? "radio" : "tv", (*it)->GroupName().c_str()); if (strFileName.Left(strCheckPath.length()) == strCheckPath) { strFileName.erase(0, strCheckPath.length()); return (*it)->GetByIndex(atoi(strFileName.c_str())); } } // no match CFileItemPtr retVal(new CFileItem); return retVal; }
void CGUIInfoColor::Parse(const CStdString &label, int context) { // Check for the standard $INFO[] block layout, and strip it if present CStdString label2 = label; if (label.Equals("-", false)) return; if (label.Left(4).Equals("$VAR", false)) { label2 = label.Mid(5, label.length() - 6); m_info = g_infoManager.TranslateSkinVariableString(label2, context); if (!m_info) m_info = g_infoManager.RegisterSkinVariableString(g_SkinInfo->CreateSkinVariable(label2, context)); return; } if (label.Left(5).Equals("$INFO", false)) label2 = label.Mid(6, label.length()-7); m_info = g_infoManager.TranslateString(label2); if (!m_info) m_color = g_colorManager.GetColor(label); }
const char* CAddonCallbacksAddon::GetLocalizedTime(const void* addonData,time_t time, bool bWithSeconds) { CAddonCallbacks* helper = (CAddonCallbacks*) addonData; if (!helper) return NULL; CDateTime date(time); CStdString string = date.GetAsLocalizedTime("",bWithSeconds); char *buffer = (char*) malloc (string.length()+1); strcpy(buffer, string.c_str()); return buffer; }
static void ParseItemRSS(CFileItem* item, SResources& resources, TiXmlElement* item_child, const CStdString& name, const CStdString& xmlns, const CStdString& path) { CStdString text = item_child->GetText(); if (name == "title") { if(text.length() > item->m_strTitle.length()) item->m_strTitle = text; } else if (name == "pubDate") { CDateTime pubDate(ParseDate(text)); item->m_dateTime = pubDate; } else if (name == "link") { SResource res; res.tag = "rss:link"; res.path = text; resources.push_back(res); } else if(name == "enclosure") { const char * len = item_child->Attribute("length"); SResource res; res.tag = "rss:enclosure"; res.path = XMLUtils::GetAttribute(item_child, "url"); res.mime = XMLUtils::GetAttribute(item_child, "type"); if(len) res.size = _atoi64(len); resources.push_back(res); } else if(name == "description") { CStdString description = text; HTML::CHTMLUtil::RemoveTags(description); item->SetProperty("description", description); } else if(name == "guid") { if(IsPathToMedia(text)) { SResource res; res.tag = "rss:guid"; res.path = text; resources.push_back(res); } } }
CStdString DocProvHelper::GenerateUniquePathNameFromDocID(CStdString sDocumentID) const { sDocumentID.Trim(); /* TXTEX_IGNORE */ sDocumentID.Replace( '\\', _T('/') ); /* TXTEX_IGNORE */ sDocumentID.Replace( _T("://"), _T("/") ); int nLastPeriod = (x64_int_cast)sDocumentID.length() - 4; /* TXTEX_IGNORE */ if( nLastPeriod >= 0 && sDocumentID.GetAt( nLastPeriod ) == _T('.') ) /* TXTEX_IGNORE */ sDocumentID.SetAt( nLastPeriod, _T('_') ); return ReplaceInvalidFileNameChars(sDocumentID); }
void CGUIInfoColor::Parse(const CStdString &label) { // Check for the standard $INFO[] block layout, and strip it if present CStdString label2 = label; if (label.Equals("-", false)) return; if (label.Left(5).Equals("$INFO", false)) label2 = label.Mid(6, label.length()-7); m_info = g_infoManager.TranslateString(label2); if (!m_info) m_color = g_colorManager.GetColor(label); }
void CGUIInfoColor::Parse(const CStdString &label, int context) { // Check for the standard $INFO[] block layout, and strip it if present CStdString label2 = label; if (label.Equals("-", false)) return; if (StringUtils::StartsWithNoCase(label, "$var[")) { label2 = label.substr(5, label.length() - 6); m_info = g_infoManager.TranslateSkinVariableString(label2, context); if (!m_info) m_info = g_infoManager.RegisterSkinVariableString(g_SkinInfo->CreateSkinVariable(label2, context)); return; } if (StringUtils::StartsWithNoCase(label, "$info[")) label2 = label.substr(6, label.length()-7); m_info = g_infoManager.TranslateString(label2); if (!m_info) m_color = g_colorManager.GetColor(label); }
void TestGlobalMethods::TestReplaceFileExtension() { CStdString sFile = _T("NotPDF.doc"); CStdString sExtension = _T("pdf"); CStdString sResult = ReplaceFileExtension(sFile, sExtension.c_str()); int iPosition = sResult.ReverseFind(_T('.')); CStdString sNewExtension = sResult.Right((int)sResult.length() - (iPosition + 1)); assertMessage(0 != iPosition, _T("Failed to locate file extension separator '.'")); assertMessage(0 == (int)sExtension.CompareNoCase(sNewExtension), _T("Failed to match the expected extension 'pdf'")); sFile = _T("IsPDF.pdf"); sExtension = _T("pdf"); sResult = ReplaceFileExtension(sFile, sExtension.c_str()); sNewExtension = sResult.Right((int)sResult.length() - (sResult.Find(_T("."), 0) + 1)); assertMessage(sExtension.length() == sNewExtension.length(), _T("We expected the extension lengths to be equal")); sFile = _T("NoExtension"); sExtension = _T("pdf"); sResult = ReplaceFileExtension(sFile, sExtension.c_str()); iPosition = sResult.ReverseFind(_T('.')); assertMessage(0 != iPosition, _T("Failed to locate file extension separator '.'")); assertMessage(0 == (int)sExtension.CompareNoCase(sResult.Right((int)sResult.length() - (iPosition + 1))), _T("Failed to match the expected extension 'pdf'")); }
void CKeyboardLayoutConfiguration::readCharMapFromXML(const TiXmlElement* pXMLMap, map<WCHAR, WCHAR>& charToCharMap, const char* mapRootElement) { if (pXMLMap && !pXMLMap->NoChildren()) { // map keys const TiXmlElement* pEntry = pXMLMap->FirstChildElement(); while (pEntry) { CStdString strInChar = pEntry->Attribute("inchar"); CStdString strOutChar = pEntry->Attribute("outchar"); if (strInChar.length() > 0 && strOutChar.length() > 0) { CStdStringW fromStr; g_charsetConverter.utf8ToW(strInChar, fromStr); CStdStringW toStr; g_charsetConverter.utf8ToW(strOutChar, toStr); if (fromStr.size()==1 && toStr.size()==1) { charToCharMap.insert(pair<WCHAR, WCHAR>(fromStr[0], toStr[0])); CLog::Log(LOGDEBUG, "insert map entry from %c to %c ", fromStr[0], toStr[0]); } else { CLog::Log(LOGERROR, "String from %ls or to %ls does not have the expected length of 1", fromStr.c_str(), toStr.c_str()); } } else { CLog::Log(LOGERROR, "map entry misses attribute <inchar> or <outchar> or content of them"); } pEntry = pEntry->NextSiblingElement(); } } else { CLog::Log(LOGDEBUG, "XML-Configuration doesn't contain expected map root element %s", mapRootElement); } }
bool CHDDirectory::GetSmartFolder(const CStdString& strPath, CFileItemList &items) { #ifdef __APPLE__ CStdString strTruePath = strPath; // If there's a trailing /, remove it. if (CUtil::HasSlashAtEnd(strTruePath)) strTruePath = strTruePath.Left(strTruePath.length()-1); // Execute the query. Cocoa_GetSmartFolderResults(strTruePath, HandleSearchResult, this, &items); #endif return true; }
void ExcelControllerImpl08::WaitForWorkbookOpened(const CStdString& sFilePathName) { CStdString sWorkbookName = sFilePathName; int iPos = sWorkbookName.ReverseFind('\\'); if (-1 != iPos) sWorkbookName = sWorkbookName.Right((int)sWorkbookName.length() - iPos - 1); else { iPos = sWorkbookName.ReverseFind(_T('/')); if (-1 != iPos) sWorkbookName = sWorkbookName.Right((int)sWorkbookName.length() - iPos - 1); } int iTryCount = 0; while (200 >= iTryCount) // about 20 seconds { try { Excel::_ApplicationPtr spApplication = GetApplication(); Excel::_WorkbookPtr spWorkbook = spApplication->Workbooks->Item[sWorkbookName.c_str()]; return; } catch(const Workshare::Exception&) { //ignore } catch(...) { unexpected(); } ::Sleep(100); iTryCount++; } throw Workshare::Com::ComException(_T("Failed to open workbook [") + sFilePathName + _T("], wait time expired"), E_FAIL); }
bool LocalTempCopyOfFile::IsFullyMessedUpString(CStdString sFileName) { CStdString sFileNameWithoutExtension = RemoveExtension(sFileName); CPINFO codepageInfo; ::GetCPInfo(CP_ACP, &codepageInfo); for(unsigned int i=0; i<sFileNameWithoutExtension.length(); i++) { if ( sFileNameWithoutExtension[i] != codepageInfo.DefaultChar[0]) return false; } return true; }
bool URIUtils::IsRAR(const CStdString& strFile) { CStdString strExtension = GetExtension(strFile); if (strExtension.Equals(".001") && strFile.Mid(strFile.length()-7,7).CompareNoCase(".ts.001")) return true; if (strExtension.CompareNoCase(".cbr") == 0) return true; if (strExtension.CompareNoCase(".rar") == 0) return true; return false; }
void CPeripherals::GetDirectory(const CStdString &strPath, CFileItemList &items) const { if (!strPath.Left(14).Equals("peripherals://")) return; CStdString strPathCut = strPath.Right(strPath.length() - 14); CStdString strBus = strPathCut.Left(strPathCut.Find('/')); CSingleLock lock(m_critSection); for (unsigned int iBusPtr = 0; iBusPtr < m_busses.size(); iBusPtr++) { if (strBus.Equals("all") || strBus.Equals(PeripheralTypeTranslator::BusTypeToString(m_busses.at(iBusPtr)->Type()))) m_busses.at(iBusPtr)->GetDirectory(strPath, items); } }
void CPPTUtil::CheckBuiltInProperties(IDispatch* pX) throw (Workshare::Exception) { if (0 == pX) throw Workshare::Exception(_T("Invalid dispatch pointer passed in")); PowerPoint::_PresentationPtr pPresentation(pX); IDispatchPtr spBuiltInProps = pPresentation->BuiltInDocumentProperties; _bstr_t bstrName = _T(""); _bstr_t bstrValue = _T(""); CStdString sMsg; PowerPoint::PpBuiltInProperty ppPropertyIndex[] = {PowerPoint::ppPropertyTitle, PowerPoint::ppPropertySubject, PowerPoint::ppPropertyAuthor, PowerPoint::ppPropertyKeywords, PowerPoint::ppPropertyComments, PowerPoint::ppPropertyCategory, PowerPoint::ppPropertyManager, PowerPoint::ppPropertyCompany, PowerPoint::ppPropertyHyperlinkBase}; long lCount = sizeof(ppPropertyIndex)/sizeof(PowerPoint::PpBuiltInProperty); CStdString sErr; for (long lIndex = 0; lIndex < lCount; lIndex++) { HRESULT hr = CCOMDispatchHelper::GetPropertyItemValues(spBuiltInProps, ppPropertyIndex[lIndex], bstrName, bstrValue); if (FAILED(hr)) { sErr.Format(_T("CCOMDispatchHelper::GetPropertyItemValues() failed for property index, %ld - Error Code, %ld"), lIndex, hr); throw Workshare::Com::ComException(sErr.c_str(), hr); } CStdString sTmp = bstrValue; sTmp.Trim(); if(0 != sTmp.length()) { sErr.Format(_T("%s not properly reset: current value is %s"), (LPCTSTR)bstrName, sTmp.c_str()); throw Workshare::Exception(sErr.c_str()); } } }
void CGUIDialogAudioSubtitleSettings::AddSubtitleStreams(unsigned int id) { SettingInfo setting; setting.id = id; setting.name = g_localizeStrings.Get(462); setting.type = SettingInfo::SPIN; setting.min = 0; setting.data = &m_subtitleStream; m_subtitleStream = g_application.m_pPlayer->GetSubtitle(); // if(m_subtitleStream < 0) m_subtitleStream = 0; // get the number of audio strams for the current movie setting.max = (float)g_application.m_pPlayer->GetSubtitleCount(); // Add a "None" entry setting.entry.push_back(make_pair(-1, g_localizeStrings.Get(231))); // cycle through each subtitle and add it to our entry list for (int i = 0; i < g_application.m_pPlayer->GetSubtitleCount(); ++i) { CStdString strItem; CStdString strName; g_application.m_pPlayer->GetSubtitleName(i, strName); if (strName.length() == 0) strName = "Unnamed"; CStdString strLanguage; g_application.m_pPlayer->GetSubtitleLanguage(i, strLanguage); if (strName != strLanguage) strName.Format("%s [%s]", strName.c_str(), strLanguage.c_str()); if(g_application.m_pPlayer->GetSubtitleIsForced(i)) { strName += " - "; strName += g_localizeStrings.Get(13207); } strItem.Format("%s (%i/%i)", strName.c_str(), i + 1, (int)setting.max); setting.entry.push_back(make_pair(i, strItem)); } m_settings.push_back(setting); }
AudioDeviceID CCoreAudioHardware::FindAudioDevice(CStdString searchName) { if (!searchName.length()) return 0; UInt32 size = 0; AudioDeviceID deviceId = 0; OSStatus ret; if (searchName.Equals("Default Output Device")) { AudioDeviceID defaultDevice = GetDefaultOutputDevice(); CLog::Log(LOGDEBUG, "CCoreAudioHardware::FindAudioDevice: Returning default device [0x%04x].", defaultDevice); return defaultDevice; } CLog::Log(LOGDEBUG, "CCoreAudioHardware::FindAudioDevice: Searching for device - %s.", searchName.c_str()); // Obtain a list of all available audio devices AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &size, NULL); UInt32 deviceCount = size / sizeof(AudioDeviceID); AudioDeviceID* pDevices = new AudioDeviceID[deviceCount]; ret = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &size, pDevices); if (ret) { CLog::Log(LOGERROR, "CCoreAudioHardware::FindAudioDevice: Unable to retrieve the list of available devices. Error = 0x%08x (%4.4s)", ret, CONVERT_OSSTATUS(ret)); delete[] pDevices; return 0; } // Attempt to locate the requested device CStdString deviceName; for (UInt32 dev = 0; dev < deviceCount; dev++) { CCoreAudioDevice device; device.Open((pDevices[dev])); device.GetName(deviceName); UInt32 totalChannels = device.GetTotalOutputChannels(); CLog::Log(LOGDEBUG, "CCoreAudioHardware::FindAudioDevice: Device[0x%04x] - Name: '%s', Total Ouput Channels: %u. ", pDevices[dev], deviceName.c_str(), totalChannels); if (searchName.Equals(deviceName)) deviceId = pDevices[dev]; if (deviceId) break; } delete[] pDevices; return deviceId; }
VOID CIoSupport::GetXbePath(char* szDest) { #ifdef _XBOX //Function to get the XBE Path like: //E:\DevKit\xbplayer\xbplayer.xbe char szTemp[MAX_PATH]; char cDriveLetter = 0; strncpy(szTemp, XeImageFileName->Buffer + 8, XeImageFileName->Length - 8); szTemp[20] = 0; GetDrive(szTemp, &cDriveLetter); strncpy(szTemp, XeImageFileName->Buffer + 29, XeImageFileName->Length - 29); szTemp[XeImageFileName->Length - 29] = 0; sprintf(szDest, "%c:\\%s", cDriveLetter, szTemp); #elif WIN32 wchar_t szAppPathW[MAX_PATH] = L""; ::GetModuleFileNameW(0, szAppPathW, sizeof(szAppPathW) - 1); CStdStringW strPathW = szAppPathW; CStdString strPath; g_charsetConverter.wToUTF8(strPathW,strPath); strncpy(szDest,strPath.c_str(),strPath.length()+1); #elif __APPLE__ int result = -1; char given_path[2*MAXPATHLEN]; uint32_t path_size = 2*MAXPATHLEN; result = _NSGetExecutablePath(given_path, &path_size); if (result == 0) realpath(given_path, szDest); #else /* Get our PID and build the name of the link in /proc */ pid_t pid = getpid(); char linkname[64]; /* /proc/<pid>/exe */ snprintf(linkname, sizeof(linkname), "/proc/%i/exe", pid); /* Now read the symbolic link */ char buf[1024]; int ret = readlink(linkname, buf, 1024); buf[ret] = 0; strcpy(szDest, buf); #endif }
CZeroconfBrowser::ZeroconfService CZeroconfBrowser::ZeroconfService::fromPath(const CStdString& fcr_path) { if( fcr_path.empty() ) throw std::runtime_error("CZeroconfBrowser::ZeroconfService::fromPath input string empty!"); int pos1 = fcr_path.Find('@'); //first @ int pos2 = fcr_path.Find('@', pos1+1); //second if( pos1 == -1 || pos2 == -1 ) throw std::runtime_error("CZeroconfBrowser::ZeroconfService::fromPath invalid input path"); return ZeroconfService( fcr_path.substr(pos2 + 1, fcr_path.length()), //name fcr_path.substr(0, pos1), //type fcr_path.substr(pos1 + 1, pos2-(pos1+1)) //domain ); }
CStdString fixString(CStdString &ansiString) // ucs2CharsetToStringCharset is always called even when not required resulting in some strings // twice the length they should be. This function is a quick fix to the problem. The correct // solution would be to call ucs2CharsetToStringCharset only when necessary. { int halfLen = ansiString.length() / 2 - 1; CStdString out = ""; if (halfLen > 0) if (*(ansiString.Mid(halfLen, 1).c_str()) == 0 && *(ansiString.Mid(halfLen + 1, 1).c_str()) == 0) out = ansiString.Left(halfLen); if (out == "") return ansiString ; else return out ; }
bool CHttpApi::checkForFunctionTypeParas(CStdString &cmd, CStdString ¶s) { int open, close; open = cmd.Find("("); if (open>0) { close=cmd.length(); while (close>open && cmd.Mid(close,1)!=")") close--; if (close>open) { paras = cmd.Mid(open + 1, close - open - 1); cmd = cmd.Left(open); return (close-open)>1; } } return false; }
int StringUtils::FindBestMatch(const CStdString &str, const CStdStringArray &strings, double &matchscore) { int best = -1; matchscore = 0; int i = 0; for (CStdStringArray::const_iterator it = strings.begin(); it != strings.end(); it++, i++) { int maxlength = max(str.length(), it->length()); double score = StringUtils::CompareFuzzy(str, *it) / maxlength; if (score > matchscore) { matchscore = score; best = i; } } return best; }
HRESULT DocProvHelper::VerifyODMAProvider(CStdString lpszDmsId) { if(m_mapODMAtoWS.size() == 0) { std::vector<CStdString> docProvs = RegistryHandler::GetAvailableDocProvs(true); std::vector<CStdString>::iterator it; for (it = docProvs.begin(); it != docProvs.end(); it++) { CStdString sWsId = Workshare::OptionApi::GetString(L"DocumentProviders", *it, L"ServerID"); CStdString sOdmaId = Workshare::OptionApi::GetString(L"DocumentProviders", *it, L"OdmaDmsID"); if(sOdmaId.length()) m_mapODMAtoWS[sOdmaId] = sWsId; } } return S_OK; }