Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
2.5 KiB

  1. /******************************************************************************
  2. Header File: string.h
  3. This defines our locally-owned version of a string class. I swear this has
  4. to be the 5th or 6h time I've done one, but each time someone else owns the
  5. code, so here we go again...
  6. Copyright (c) 1997 by Microsoft Corporation. All Rights Reserved.
  7. Change History:
  8. 01-08-97 Bob Kjelgaard
  9. 01-30-97 Bob Kjelgaard Added features to aid port extraction for plug and play.
  10. 07-05-97 Tim Wells Ported to NT
  11. ******************************************************************************/
  12. #if !defined(COSMIC_STRINGS)
  13. #define COSMIC_STRINGS
  14. class CString {
  15. LPTSTR m_lpstr;
  16. public:
  17. void Empty() {
  18. if (m_lpstr) {
  19. delete m_lpstr;
  20. }
  21. m_lpstr = NULL;
  22. }
  23. CString() {
  24. m_lpstr = NULL;
  25. }
  26. ~CString() {
  27. Empty();
  28. }
  29. CString(LPCTSTR lpstrRef);
  30. CString(const CString& csRef);
  31. BOOL IsEmpty() const { return !m_lpstr || !*m_lpstr; }
  32. const CString& operator =(const CString& csRef);
  33. const CString& operator =(LPCTSTR lpstrRef);
  34. operator LPCTSTR() const { return m_lpstr; }
  35. operator LPTSTR() { return m_lpstr; }
  36. void GetContents(HWND hwnd); // Get Window Text
  37. void FromTable(unsigned uid); // Load from resource
  38. void Load(ATOM at, BOOL bGlobal = TRUE); // Load from atom
  39. void Load(HINF hInf = INVALID_HANDLE_VALUE,
  40. LPCTSTR lpstrSection = NULL,
  41. LPCTSTR lpstrKeyword = NULL,
  42. DWORD dwFieldIndex = 1,
  43. LPCTSTR lpstrDefault = NULL);
  44. void Load(HKEY hk, LPCTSTR lpstrKeyword);
  45. void MakeSystemPath (LPCTSTR lpstrFilename);
  46. void Store(HKEY hk, LPCTSTR lpstrKey, LPCTSTR lpstrType = NULL);
  47. DWORD Decode();
  48. friend CString operator + (const CString& cs1, const CString& cs2);
  49. friend CString operator + (const CString& cs1, LPCTSTR lpstr2);
  50. friend CString operator + (LPCTSTR lpstr1,const CString& cs2);
  51. };
  52. class CStringArray {
  53. unsigned m_ucItems, m_ucMax, m_uGrowBy;
  54. CString *m_pcsContents, m_csEmpty;
  55. public:
  56. CStringArray(unsigned m_uGrowby = 10);
  57. ~CStringArray();
  58. void CStringArray::Cleanup();
  59. unsigned Count() const { return m_ucItems; }
  60. void Add(LPCTSTR lpstr);
  61. CString& operator[](unsigned u);
  62. // Split a string into an array, using a defined separator
  63. void Tokenize(LPTSTR lpstr, TCHAR cSeparator);
  64. };
  65. #endif