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.

123 lines
3.2 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1991 - 1992.
  5. //
  6. // File: keyarray.hxx
  7. //
  8. // Contents: Key Array Class
  9. //
  10. // Classes: CKeyArray
  11. //
  12. // WARNING: CKeyArray is in CSynRestriction, which is not unwindable,
  13. // so don't make CKeyArray unwindable
  14. //
  15. // History: 30-Jan-92 AmyA Created
  16. // 14-Nov-95 dlee added fThrow bother
  17. //
  18. //----------------------------------------------------------------------------
  19. #pragma once
  20. #ifdef DISPLAY_INCLUDES
  21. #pragma message( "#include <" __FILE__ ">..." )
  22. #endif
  23. class CKey;
  24. class CKeyBuf;
  25. //+---------------------------------------------------------------------------
  26. //
  27. // Class: CKeyArray
  28. //
  29. // Purpose: Class for the management of an array of CKeys.
  30. //
  31. // Interface:
  32. //
  33. // History: 30-Jan-92 AmyA Created
  34. // 15-Apr-92 BartoszM Re-implemented
  35. //
  36. //----------------------------------------------------------------------------
  37. class CKeyArray
  38. {
  39. public:
  40. CKeyArray( int size, BOOL fThrow = TRUE );
  41. CKeyArray( const CKeyArray& keyArray, BOOL fThrow = TRUE );
  42. ~CKeyArray();
  43. int Count() const { return _count; }
  44. BOOL Add (const CKey& Key);
  45. BOOL Add (const CKeyBuf& Key);
  46. BOOL Add (int pos, const CKeyBuf& keyBuf);
  47. BOOL Add (int pos, const CKey& key);
  48. void Delete (int pos );
  49. void Transfer(int dest, int source);
  50. BOOL FillMax ( int pos );
  51. CKey& Get (int position) const;
  52. int TotalKeySize() const;
  53. BOOL IsValid() const { return 0 != _aKey; }
  54. //
  55. // Serialization
  56. //
  57. void Marshall( PSerStream & stm ) const;
  58. CKeyArray( PDeSerStream & stm, BOOL fThrow = TRUE );
  59. #ifdef CIEXTMODE
  60. void CiExtDump(void *ciExtSelf);
  61. #endif
  62. private:
  63. void _Grow(int pos);
  64. void _Add( const CKey& Key );
  65. void _Add( const CKeyBuf& Key );
  66. void _Add( int pos, const CKeyBuf& keyBuf );
  67. void _Add( int pos, const CKey& key );
  68. void _FillMax ( int pos );
  69. #if CIDBG == 1
  70. void Display() {}
  71. #endif // CIDBG == 1
  72. CKey* _aKey;
  73. int _count;
  74. int _size;
  75. BOOL _fThrow;
  76. };
  77. //+---------------------------------------------------------------------------
  78. //
  79. // Member: CKeyArray::Get, public
  80. //
  81. // Synopsis: Get access to key at given position
  82. //
  83. // Arguments: [pos] -- position in array
  84. //
  85. // History: 16-Apr-92 BartoszM Created.
  86. //
  87. //----------------------------------------------------------------------------
  88. inline CKey& CKeyArray::Get(int position) const
  89. {
  90. Win4Assert(position < _size);
  91. return _aKey[position];
  92. }
  93. //+---------------------------------------------------------------------------
  94. //----------------------------------------------------------------------------
  95. inline void CKeyArray::Transfer(int dest, int source)
  96. {
  97. Win4Assert(dest < _size);
  98. Win4Assert(source < _size);
  99. _aKey[dest].Acquire( _aKey[source] );
  100. }
  101. //+---------------------------------------------------------------------------
  102. //----------------------------------------------------------------------------
  103. inline void CKeyArray::Delete(int position)
  104. {
  105. Win4Assert(position < _size);
  106. _aKey[position].Free();
  107. }