BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext) { LPGUID* pGUID = (LPGUID*)lpContext; if (pGUID == NULL) { return FALSE; } if ((*pGUID) != NULL) { return TRUE; } if (lpGUID != NULL) { // XP, 2k if ((CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, lpszDrvName, -1, TEXT("cmipci.sys"), -1) == CSTR_EQUAL) && (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, lpszDesc, -1, TEXT("CMI8738/8768 Wave"), -1) == CSTR_EQUAL)) { (*pGUID) = (LPGUID)LocalAlloc(LPTR, sizeof(GUID)); memcpy((*pGUID), lpGUID, sizeof(GUID)); return TRUE; } // Vista if (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, lpszDesc, -1, TEXT("Speakers (CMI8738/8768 Audio Device)"), -1) == CSTR_EQUAL) { (*pGUID) = (LPGUID)LocalAlloc(LPTR, sizeof(GUID)); memcpy((*pGUID), lpGUID, sizeof(GUID)); return TRUE; } } return TRUE; }
int FilenameCompare( const TCHAR * pa, const TCHAR * pb ) { int diff = CompareString( LOCALE_USER_DEFAULT, NORM_IGNORECASE|NORM_IGNOREKANATYPE|NORM_IGNOREWIDTH, pa, -1, pb, -1 ); if ( diff == CSTR_EQUAL ) diff = CompareString( LOCALE_USER_DEFAULT, SORT_STRINGSORT, pa, -1, pb, -1 ); return diff - CSTR_EQUAL; }
long CDistDatabaseReactor::SelectRowId(int& nRowId,const char* strCadLyName,const char *strSdeLyName,int nIndex,AcDbDatabase* pDB) { int nResult = 0; DIST_STRUCT_CHANGEROWID* pTemp = m_pRowIdData; int nID = int(pDB); nRowId = -1; while(pTemp != NULL) { if(nID == pTemp->nID && CompareString(strCadLyName,pTemp->strCadLyName)==0 && CompareString(strSdeLyName,pTemp->strSdeLyName)==0) { int nCount = pTemp->RowIdArray.GetSize(); if(nIndex>=0 && nIndex < nCount) { nRowId = pTemp->RowIdArray.GetAt(nIndex); nResult = 1; } break; } pTemp = pTemp->pNext; } return nResult; }
// 功能:判断指定属性实体是否存在 // 参数:strCadLyName CAD图层名称 // strSdeLyName SDE图层名称 // nRowId 实体RowId // pDB 数据库指针(主要区分多文档) // 返回:存在返回 1 ;不存在返回 0 ;其他参考定义 long CDistDatabaseReactor::IsRowIdExists(const char* strCadLyName,const char *strSdeLyName, int nRowId,AcDbDatabase* pDB) { if(nRowId < 0) return 0; //RowId值小于0,认为是新增实体,链表不会记录它们的改动 int nResult = 0; DIST_STRUCT_CHANGEROWID* pTemp = m_pRowIdData; int nID = int(pDB); while(pTemp != NULL) { if((nID == pTemp->nID) && (CompareString(strCadLyName,pTemp->strCadLyName)==0) && (CompareString(strSdeLyName,pTemp->strSdeLyName)==0)) { int nCount = pTemp->RowIdArray.GetSize(); for(int i=0; i<nCount; i++) { if(nRowId == pTemp->RowIdArray.GetAt(i)) { nResult = 1; break; } } } pTemp = pTemp->pNext; } return nResult; }
void BootUpModule(void) { typedef enum { Bootup1, Passed, Error } BootUpState_Type; BootUpState_Type BootUpState = Bootup1; while (BootUpState != Passed) { switch (BootUpState) { case Bootup1: SendSim900("AT+Bootup\r\n"); if (CompareString(buffer, "OK", 2)) { //are the same FRTOS1_xSemaphoreGive(SuccessLedMutex); BootUpState = Passed; } break; default: BootUpState = Error; break; } FRTOS1_vTaskDelay(BOOTUP_STATEMACHINE_DELAY_MS/portTICK_PERIOD_MS); } }
int FarString::CompareNoCase (const char * Str, size_t nLength) const { if (nLength > fData->fLength+1) nLength = fData->fLength+1; return 2-CompareString (LOCALE_USER_DEFAULT, NORM_IGNORECASE, fData->fText, nLength, Str, nLength); }
static int CALLBACK CompareListItem(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) { int cmp = CompareString((LCID)lParamSort, 0, ((LANGPACK_INFO*)lParam1)->szLanguage, -1, ((LANGPACK_INFO*)lParam2)->szLanguage, -1); if (cmp != 0) cmp -= 2; return cmp; }
int main() { Student stus[] = {{"a",10},{"b",50},{"c",20}}; for(Student* s=stus;s!=stus+3;++s){ std::cout<<s->name<<" "<<s->score<<"\n"; } Student *end = stus + sizeof(stus)/sizeof(stus[0]); Student *best = bestStudent(stus,end,&compareStudentScore); std::cout<<(*best).name<<"~~~~~~~~~~~"<<(*best).score<<std::endl; int num[] = {1,2,4,6,8,2,4}; int *nEnd = num + sizeof(num)/sizeof(num[0]); { int *high = bestStudent(num,nEnd,&compareInt); std::cout<<*high<<std::endl; } { Compare2 comp; comp(3,6); int *high = bestStudent(num,nEnd,comp); std::cout<<*high<<std::endl; } const char* strs[]={"dsifewnrfsdfawoewaf","1654sdaf","w3rewasa3","29ajfdsof93"}; const char **last = strs + sizeof(strs)/sizeof(strs[0]); std::sort(strs,last,CompareString()); for(int i=0;i<4;i++) { std::cout<<strs[i]<<std::endl; } return 0; }
_Use_decl_annotations_ DX9_exception::DX9_exception(HRESULT hr, const char* file_name, int line) noexcept : HRESULT_exception(hr, file_name, line) { try { WCHAR wide_error_string[1024]; PCWSTR dx_message = DXGetErrorStringW(m_hr); if(CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, dx_message, -1, TEXT("Unknown"), -1) == CSTR_EQUAL) { assert(!"DX error string could not be found. Was check_hr intended?"); dx_message = L"Unknown error."; } StringCchPrintfW(wide_error_string, ARRAYSIZE(wide_error_string), L"Error: %08x: %s", m_hr, dx_message); const auto error_string = PortableRuntime::utf8_from_utf16(wide_error_string); PortableRuntime::dprintf("!%s(%d): %s\n", file_name, line, error_string.c_str()); // Just save off the message now, but do the full formatting in what(), to allow exception unwind to free up some resources. m_what = std::make_shared<std::string>(std::move(error_string)); } catch(const std::bad_alloc& ex) { (void)ex; // Unreferenced parameter. PortableRuntime::dprintf("!Failed creation of exception object.\n"); } }
void CDistDatabaseReactor::InsertReadOnlyLayer(const char *strSdeLyName,AcDbDatabase* pDB) { DIST_STRUCT_READONLYLAYER* pTemp = m_pReadOnlyLayer; DIST_STRUCT_READONLYLAYER* pTempPre = pTemp; int nID = int(pDB); while(pTemp != NULL) { if((nID == pTemp->nID) && (CompareString(strSdeLyName,pTemp->strSdeLyName)==0)) return; //已经存在,直接退出 pTempPre = pTemp; pTemp = pTemp->pNext; } pTemp = new DIST_STRUCT_READONLYLAYER; strcpy(pTemp->strSdeLyName,strSdeLyName); pTemp->nID = nID; pTemp->pNext = NULL; if(m_pReadOnlyLayer == NULL) m_pReadOnlyLayer = pTemp; else pTempPre->pNext = pTemp; }
void GetConnection(void) { typedef enum { GetCon1, Passed, Error } GetConState_Type; GetConState_Type GetConState = GetCon1; while (GetConState != Passed) { switch (GetConState) { case GetCon1: SendSim900("AT+GetConnection\r\n"); if (CompareString(buffer, "ok", 2)) { //are the same FRTOS1_xSemaphoreGive(SuccessLedMutex); GetConState = Passed; } break; default: GetConState = Error; break; } FRTOS1_vTaskDelay( GET_CONNECTION_STATEMACHINE_DELAY_MS/portTICK_PERIOD_MS); } }
BOOL getDeviceInfo(const GUID* category, CMIDEV* pDev) { TCHAR szServiceName[128]; int nIndex = 0; pDev->Info = SetupDiGetClassDevs(category, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); if (pDev->Info == INVALID_HANDLE_VALUE) { PrintLastError("SetupDiGetClassDevs()"); return FALSE; } pDev->InfoData.cbSize = sizeof(SP_DEVINFO_DATA); while (SetupDiEnumDeviceInfo(pDev->Info, nIndex, &(pDev->InfoData))) { if (!SetupDiGetDeviceRegistryProperty(pDev->Info, &(pDev->InfoData), SPDRP_SERVICE, NULL, (PBYTE)szServiceName, sizeof(szServiceName), NULL)) { PrintLastError("SetupDiGetDeviceRegistryProperty()"); SetupDiDestroyDeviceInfoList(pDev->Info); pDev->Info = NULL; return FALSE; } if (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, szServiceName, -1, TEXT("cmipci"), -1) == CSTR_EQUAL) { return TRUE; } nIndex++; } SetupDiDestroyDeviceInfoList(pDev->Info); pDev->Info = NULL; return FALSE; }
int _RTLENTRY _EXPFUNC _mbsnbicoll( const unsigned char *__S1, const unsigned char *__S2, size_t n ) { int ret; ret = CompareString ( __locale->handle, NORM_IGNORECASE, (LPCTSTR)__S1, n, (LPCTSTR)__S2, n ); return (ret-2); }
UINT findWaveDeviceID() { WAVEOUTCAPS woc; UINT i, numDev; numDev = waveOutGetNumDevs(); for (i=0;i<numDev;i++) { if (!waveOutGetDevCaps(i, &woc, sizeof(WAVEOUTCAPS))) { if ((CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, woc.szPname, -1, TEXT("CMI8738/8768 Wave"), -1) == CSTR_EQUAL) || (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, woc.szPname, -1, TEXT("Speakers (CMI8738/8768 Audio De"), -1) == CSTR_EQUAL)) { return i; } } } return WAVE_MAPPER; }
STDMETHODIMP CImpIDispatch::GetIDsOfNames( /* [in] */ REFIID riid, /* [size_is][in] */ OLECHAR** rgszNames, /* [in] */ UINT cNames, /* [in] */ LCID lcid, /* [size_is][out] */ DISPID* rgDispId) { HRESULT hr; UINT i; // Assume some degree of success hr = NOERROR; // Hardcoded mapping for this sample // A more usual procedure would be to use a TypeInfo for ( i=0; i < cNames; i++) { if ( 2 == CompareString( lcid, NORM_IGNOREWIDTH, (wchar_t*)pszExtend, 3, (wchar_t*)rgszNames[i], 3 ) ) { rgDispId[i] = DISPID_Extend; } else { // One or more are unknown so set the return code accordingly hr = ResultFromScode(DISP_E_UNKNOWNNAME); rgDispId[i] = DISPID_UNKNOWN; } } return hr; }
static Boolean LGetSelectedCellCommon(ListHandle listH, Cell *listCell, GetListCellTextProcType getCellText, Boolean first) /* This function finds the alphabetically first or last cell (depending on the value of first) in the currently selected cells of the list. It returns false if there are no selected cells. */ { Boolean result; Str255 cellText; Str255 bestText; SInt16 indexOfBestText; assert(getCellText != NULL); // Establish some pre-conditions. result = false; listCell->h = 0; listCell->v = 0; indexOfBestText = 0; if (first) { bestText[0] = 0; bestText[1] = 255; bestText[2] = 255; } else { bestText[0] = 0; } // Loop through the selected cells, looking for the best text (ie the // alphabetically first or last). while ( LGetSelect(true, listCell, listH) ) { result = true; getCellText(listH, listCell, cellText); if ( (first && (CompareString(cellText, bestText, NULL) < 0)) || (!first && (CompareString(cellText, bestText, NULL) > 0)) ) { indexOfBestText = listCell->v; BlockMoveData(cellText, bestText, cellText[0] + 1); } listCell->v += 1; } // Finish up. listCell->h = 0; listCell->v = indexOfBestText; return result; }
int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2) { ClcCacheEntry *c1 = contact1->pce, *c2 = contact2->pce; for (int i = 0; i < _countof(g_CluiData.bSortByOrder); i++) { BYTE &by = g_CluiData.bSortByOrder[i]; if (by == SORTBY_STATUS) { //status int ordera = GetStatusModeOrdering(c1->getStatus()); int orderb = GetStatusModeOrdering(c2->getStatus()); if (ordera == orderb) continue; return ordera - orderb; } // one is offline: offline goes below online if (!g_CluiData.fSortNoOfflineBottom) { int statusa = c1->getStatus(); int statusb = c2->getStatus(); if ((statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE)) return 2 * (statusa == ID_STATUS_OFFLINE) - 1; } int r = 0; switch (by) { case SORTBY_NAME: // name r = mir_wstrcmpi(contact1->szText, contact2->szText); break; case SORTBY_NAME_LOCALE: // name if (LocaleId == -1) LocaleId = Langpack_GetDefaultLocale(); r = CompareString(LocaleId, NORM_IGNORECASE, SAFETSTRING(contact1->szText), -1, SAFETSTRING(contact2->szText), -1) - 2; break; case SORTBY_LASTMSG: // last message r = (int)CompareContacts2_getLMTime(contact2->hContact) - (int)CompareContacts2_getLMTime(contact1->hContact); break; case SORTBY_PROTO: if (contact1->proto == nullptr || contact2->proto == nullptr) continue; r = GetProtoIndex(contact1->proto) - GetProtoIndex(contact2->proto); break; case SORTBY_RATE: r = contact2->bContactRate - contact1->bContactRate; // reverse order break; default: // should never happen continue; } if (r != 0) return r; } return 0; }
bool GlobalSearchSortModel::lessThan(const QModelIndex& left, const QModelIndex& right) const { const SearchProvider::Result r1 = left.data(GlobalSearchWidget::Role_PrimaryResult) .value<SearchProvider::Result>(); const SearchProvider::Result r2 = right.data(GlobalSearchWidget::Role_PrimaryResult) .value<SearchProvider::Result>(); // Order results that arrived first first, so that the results don't jump // around while the user is trying to navigate through them. const int order_left = left.data(GlobalSearchWidget::Role_OrderArrived).toInt(); const int order_right = right.data(GlobalSearchWidget::Role_OrderArrived).toInt(); if (order_left < order_right) return true; if (order_left > order_right) return false; #define CompareInt(field) \ if (r1.field < r2.field) return true; \ if (r1.field > r2.field) return false int ret = 0; #define CompareString(field) \ ret = QString::localeAwareCompare(r1.metadata_.field(), r2.metadata_.field()); \ if (ret < 0) return true; \ if (ret > 0) return false // If they arrived at the same time then sort by quality and type. CompareInt(match_quality_); CompareInt(type_); // Failing that, compare title, artist and album switch (r1.type_) { case globalsearch::Type_Track: case globalsearch::Type_Stream: CompareString(title); // fallthrough case globalsearch::Type_Album: CompareString(artist); CompareString(album); break; } return false; #undef CompareInt #undef CompareString }
void CDistDatabaseReactor::DeleteLayerRowIdArray(const char* strCadLyName,const char *strSdeLyName,AcDbDatabase* pDB) { DIST_STRUCT_CHANGEROWID* pTemp = m_pRowIdData; int nID = int(pDB); while(pTemp != NULL) { if(nID == pTemp->nID && CompareString(strCadLyName,pTemp->strCadLyName)==0 && CompareString(strSdeLyName,pTemp->strSdeLyName)==0) { pTemp->RowIdArray.RemoveAll(); return; } pTemp = pTemp->pNext; } }
void CDistDatabaseReactor::InsertRowId(const char* strCadLyName,const char *strSdeLyName,int nRowId,AcDbDatabase* pDB) { if(nRowId < 0) return;//RowId值小于0,认为是新增实体,链表不会记录它们的改动 DIST_STRUCT_CHANGEROWID* pTemp = m_pRowIdData; DIST_STRUCT_CHANGEROWID* pTempPre = pTemp; int nID = int(pDB); while(pTemp != NULL) { if(nID == pTemp->nID && CompareString(strCadLyName,pTemp->strCadLyName)==0 && CompareString(strSdeLyName,pTemp->strSdeLyName)==0) { int nCount = pTemp->RowIdArray.GetSize(); bool bFound = false; for(int i=0; i<nCount; i++) { if(nRowId == pTemp->RowIdArray.GetAt(i)) { bFound = true; break; } } if(!bFound) pTemp->RowIdArray.Add(nRowId); return; } pTempPre = pTemp; pTemp = pTemp->pNext; } pTemp = new DIST_STRUCT_CHANGEROWID; strcpy(pTemp->strCadLyName,strCadLyName); strcpy(pTemp->strSdeLyName,strSdeLyName); pTemp->nID = nID; pTemp->pNext = NULL; pTemp->RowIdArray.Add(nRowId); if(m_pRowIdData == NULL) m_pRowIdData = pTemp; else pTempPre->pNext = pTemp; }
void CFilterDialogPersistentSettings::LoadExtraXMLSettings(BSTR bstrName,BSTR bstrValue) { if(CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, bstrName, lstrlen(SETTING_FILTER_LIST), SETTING_FILTER_LIST, lstrlen(SETTING_FILTER_LIST)) == CSTR_EQUAL) { m_FilterList.push_back(bstrValue); } }
long CDistDatabaseReactor::GetRowIdCount(const char* strCadLyName,const char *strSdeLyName,AcDbDatabase* pDB) { int nResult = 0; DIST_STRUCT_CHANGEROWID* pTemp = m_pRowIdData; int nID = int(pDB); while(pTemp != NULL) { if(nID == pTemp->nID && CompareString(strCadLyName,pTemp->strCadLyName)==0 && CompareString(strSdeLyName,pTemp->strSdeLyName)==0) { nResult= pTemp->RowIdArray.GetSize(); break; } pTemp = pTemp->pNext; } return nResult; }
bool GlobalSearchSortModel::lessThan(const QModelIndex& left, const QModelIndex& right) const { // Compare the provider sort index first. const int index_left = left.data(GlobalSearchModel::Role_ProviderIndex).toInt(); const int index_right = right.data(GlobalSearchModel::Role_ProviderIndex).toInt(); if (index_left < index_right) return true; if (index_left > index_right) return false; // Dividers always go first if (left.data(LibraryModel::Role_IsDivider).toBool()) return true; if (right.data(LibraryModel::Role_IsDivider).toBool()) return false; // Containers go before songs if they're at the same level const bool left_is_container = left.data(LibraryModel::Role_ContainerType).isValid(); const bool right_is_container = right.data(LibraryModel::Role_ContainerType).isValid(); if (left_is_container && !right_is_container) return true; if (right_is_container && !left_is_container) return false; // Containers get sorted on their sort text. if (left_is_container) { return QString::localeAwareCompare( left.data(LibraryModel::Role_SortText).toString(), right.data(LibraryModel::Role_SortText).toString()) < 0; } // Otherwise we're comparing songs. Sort by disc, track, then title. const SearchProvider::Result r1 = left.data(GlobalSearchModel::Role_Result).value<SearchProvider::Result>(); const SearchProvider::Result r2 = right.data(GlobalSearchModel::Role_Result) .value<SearchProvider::Result>(); #define CompareInt(field) \ if (r1.metadata_.field() < r2.metadata_.field()) return true; \ if (r1.metadata_.field() > r2.metadata_.field()) return false int ret = 0; #define CompareString(field) \ ret = \ QString::localeAwareCompare(r1.metadata_.field(), r2.metadata_.field()); \ if (ret < 0) return true; \ if (ret > 0) return false CompareInt(disc); CompareInt(track); CompareString(title); return false; #undef CompareInt #undef CompareString }
void CDxtexCommandLineInfo::ParseParam(const TCHAR* pszParam,BOOL bFlag,BOOL bLast) { DWORD lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT); if( CompareString( lcid, NORM_IGNORECASE, pszParam, -1, TEXT("DXT1"), -1 ) == CSTR_EQUAL ) { m_fmt = D3DFMT_DXT1; } else if( CompareString( lcid, NORM_IGNORECASE, pszParam, -1, TEXT("DXT2"), -1 ) == CSTR_EQUAL ) { m_fmt = D3DFMT_DXT2; } else if( CompareString( lcid, NORM_IGNORECASE, pszParam, -1, TEXT("DXT3"), -1 ) == CSTR_EQUAL ) { m_fmt = D3DFMT_DXT3; } else if( CompareString( lcid, NORM_IGNORECASE, pszParam, -1, TEXT("DXT4"), -1 ) == CSTR_EQUAL ) { m_fmt = D3DFMT_DXT4; } else if( CompareString( lcid, NORM_IGNORECASE, pszParam, -1, TEXT("DXT5"), -1 ) == CSTR_EQUAL ) { m_fmt = D3DFMT_DXT5; } else if (bFlag && tolower(pszParam[0]) == 'a') { m_bAlphaComing = TRUE; } else if (!bFlag && m_bAlphaComing) { m_strFileNameAlpha = pszParam; m_bAlphaComing = FALSE; } else if (bFlag && tolower(pszParam[0]) == 'm') { m_bMipMap = TRUE; } else if (!bFlag && !m_strFileName.IsEmpty()) { m_strFileNameSave = pszParam; } CCommandLineInfo::ParseParam(pszParam, bFlag, bLast); }
int CompareContacts2(const ClcContact *contact1, const ClcContact *contact2, int by) { TCHAR *namea, *nameb; int statusa, statusb; char *szProto1, *szProto2; if ((INT_PTR)contact1 < 100 || (INT_PTR)contact2 < 100) return 0; MCONTACT a = contact1->hContact; MCONTACT b = contact2->hContact; namea = (TCHAR *)contact1->szText; statusa = GetContactCachedStatus(contact1->hContact); szProto1 = contact1->proto; nameb = (TCHAR *)contact2->szText; statusb = GetContactCachedStatus(contact2->hContact); szProto2 = contact2->proto; if (by == SORTBY_STATUS) { //status int ordera, orderb; ordera = GetStatusModeOrdering(statusa); orderb = GetStatusModeOrdering(statusb); return (ordera != orderb) ? ordera - orderb : 0; } //one is offline: offline goes below online if (g_CluiData.fSortNoOfflineBottom == 0 && (statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE)) return 2 * (statusa == ID_STATUS_OFFLINE) - 1; if (by == SORTBY_NAME) //name return mir_tstrcmpi(namea, nameb); if (by == SORTBY_NAME_LOCALE) { //name static int LocaleId = -1; if (LocaleId == -1) LocaleId = Langpack_GetDefaultLocale(); return (CompareString(LocaleId, NORM_IGNORECASE, SAFETSTRING(namea), -1, SAFETSTRING(nameb), -1)) - 2; } if (by == SORTBY_LASTMSG) { //last message DWORD ta = CompareContacts2_getLMTime(a); DWORD tb = CompareContacts2_getLMTime(b); return tb - ta; } if (by == SORTBY_PROTO) { int rc = GetProtoIndex(szProto1) - GetProtoIndex(szProto2); if (rc != 0 && (szProto1 != NULL && szProto2 != NULL)) return rc; } else if (by == SORTBY_RATE) return contact2->bContactRate - contact1->bContactRate; // else :o) return 0; }
// CP-1251 // для сортированного массива эту операцию можно значительно ускорить, // но придется вводить дополнительный член класса (fSorted). // плюс если fSorted == true, то Insert делать сразу в нужную позицию. int FarStringArray::IndexOf( const char * item ) { far_assert( item != NULL ); int len = strlen( item ); for ( int i = 0; i < fCount; i++ ) { if ( CompareString( LOCALE_USER_DEFAULT, 0, At( i ), -1, item, len ) == CSTR_EQUAL ) return i; } return -1; }
//------------------------------------------------------------------- // Sort::CompareForMerge // // Input : Two tuples containint <record pointer, array index> // Output : None // Return : The comparison result //------------------------------------------------------------------- bool Sort::CompareForMerge(std::tuple<char *,int>& t1, std::tuple<char *,int>& t2) { switch (_sortType) { case attrInteger: return CompareInt(std::get<0>(t1),std::get<0>(t2))<0; break; case attrString: return CompareString(std::get<0>(t1),std::get<0>(t2))<0; default: break; } }
void CWildcardSelectDialogPersistentSettings::LoadExtraXMLSettings(BSTR bstrName,BSTR bstrValue) { if(CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, bstrName, lstrlen(SETTING_PATTERN_LIST), SETTING_PATTERN_LIST, lstrlen(SETTING_PATTERN_LIST)) == CSTR_EQUAL) { m_PatternList.push_back(bstrValue); } else if(lstrcmpi(bstrName, SETTING_CURRENT_TEXT) == 0) { StringCchCopy(m_szPattern,SIZEOF_ARRAY(m_szPattern),bstrValue); } }
int cmpstr( pubyte left, pubyte right, uint len ) { int ret; ret = CompareString( LOCALE_USER_DEFAULT, NORM_IGNORECASE, left, len, right, len ); if ( ret == CSTR_LESS_THAN ) return -1; if ( ret == CSTR_GREATER_THAN ) return 1; return 0; }
int tcsncmp(const tchar_t* a,const tchar_t* b,size_t n) { int i = CompareString(LOCALE_USER_DEFAULT,0,a,min(tcslen(a),n),b,min(tcslen(b),n)); if (i) return i-CSTR_EQUAL; // fallback #ifdef UNICODE return wcsncmp(a,b,n); #else return strncmp(a,b,n); #endif }