Leaked source code of windows server 2003
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.

97 lines
2.3 KiB

  1. // File: mrulist.h
  2. #ifndef _MRULIST2_H_
  3. #define _MRULIST2_H_
  4. #include "ConfUtil.h"
  5. #include "richaddr.h"
  6. typedef VOID * PMRUE; // MRU Entries
  7. enum {
  8. MRUTYPE_SZ = 1,
  9. MRUTYPE_DW = 2,
  10. };
  11. class CMRUList2
  12. {
  13. private:
  14. const DWSTR * m_prgDwStr;// {{cCol, pszKey}, {mruType, pszPrefix1}, {mruType, pszPrefix2},...}
  15. int m_cCol; // number of "columns" (data entries in m_prgDwStr)
  16. int m_cEntryMax; // maximum number of entries
  17. int m_cEntry; // current number of entries
  18. PMRUE * m_rgpEntry; // array of pointers to MRU data
  19. BOOL m_fDirty; // TRUE if data was changed
  20. BOOL m_fReversed; // Load/Save data reversed (old style)
  21. BOOL FValidCol(int i) {return ((i >= 0) && (i < m_cCol));}
  22. BOOL FValidIndex(int i) {return ((i >= 0) && (i < m_cEntry));}
  23. BOOL FDirty() {return m_fDirty;}
  24. BOOL FReversed() {return m_fReversed;}
  25. inline PMRUE GetEntry(int iItem)
  26. {
  27. ASSERT(FValidIndex(iItem));
  28. return m_rgpEntry[iItem];
  29. }
  30. inline int MruTypeForCol(int iCol)
  31. {
  32. ASSERT(FValidCol(iCol));
  33. return m_prgDwStr[1+iCol].dw;
  34. }
  35. inline LPCTSTR PszPrefixForCol(int iCol)
  36. {
  37. ASSERT(FValidCol(iCol));
  38. return m_prgDwStr[1+iCol].psz;
  39. }
  40. inline LPCTSTR PszRegKey(void)
  41. {
  42. return m_prgDwStr[0].psz;
  43. }
  44. VOID ShiftEntriesDown(int cItem);
  45. protected:
  46. virtual int CompareEntry(int iItem, PMRUE pEntry);
  47. public:
  48. CMRUList2(const DWSTR * prgDwStr, int cEntryMax, BOOL fReverse = FALSE);
  49. ~CMRUList2();
  50. int GetNumEntries() {return m_cEntry;}
  51. VOID SetDirty(BOOL fDirty) {m_fDirty = fDirty;}
  52. // Generic functions
  53. int FindEntry(PMRUE pEntry);
  54. VOID MoveEntryToTop(int iItem);
  55. PMRUE LoadEntry(RegEntry * pre, int iItem);
  56. VOID StoreEntry(RegEntry * pre, int iItem);
  57. VOID DeleteEntry(PMRUE pEntry);
  58. VOID DeleteEntry(int iItem);
  59. void
  60. DeleteEntry
  61. (
  62. const TCHAR * const primaryString
  63. );
  64. HRESULT Save(void);
  65. LPCTSTR GetString(int iItem, int iCol);
  66. DWORD GetDWORD(int iItem, int iCol);
  67. LPCTSTR GetString(PMRUE pEntry, int iCol);
  68. DWORD GetDWORD(PMRUE pEntry, int iCol);
  69. HRESULT AddEntry(PMRUE pEntry);
  70. HRESULT AddEntry(LPCTSTR pcsz);
  71. HRESULT AddEntry(LPCTSTR pcsz1, LPCTSTR pcsz2);
  72. HRESULT AddEntry(LPCTSTR pcsz1, LPCTSTR pcsz2, DWORD dw3);
  73. };
  74. #endif /* _MRULIST2_H_ */