From: boca4711 <boc...@us...> - 2005-10-16 12:21:28
|
Update of /cvsroot/anyedit/AnyEditv2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22599 Modified Files: Misc.cpp Misc.h Log Message: - Added SortStringArray to sort string arrays - Added GetGUID to create and return a GUID string Index: Misc.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/Misc.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Misc.cpp 8 May 2005 11:03:03 -0000 1.14 --- Misc.cpp 16 Oct 2005 12:21:19 -0000 1.15 *************** *** 43,46 **** --- 43,60 ---- #endif + static int Compare(const void *a, const void *b) + { + CString *pA = (CString*)a; + CString *pB = (CString*)b; + return (pA->Compare(*pB)); + } + + static int CompareNoCase(const void *a, const void *b) + { + CString *pA = (CString*)a; + CString *pB = (CString*)b; + return (pA->CompareNoCase(*pB)); + } + ////////////////////////////////////////////////////////////////////// // Construction/Destruction *************** *** 570,571 **** --- 584,627 ---- s++; } + + void CMisc::SortStringArray (CStringArray& csa, bool bCaseSensitive) + { + int iArraySize = csa.GetSize(); + if (iArraySize <= 0) + return; + + int iCSSize = sizeof (CString*); + void* pArrayStart = (void *)&csa[0]; + + if (bCaseSensitive) + qsort (pArrayStart, iArraySize, iCSSize, Compare); + else + qsort (pArrayStart, iArraySize, iCSSize, CompareNoCase); + } + + CString CMisc::GetGUID() + { + CString strGUID; + + GUID m_guid; + ::CoCreateGuid(&m_guid); + LPOLESTR wszCLSID = NULL; + StringFromCLSID(m_guid, &wszCLSID); + int nLen = lstrlenW(wszCLSID); + + TCHAR* szCLSID = new TCHAR[nLen + 1]; + + #ifndef _UNICODE + wcstombs(szCLSID, wszCLSID, nLen); + szCLSID[nLen] = 0; + #else + lstrcpy(szCLSID, wszCLSID); + #endif + + CoTaskMemFree(wszCLSID); + + strGUID = szCLSID; + delete szCLSID; + + return strGUID; + } Index: Misc.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/Misc.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Misc.h 12 Oct 2005 18:55:57 -0000 1.13 --- Misc.h 16 Oct 2005 12:21:19 -0000 1.14 *************** *** 39,42 **** --- 39,44 ---- { public: + CString GetGUID(); + void SortStringArray (CStringArray& csa, bool bCaseSensitive); void NormalizeString(char *s); BOOL ShortToLongPath(CString &sShortPath, CString &sLongPath); |