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.

129 lines
4.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1991 **/
  4. /**********************************************************************/
  5. /*
  6. strlst.hxx
  7. String list class: definition
  8. class STRLIST: handles a list of strings. useful when API return
  9. a list of string values separated by certain
  10. characters. we can convert this to a STRLIST which
  11. is then our canonical form and use ITER_STRLIST
  12. below iterate over the STRLIST. Derived using the
  13. collection class (SLIST).
  14. class ITER_STRLIST: used to iterate over the STRLIST above.
  15. FILE HISTORY:
  16. chuckc 1-Jan-1991 Added STRLIST.
  17. terryk 11-Jul-1991 Add the fDestroy parameter in the
  18. constructors
  19. KeithMo 23-Oct-1991 Added forward references.
  20. beng 17-Jun-1992 Removed the single-string ctors
  21. */
  22. #ifndef _STRLST_HXX_
  23. #define _STRLST_HXX_
  24. #include "string.hxx"
  25. #include "slist.hxx"
  26. //
  27. // Forward references.
  28. //
  29. DLL_CLASS STRLIST;
  30. DLL_CLASS ITER_STRLIST;
  31. DECL_SLIST_OF(NLS_STR,DLL_BASED);
  32. /*************************************************************************
  33. NAME: STRLIST
  34. SYNOPSIS: String list object, used in conjunction with NLS_STR
  35. and ITER_STRLIST.
  36. INTERFACE:
  37. STRLIST() - ctor
  38. ~STRLIST() - dtor
  39. WriteToBuffer()
  40. Writes the contents of STRLIST to PSZ format,
  41. using separators specified by pszSep.
  42. QueryBufferSize()
  43. Query the number of bytes required by WriteToBuffer()
  44. USES: NLS_STR
  45. CAVEATS:
  46. The fDestroy variable in the constructor is used as a
  47. flag to indicate whether the caller wants to let the
  48. class destructor to destroy the list elements or the
  49. caller will do it himself. The default value is TRUE -
  50. the class will do the memory free.
  51. HISTORY:
  52. chuckc 03-Jan-1991 Created
  53. beng 26-Apr-1991 Replaced CB with INT
  54. terryk 15-Jul-1991 Add the fDestroy parameter to the ctor
  55. such that the destructor will not try
  56. to delete the element at dtor time.
  57. beng 17-Jun-1992 Removed single string ctors
  58. **************************************************************************/
  59. DLL_CLASS STRLIST: public SLIST_OF(NLS_STR)
  60. {
  61. friend class ITER_STRLIST;
  62. public:
  63. STRLIST( BOOL fDestroy = TRUE );
  64. STRLIST(const TCHAR * pszSrc, const TCHAR * pszSep, BOOL fDestroy = TRUE);
  65. STRLIST(const NLS_STR & nlsSrc, const NLS_STR & nlsSep, BOOL fDestroy = TRUE );
  66. ~STRLIST();
  67. INT WriteToBuffer( TCHAR * pszDest, INT cbDest, TCHAR *pszSep );
  68. INT QueryBufferSize( TCHAR *pszSep );
  69. private:
  70. VOID CreateList(const TCHAR * pszSrc, const TCHAR * pszSep);
  71. };
  72. /*************************************************************************
  73. NAME: ITER_STRLIST
  74. SYNOPSIS: String list iterator, used in conjunction with NLS_STR
  75. and STRLIST.
  76. INTERFACE:
  77. ITER_STRLIST( )
  78. Declare an iterator using strl.
  79. ITER_STRLIST( )
  80. Declare an iterator using an existing iterator.
  81. ~ITER_STRLIST()
  82. Destructor
  83. (also see ITER_SL, since we inherit all its public members)
  84. HISTORY:
  85. chuckc 03-Jan-1991 Created
  86. **************************************************************************/
  87. DLL_CLASS ITER_STRLIST: public ITER_SL_OF(NLS_STR)
  88. {
  89. public:
  90. ITER_STRLIST( STRLIST & strl );
  91. ITER_STRLIST( const ITER_STRLIST & iter_strl );
  92. ~ITER_STRLIST();
  93. };
  94. #endif // _STRLST_HXX_