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.

98 lines
2.8 KiB

  1. // -------------------------------------------------------------------------------
  2. // Created by RogerJ, October 4th, 2000
  3. // This header file declares two classes that are closely linked to each other. These
  4. // two classes provided a convenient way to construct, add, and remove a multi-sz list
  5. // array.
  6. #ifndef _WINDOWS_UPDATE_MULTI_SZ_LIST_BY_ROGERJ
  7. #define _WINDOWS_UPDATE_MULTI_SZ_LIST_BY_ROGERJ
  8. struct PosIndex
  9. {
  10. PosIndex() { x = y = -1;};
  11. int x;
  12. int y;
  13. inline BOOL operator < (PosIndex& other) { return (x<other.x) || ((x==other.x) && (y<other.y));};
  14. inline BOOL operator > (PosIndex& other) { return (x>other.x) || ((x==other.x) && (y>other.y));};
  15. inline BOOL operator == (PosIndex& other) { return (x==other.x) && (y==other.y);};
  16. };
  17. // forward declaration
  18. class CMultiSZArray;
  19. class CMultiSZString
  20. {
  21. public:
  22. // default constructor
  23. CMultiSZString();
  24. CMultiSZString (LPCTSTR pszHardwareId, int nSize = -1);
  25. // copy constructor
  26. CMultiSZString (CMultiSZString& CopyInfo);
  27. // destructor
  28. ~CMultiSZString (void);
  29. // member functions
  30. BOOL ToString(LPTSTR pszBuffer, int* pnBufferLen);
  31. BOOL Compare(CMultiSZString& CompareString);
  32. BOOL CompareNoCase (CMultiSZString& CompareString);
  33. inline BOOL operator == (CMultiSZString& CompareString) { return Compare(CompareString);};
  34. inline void ResetIndex(void) { m_nIndex = 0; };
  35. LPCTSTR GetNextString(void);
  36. BOOL Contains(LPCTSTR pszIn);
  37. BOOL ContainsNoCase (LPCTSTR pszIn);
  38. BOOL PositionIndex(LPCTSTR pszIn, int* pPosition);
  39. inline void CheckFound(void) { m_bFound = TRUE;};
  40. inline BOOL IsFound(void) { return m_bFound; };
  41. // friend class
  42. friend class CMultiSZArray;
  43. private:
  44. // member variables
  45. LPTSTR m_szHardwareId;
  46. int m_nSize;
  47. int m_nStringCount;
  48. int m_nIndex;
  49. BOOL m_bFound;
  50. // linking pointers
  51. CMultiSZString* prev;
  52. CMultiSZString* next;
  53. };
  54. class CMultiSZArray
  55. {
  56. public:
  57. // default constructor
  58. CMultiSZArray();
  59. // other constructors
  60. CMultiSZArray(CMultiSZString* pInfo);
  61. CMultiSZArray(LPCTSTR pszHardwareId, int nSize = -1);
  62. // destructor
  63. ~CMultiSZArray(void);
  64. // operations
  65. BOOL RemoveAll(void);
  66. BOOL Add(CMultiSZString* pInfo);
  67. BOOL Add(LPCSTR pszHardwareId, int nSize = -1);
  68. inline BOOL Remove(CMultiSZString* pInfo) { return Remove(pInfo->m_szHardwareId);};
  69. inline BOOL Remove(CMultiSZString& Info) { return Remove(Info.m_szHardwareId);};
  70. BOOL Remove(LPCTSTR pszHardwareId);
  71. inline int GetCount(void) { return m_nCount;};
  72. BOOL ToString (LPTSTR pszBuffer, int* pnBufferLen);
  73. int GetTotalStringCount(void);
  74. inline void ResetIndex() { m_pIndex = m_pHead; };
  75. CMultiSZString* GetNextMultiSZString(void);
  76. BOOL Contains(LPCTSTR pszIn);
  77. BOOL ContainsNoCase (LPCTSTR pszIn);
  78. BOOL PositionIndex(LPCTSTR pszIn, PosIndex* pPosition);
  79. BOOL CheckFound(int nIndex);
  80. private:
  81. // member vairables
  82. CMultiSZString* m_pHead;
  83. CMultiSZString* m_pTail;
  84. int m_nCount;
  85. CMultiSZString* m_pIndex;
  86. };
  87. #endif