Ignore:
Timestamp:
Oct 9, 2009, 1:44:09 PM (15 years ago)
Author:
george
Message:
  • Přidáno: Generování hlavičky položek se značkou Tag a Wire typem.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ProtocolBuffers/UMainForm.pas

    r5 r6  
    11unit UMainForm;
    22
    3 {$mode objfpc}{$H+}
     3{$mode delphi}{$H+}
    44
    55interface
    66
    77uses
    8   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs;
     8  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
     9  StdCtrls, UProtocolBuffers, UMemoryStreamEx;
    910
    1011type
     12  { TMainForm }
    1113  TMainForm = class(TForm)
     14    Memo1: TMemo;
     15    procedure FormCreate(Sender: TObject);
     16    procedure FormDestroy(Sender: TObject);
    1217  private
    1318    { private declarations }
    1419  public
    15     { public declarations }
     20    PB: TProtocolBuffer;
    1621  end;
    1722
     
    2126implementation
    2227
     28{ TMainForm }
     29
     30procedure TMainForm.FormCreate(Sender: TObject);
     31var
     32  Stream: TMemoryStreamEx;
     33  Text: string;
     34  I: Integer;
     35begin
     36  Stream := TMemoryStreamEx.Create;
     37  PB := TProtocolBuffer.Create;
     38  with PB do begin
     39    BaseMessage := TPBMessage.Create;
     40    BaseMessage.Name := 'SampleMessage';
     41    BaseMessage.Tag := $aaaa;
     42    SaveToStream(Stream);
     43  end;
     44
     45  Stream.Position := 0;
     46  Text := '';
     47  for I := 1 to Stream.Size do begin
     48    Text := Text + IntToHex(Stream.ReadByte, 2) + ' ';
     49  end;
     50  Memo1.Lines.Text := Text;
     51  Stream.Free;
     52end;
     53
     54procedure TMainForm.FormDestroy(Sender: TObject);
     55begin
     56  PB.Free;
     57end;
     58
    2359initialization
    2460  {$I UMainForm.lrs}
Note: See TracChangeset for help on using the changeset viewer.