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.

100 lines
1.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: N C S T L . H
  7. //
  8. // Contents: STL utilities.
  9. //
  10. // Notes: Pollute this under penalty of death.
  11. //
  12. // Author: shaunco 09 Oct 1997
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #ifndef _NCSTL_H_
  17. #define _NCSTL_H_
  18. #include "ncstlstr.h" // CWideString
  19. #include "stllist.h" // list
  20. #include "stlvec.h" // vector
  21. using namespace std;
  22. typedef CWideString tstring;
  23. typedef list<tstring*> ListStrings;
  24. //+--------------------------------------------------------------------------
  25. //
  26. // Funct: DumpListStrings
  27. //
  28. // Desc: debug utility function to dump out the given list
  29. //
  30. // Args:
  31. //
  32. // Return: (void)
  33. //
  34. // Notes:
  35. //
  36. // History: 1-Dec-97 SumitC Created
  37. //
  38. //---------------------------------------------------------------------------
  39. inline
  40. PCWSTR
  41. DumpListStrings(
  42. IN const list<tstring *>& lstr,
  43. OUT tstring* pstrOut)
  44. {
  45. WCHAR szBuf [1024];
  46. INT i;
  47. list<tstring *>::const_iterator iter;
  48. pstrOut->erase();
  49. for (iter = lstr.begin(), i = 1;
  50. iter != lstr.end();
  51. iter++, i++)
  52. {
  53. wsprintfW(szBuf, L" %2i: %s\n", i, (*iter)->c_str());
  54. pstrOut->append(szBuf);
  55. }
  56. return pstrOut->c_str();
  57. }
  58. template<class T>
  59. void
  60. FreeCollectionAndItem (
  61. T& col)
  62. {
  63. for(T::iterator iter = col.begin(); iter != col.end(); ++iter)
  64. {
  65. T::value_type pElem = *iter;
  66. delete pElem;
  67. }
  68. col.erase (col.begin(), col.end());
  69. }
  70. template<class T>
  71. void
  72. FreeVectorItem (
  73. vector<T>& v,
  74. UINT i)
  75. {
  76. if ((v.size()>0) && (i<v.size()))
  77. {
  78. delete v[i];
  79. vector<T>::iterator iterItem = v.begin() + i;
  80. v.erase (iterItem);
  81. }
  82. }
  83. #endif // _NCSTL_H_