Ignore:
Timestamp:
Apr 14, 2011, 12:51:20 PM (14 years ago)
Author:
george
Message:
  • Modified: Unit UStreamHelper no longer define TThreadStreamHelper.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • CoolStreaming/UStreamHelper.pas

    r172 r233  
    66
    77uses
    8   Classes, DateUtils, syncobjs, UMicroThreading;
     8  Classes, DateUtils, syncobjs;
    99
    1010type
     
    1919    FEndianness: TEndianness;
    2020    SwapData: Boolean;
     21    function GetItem(Index: Integer): Byte;
    2122    procedure SetEndianness(const AValue: TEndianness);
     23    procedure SetItem(Index: Integer; const AValue: Byte);
    2224  public
    2325    procedure WriteByte(Data: Byte);
     
    5052    constructor Create; overload;
    5153    constructor Create(AStream: TStream); overload;
     54    procedure Clear;
    5255    destructor Destroy; override;
    5356    function GetSize: Int64; override;
     
    5861    property Endianness: TEndianness read FEndianness write SetEndianness;
    5962    property Stream: TStream read FStream write FStream;
    60   end;
    61 
    62   { TThreadStreamHelper }
    63 
    64   TThreadStreamHelper = class(TStreamHelper)
    65     Lock: TMicroThreadCriticalSection;
    66     procedure Clear;
    67     constructor Create;
    68     destructor Destroy; override;
     63    property Items[Index: Integer]: Byte read GetItem write SetItem; default;
    6964  end;
    7065
     
    195190end;
    196191
     192procedure TStreamHelper.Clear;
     193begin
     194  Stream.Size := 0;
     195end;
     196
    197197destructor TStreamHelper.Destroy;
    198198begin
     
    273273end;
    274274
     275function TStreamHelper.GetItem(Index: Integer): Byte;
     276begin
     277  Position := Index;
     278  Result := ReadByte;
     279end;
     280
     281procedure TStreamHelper.SetItem(Index: Integer; const AValue: Byte);
     282begin
     283 Position := Index;
     284 WriteByte(AValue);
     285end;
     286
    275287procedure TStreamHelper.WriteAnsiString(Data: string);
    276288var
     
    348360end;
    349361
    350 { TThreadStreamHelper }
    351 
    352 procedure TThreadStreamHelper.Clear;
    353 begin
    354   try
    355     Lock.Acquire;
    356     Size := 0;
    357   finally
    358     Lock.Release;
    359   end;
    360 end;
    361 
    362 constructor TThreadStreamHelper.Create;
    363 begin
    364   inherited Create;
    365   Lock := TMicroThreadCriticalSection.Create;
    366 end;
    367 
    368 destructor TThreadStreamHelper.Destroy;
    369 begin
    370   Lock.Free;
    371   inherited Destroy;
    372 end;
    373362
    374363end.
Note: See TracChangeset for help on using the changeset viewer.