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.

75 lines
1.8 KiB

  1. #ifndef _INC_FLDRCLNR_DBLNUL_H
  2. #define _INC_FLDRCLNR_DBLNUL_H
  3. //
  4. // For iterating over items in a double-nul terminated list of
  5. // text strings.
  6. //
  7. class DblNulTermListIter
  8. {
  9. public:
  10. explicit DblNulTermListIter(LPCTSTR pszList)
  11. : m_pszList(pszList),
  12. m_pszCurrent(pszList) { }
  13. ~DblNulTermListIter(void) { }
  14. BOOL Next(LPCTSTR *ppszItem);
  15. void Reset(void)
  16. { m_pszCurrent = m_pszList; }
  17. private:
  18. LPCTSTR m_pszList;
  19. LPCTSTR m_pszCurrent;
  20. };
  21. class DblNulTermList
  22. {
  23. public:
  24. explicit DblNulTermList(int cchGrow = MAX_PATH)
  25. : m_psz(NULL),
  26. m_cchAlloc(0),
  27. m_cchUsed(0),
  28. m_cStrings(0),
  29. m_cchGrow(cchGrow) { }
  30. ~DblNulTermList(void)
  31. { LocalFree(m_psz); }
  32. BOOL AddString(LPCTSTR psz)
  33. { return AddString(psz, psz ? lstrlen(psz) : 0); }
  34. int Count(void) const
  35. { return m_cStrings; }
  36. operator LPCTSTR ()
  37. { return m_psz; }
  38. DblNulTermListIter CreateIterator(void) const
  39. { return DblNulTermListIter(m_psz); }
  40. #if DBG
  41. void Dump(void) const;
  42. #endif
  43. private:
  44. LPTSTR m_psz; // The text buffer.
  45. int m_cchAlloc; // Total allocation in chars.
  46. int m_cchUsed; // Total used excluding FINAL nul term.
  47. int m_cchGrow; // How much to grow each expansion.
  48. int m_cStrings; // Count of strings in list.
  49. BOOL AddString(LPCTSTR psz, int cch);
  50. BOOL Grow(void);
  51. //
  52. // Prevent copy.
  53. //
  54. DblNulTermList(const DblNulTermList& rhs);
  55. DblNulTermList& operator = (const DblNulTermList& rhs);
  56. };
  57. #endif // INC_FLDRCLNR_DBLNUL_H