Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.16 KB | None | 0 0
  1. type
  2.   TDynDwordArray = array of DWORD;
  3.   TDynTwoDimensionalDwordArray = array of TDynDwordArray;
  4.  
  5.   TDwMsStream = class(TMemoryStream)
  6.   public
  7.     procedure WriteTwoDimensionalDwordArray(const Data: TDynTwoDimensionalDwordArray);
  8.     procedure ReadTwoDimensionalDwordArray(out Data: TDynTwoDimensionalDwordArray);
  9.   end;
  10.  
  11. { TDwMsStream }
  12.  
  13. procedure TDwMsStream.ReadTwoDimensionalDwordArray(
  14.   out Data: TDynTwoDimensionalDwordArray);
  15. var
  16.   i: integer;
  17.   tmp: Cardinal;
  18. begin
  19.   ReadBuffer(tmp, sizeof(Cardinal));
  20.   SetLength(Data, tmp);
  21.   for i := 0 to length(Data) do
  22.     begin
  23.       ReadBuffer(tmp, sizeof(Cardinal));
  24.       SetLength(Data[i], tmp);
  25.       if tmp > 0 then
  26.         ReadBuffer(Data[i], tmp * sizeof(DWORD));
  27.     end;
  28. end;
  29.  
  30. procedure TDwMsStream.WriteTwoDimensionalDwordArray(
  31.   const Data: TDynTwoDimensionalDwordArray);
  32. var
  33.   i: integer;
  34.   tmp: Cardinal;
  35. begin
  36.   tmp := Length(Data);
  37.   WriteBuffer(tmp, sizeof(Cardinal));
  38.   for i := 0 to length(Data) do
  39.     begin
  40.       tmp := Length(Data[i]);
  41.       WriteBuffer(tmp, sizeof(Cardinal));
  42.       if tmp > 0 then
  43.         WriteBuffer(Data[i], tmp * sizeof(DWORD));
  44.     end;
  45. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement