Changeset 173


Ignore:
Timestamp:
Feb 23, 2011, 7:42:22 AM (13 years ago)
Author:
george
Message:
  • Added: Demo of indexed varblock structure.
Location:
CoolStreaming
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • CoolStreaming/Demo/VarBlockSerializer/UMainForm.lfm

    r172 r173  
    11object MainForm: TMainForm
    22  Left = 263
    3   Height = 466
     3  Height = 405
    44  Top = 119
    5   Width = 631
     5  Width = 644
    66  Caption = 'VarBlockSerializer demo'
    7   ClientHeight = 466
    8   ClientWidth = 631
     7  ClientHeight = 405
     8  ClientWidth = 644
     9  OnShow = FormShow
    910  LCLVersion = '0.9.31'
    10   object GroupBox1: TGroupBox
     11  object PageControl1: TPageControl
    1112    Left = 8
    12     Height = 64
     13    Height = 392
    1314    Top = 8
    14     Width = 608
    15     Caption = 'Unsigned integer (UInt)'
    16     ClientHeight = 46
    17     ClientWidth = 604
     15    Width = 632
     16    ActivePage = TabSheet2
     17    TabIndex = 1
    1818    TabOrder = 0
    19     object SpinEditUInt: TSpinEdit
    20       Left = 6
    21       Height = 21
    22       Top = 8
    23       Width = 152
    24       MaxValue = 1000000000
    25       TabOrder = 0
    26       Value = 1
     19    object TabSheet1: TTabSheet
     20      Caption = 'Simple types'
     21      ClientHeight = 366
     22      ClientWidth = 624
     23      object GroupBox1: TGroupBox
     24        Left = 8
     25        Height = 64
     26        Top = 8
     27        Width = 608
     28        Caption = 'Unsigned integer (UInt)'
     29        ClientHeight = 46
     30        ClientWidth = 604
     31        TabOrder = 0
     32        object SpinEditUInt: TSpinEdit
     33          Left = 6
     34          Height = 21
     35          Top = 8
     36          Width = 152
     37          MaxValue = 1000000000
     38          TabOrder = 0
     39          Value = 1
     40        end
     41        object ButtonUIntEncode: TButton
     42          Left = 246
     43          Height = 25
     44          Top = 8
     45          Width = 75
     46          Caption = 'Encode >>'
     47          OnClick = ButtonUIntEncodeClick
     48          TabOrder = 1
     49        end
     50        object EditUInt: TEdit
     51          Left = 326
     52          Height = 21
     53          Top = 8
     54          Width = 269
     55          TabOrder = 2
     56          Text = '00'
     57        end
     58        object ButtonUIntDecode: TButton
     59          Left = 166
     60          Height = 25
     61          Top = 8
     62          Width = 75
     63          Caption = '<< Decode'
     64          OnClick = ButtonUIntDecodeClick
     65          TabOrder = 3
     66        end
     67      end
     68      object GroupBox2: TGroupBox
     69        Left = 8
     70        Height = 64
     71        Top = 80
     72        Width = 608
     73        Caption = 'Signed integer (SInt)'
     74        ClientHeight = 46
     75        ClientWidth = 604
     76        TabOrder = 1
     77        object SpinEditSInt: TSpinEdit
     78          Left = 6
     79          Height = 21
     80          Top = 8
     81          Width = 152
     82          MaxValue = 1000000000
     83          MinValue = -1000000000
     84          TabOrder = 0
     85          Value = -1
     86        end
     87        object ButtonSIntEncode: TButton
     88          Left = 246
     89          Height = 25
     90          Top = 8
     91          Width = 75
     92          Caption = 'Encode >>'
     93          OnClick = ButtonSIntEncodeClick
     94          TabOrder = 1
     95        end
     96        object EditSInt: TEdit
     97          Left = 326
     98          Height = 21
     99          Top = 8
     100          Width = 269
     101          TabOrder = 2
     102          Text = '00'
     103        end
     104        object ButtonSIntDecode: TButton
     105          Left = 166
     106          Height = 25
     107          Top = 8
     108          Width = 75
     109          Caption = '<< Decode'
     110          OnClick = ButtonSIntDecodeClick
     111          TabOrder = 3
     112        end
     113      end
     114      object GroupBox3: TGroupBox
     115        Left = 8
     116        Height = 64
     117        Top = 152
     118        Width = 608
     119        Caption = 'String'
     120        ClientHeight = 46
     121        ClientWidth = 604
     122        TabOrder = 2
     123        object ButtonEncodeString: TButton
     124          Left = 246
     125          Height = 25
     126          Top = 8
     127          Width = 75
     128          Caption = 'Encode >>'
     129          OnClick = ButtonEncodeStringClick
     130          TabOrder = 0
     131        end
     132        object EditStringData: TEdit
     133          Left = 326
     134          Height = 21
     135          Top = 8
     136          Width = 269
     137          TabOrder = 1
     138          Text = '00'
     139        end
     140        object ButtonDecodeString: TButton
     141          Left = 166
     142          Height = 25
     143          Top = 8
     144          Width = 75
     145          Caption = '<< Decode'
     146          OnClick = ButtonDecodeStringClick
     147          TabOrder = 2
     148        end
     149        object EditString: TEdit
     150          Left = 6
     151          Height = 21
     152          Top = 8
     153          Width = 152
     154          TabOrder = 3
     155          Text = 'Hello world'
     156        end
     157      end
     158      object GroupBox4: TGroupBox
     159        Left = 8
     160        Height = 64
     161        Top = 224
     162        Width = 608
     163        Caption = 'Raw data (Block)'
     164        ClientHeight = 46
     165        ClientWidth = 604
     166        TabOrder = 3
     167        object ButtonEncodeRaw: TButton
     168          Left = 246
     169          Height = 25
     170          Top = 8
     171          Width = 75
     172          Caption = 'Encode >>'
     173          OnClick = ButtonEncodeRawClick
     174          TabOrder = 0
     175        end
     176        object EditRawData: TEdit
     177          Left = 326
     178          Height = 21
     179          Top = 8
     180          Width = 269
     181          TabOrder = 1
     182          Text = '00'
     183        end
     184        object ButtonDecodeRaw: TButton
     185          Left = 166
     186          Height = 25
     187          Top = 8
     188          Width = 75
     189          Caption = '<< Decode'
     190          OnClick = ButtonDecodeRawClick
     191          TabOrder = 2
     192        end
     193        object EditRaw: TEdit
     194          Left = 6
     195          Height = 21
     196          Top = 8
     197          Width = 152
     198          TabOrder = 3
     199          Text = '01 23 45 67 89 AB CD EF'
     200        end
     201      end
     202      object GroupBox5: TGroupBox
     203        Left = 8
     204        Height = 64
     205        Top = 296
     206        Width = 608
     207        Caption = 'Float'
     208        ClientHeight = 46
     209        ClientWidth = 604
     210        TabOrder = 4
     211        object ButtonFloatEncode1: TButton
     212          Left = 246
     213          Height = 25
     214          Top = 8
     215          Width = 75
     216          Caption = 'Encode >>'
     217          OnClick = ButtonFloatEncode1Click
     218          TabOrder = 0
     219        end
     220        object EditFloat: TEdit
     221          Left = 326
     222          Height = 21
     223          Top = 8
     224          Width = 269
     225          TabOrder = 1
     226          Text = '00'
     227        end
     228        object ButtonFloatDecode1: TButton
     229          Left = 166
     230          Height = 25
     231          Top = 7
     232          Width = 75
     233          Caption = '<< Decode'
     234          OnClick = ButtonFloatDecode1Click
     235          TabOrder = 2
     236        end
     237        object FloatSpinEdit1: TFloatSpinEdit
     238          Left = 6
     239          Height = 21
     240          Top = 7
     241          Width = 96
     242          DecimalPlaces = 8
     243          Increment = 1
     244          MaxValue = 1000000000
     245          MinValue = -100000000
     246          TabOrder = 3
     247          Value = 0
     248        end
     249        object SpinEditFloat: TSpinEdit
     250          Left = 110
     251          Height = 21
     252          Top = 16
     253          Width = 50
     254          MaxValue = 16
     255          MinValue = 2
     256          TabOrder = 4
     257          Value = 2
     258        end
     259        object Label1: TLabel
     260          Left = 111
     261          Height = 14
     262          Top = 0
     263          Width = 24
     264          Caption = 'Base'
     265          ParentColor = False
     266        end
     267      end
    27268    end
    28     object ButtonUIntEncode: TButton
    29       Left = 246
    30       Height = 25
    31       Top = 8
    32       Width = 75
    33       Caption = 'Encode >>'
    34       OnClick = ButtonUIntEncodeClick
    35       TabOrder = 1
    36     end
    37     object EditUInt: TEdit
    38       Left = 326
    39       Height = 21
    40       Top = 8
    41       Width = 269
    42       TabOrder = 2
    43       Text = '00'
    44     end
    45     object ButtonUIntDecode: TButton
    46       Left = 166
    47       Height = 25
    48       Top = 8
    49       Width = 75
    50       Caption = '<< Decode'
    51       OnClick = ButtonUIntDecodeClick
    52       TabOrder = 3
    53     end
    54   end
    55   object GroupBox2: TGroupBox
    56     Left = 8
    57     Height = 64
    58     Top = 80
    59     Width = 608
    60     Caption = 'Signed integer (SInt)'
    61     ClientHeight = 46
    62     ClientWidth = 604
    63     TabOrder = 1
    64     object SpinEditSInt: TSpinEdit
    65       Left = 6
    66       Height = 21
    67       Top = 8
    68       Width = 152
    69       MaxValue = 1000000000
    70       MinValue = -1000000000
    71       TabOrder = 0
    72       Value = -1
    73     end
    74     object ButtonSIntEncode: TButton
    75       Left = 246
    76       Height = 25
    77       Top = 8
    78       Width = 75
    79       Caption = 'Encode >>'
    80       OnClick = ButtonSIntEncodeClick
    81       TabOrder = 1
    82     end
    83     object EditSInt: TEdit
    84       Left = 326
    85       Height = 21
    86       Top = 8
    87       Width = 269
    88       TabOrder = 2
    89       Text = '00'
    90     end
    91     object ButtonSIntDecode: TButton
    92       Left = 166
    93       Height = 25
    94       Top = 8
    95       Width = 75
    96       Caption = '<< Decode'
    97       OnClick = ButtonSIntDecodeClick
    98       TabOrder = 3
    99     end
    100   end
    101   object GroupBox3: TGroupBox
    102     Left = 8
    103     Height = 64
    104     Top = 152
    105     Width = 608
    106     Caption = 'String'
    107     ClientHeight = 46
    108     ClientWidth = 604
    109     TabOrder = 2
    110     object ButtonEncodeString: TButton
    111       Left = 246
    112       Height = 25
    113       Top = 8
    114       Width = 75
    115       Caption = 'Encode >>'
    116       OnClick = ButtonEncodeStringClick
    117       TabOrder = 0
    118     end
    119     object EditStringData: TEdit
    120       Left = 326
    121       Height = 21
    122       Top = 8
    123       Width = 269
    124       TabOrder = 1
    125       Text = '00'
    126     end
    127     object ButtonDecodeString: TButton
    128       Left = 166
    129       Height = 25
    130       Top = 8
    131       Width = 75
    132       Caption = '<< Decode'
    133       OnClick = ButtonDecodeStringClick
    134       TabOrder = 2
    135     end
    136     object EditString: TEdit
    137       Left = 6
    138       Height = 21
    139       Top = 8
    140       Width = 152
    141       TabOrder = 3
    142       Text = 'Hello world'
    143     end
    144   end
    145   object GroupBox4: TGroupBox
    146     Left = 8
    147     Height = 64
    148     Top = 224
    149     Width = 608
    150     Caption = 'Raw data (Block)'
    151     ClientHeight = 46
    152     ClientWidth = 604
    153     TabOrder = 3
    154     object ButtonEncodeRaw: TButton
    155       Left = 246
    156       Height = 25
    157       Top = 8
    158       Width = 75
    159       Caption = 'Encode >>'
    160       OnClick = ButtonEncodeRawClick
    161       TabOrder = 0
    162     end
    163     object EditRawData: TEdit
    164       Left = 326
    165       Height = 21
    166       Top = 8
    167       Width = 269
    168       TabOrder = 1
    169       Text = '00'
    170     end
    171     object ButtonDecodeRaw: TButton
    172       Left = 166
    173       Height = 25
    174       Top = 8
    175       Width = 75
    176       Caption = '<< Decode'
    177       OnClick = ButtonDecodeRawClick
    178       TabOrder = 2
    179     end
    180     object EditRaw: TEdit
    181       Left = 6
    182       Height = 21
    183       Top = 8
    184       Width = 152
    185       TabOrder = 3
    186       Text = '01 23 45 67 89 AB CD EF'
    187     end
    188   end
    189   object GroupBox5: TGroupBox
    190     Left = 8
    191     Height = 64
    192     Top = 296
    193     Width = 608
    194     Caption = 'Float'
    195     ClientHeight = 46
    196     ClientWidth = 604
    197     TabOrder = 4
    198     object ButtonFloatEncode1: TButton
    199       Left = 246
    200       Height = 25
    201       Top = 8
    202       Width = 75
    203       Caption = 'Encode >>'
    204       OnClick = ButtonFloatEncode1Click
    205       TabOrder = 0
    206     end
    207     object EditFloat: TEdit
    208       Left = 326
    209       Height = 21
    210       Top = 8
    211       Width = 269
    212       TabOrder = 1
    213       Text = '00'
    214     end
    215     object ButtonFloatDecode1: TButton
    216       Left = 166
    217       Height = 25
    218       Top = 7
    219       Width = 75
    220       Caption = '<< Decode'
    221       OnClick = ButtonFloatDecode1Click
    222       TabOrder = 2
    223     end
    224     object FloatSpinEdit1: TFloatSpinEdit
    225       Left = 6
    226       Height = 21
    227       Top = 7
    228       Width = 96
    229       DecimalPlaces = 8
    230       Increment = 1
    231       MaxValue = 1000000000
    232       MinValue = -100000000
    233       TabOrder = 3
    234       Value = 0
    235     end
    236     object SpinEditFloat: TSpinEdit
    237       Left = 110
    238       Height = 21
    239       Top = 16
    240       Width = 50
    241       MaxValue = 16
    242       MinValue = 2
    243       TabOrder = 4
    244       Value = 2
    245     end
    246     object Label1: TLabel
    247       Left = 111
    248       Height = 14
    249       Top = 0
    250       Width = 24
    251       Caption = 'Base'
    252       ParentColor = False
     269    object TabSheet2: TTabSheet
     270      Caption = 'Indexed structure'
     271      ClientHeight = 366
     272      ClientWidth = 624
     273      object EditIndexedItem1: TEdit
     274        Left = 36
     275        Height = 21
     276        Top = 34
     277        Width = 224
     278        TabOrder = 0
     279        Text = '11 22'
     280      end
     281      object Label2: TLabel
     282        Left = 10
     283        Height = 14
     284        Top = 38
     285        Width = 14
     286        Caption = '0: '
     287        ParentColor = False
     288      end
     289      object Label3: TLabel
     290        Left = 10
     291        Height = 14
     292        Top = 61
     293        Width = 11
     294        Caption = '1:'
     295        ParentColor = False
     296      end
     297      object EditIndexedItem2: TEdit
     298        Left = 36
     299        Height = 21
     300        Top = 58
     301        Width = 224
     302        TabOrder = 1
     303        Text = '33 44'
     304      end
     305      object EditIndexedItem3: TEdit
     306        Left = 36
     307        Height = 21
     308        Top = 86
     309        Width = 224
     310        TabOrder = 2
     311        Text = '55 66'
     312      end
     313      object Label4: TLabel
     314        Left = 10
     315        Height = 14
     316        Top = 89
     317        Width = 11
     318        Caption = '2:'
     319        ParentColor = False
     320      end
     321      object ButtonEncodeIndexed: TButton
     322        Left = 156
     323        Height = 25
     324        Top = 122
     325        Width = 75
     326        Caption = 'Encode >>'
     327        OnClick = ButtonEncodeIndexedClick
     328        TabOrder = 3
     329      end
     330      object ButtonDecodeIndexed: TButton
     331        Left = 68
     332        Height = 25
     333        Top = 122
     334        Width = 75
     335        Caption = '<< Decode'
     336        OnClick = ButtonDecodeIndexedClick
     337        TabOrder = 4
     338      end
     339      object EditIndexed: TEdit
     340        Left = 10
     341        Height = 21
     342        Top = 154
     343        Width = 588
     344        TabOrder = 5
     345      end
     346      object CheckBoxMask1: TCheckBox
     347        Left = 284
     348        Height = 17
     349        Top = 34
     350        Width = 20
     351        Checked = True
     352        State = cbChecked
     353        TabOrder = 6
     354      end
     355      object CheckBoxMask2: TCheckBox
     356        Left = 284
     357        Height = 17
     358        Top = 59
     359        Width = 20
     360        Checked = True
     361        State = cbChecked
     362        TabOrder = 7
     363      end
     364      object CheckBoxMask3: TCheckBox
     365        Left = 284
     366        Height = 17
     367        Top = 88
     368        Width = 20
     369        Checked = True
     370        State = cbChecked
     371        TabOrder = 8
     372      end
     373      object Label5: TLabel
     374        Left = 268
     375        Height = 14
     376        Top = 18
     377        Width = 40
     378        Caption = 'Bit mask'
     379        ParentColor = False
     380      end
     381      object Label6: TLabel
     382        Left = 8
     383        Height = 14
     384        Top = 11
     385        Width = 29
     386        Caption = 'Index'
     387        ParentColor = False
     388      end
    253389    end
    254390  end
  • CoolStreaming/Demo/VarBlockSerializer/UMainForm.pas

    r172 r173  
    1515  TMainForm = class(TForm)
    1616  published
     17    ButtonEncodeIndexed: TButton;
     18    ButtonDecodeIndexed: TButton;
     19    ButtonDecodeRaw: TButton;
    1720    ButtonDecodeString: TButton;
    18     ButtonDecodeRaw: TButton;
     21    ButtonEncodeRaw: TButton;
    1922    ButtonEncodeString: TButton;
    20     ButtonEncodeRaw: TButton;
    2123    ButtonFloatDecode1: TButton;
    2224    ButtonFloatEncode1: TButton;
    23     ButtonUIntDecode: TButton;
    2425    ButtonSIntDecode: TButton;
    2526    ButtonSIntEncode: TButton;
     27    ButtonUIntDecode: TButton;
     28    ButtonUIntEncode: TButton;
     29    CheckBoxMask1: TCheckBox;
     30    CheckBoxMask2: TCheckBox;
     31    CheckBoxMask3: TCheckBox;
     32    EditIndexedItem1: TEdit;
     33    EditIndexedItem2: TEdit;
     34    EditIndexedItem3: TEdit;
     35    EditIndexed: TEdit;
     36    EditFloat: TEdit;
    2637    EditRaw: TEdit;
    27     EditFloat: TEdit;
     38    EditRawData: TEdit;
     39    EditSInt: TEdit;
     40    EditString: TEdit;
    2841    EditStringData: TEdit;
    29     EditString: TEdit;
    30     EditRawData: TEdit;
    3142    EditUInt: TEdit;
    32     ButtonUIntEncode: TButton;
    33     EditSInt: TEdit;
    3443    FloatSpinEdit1: TFloatSpinEdit;
    3544    GroupBox1: TGroupBox;
     
    3948    GroupBox5: TGroupBox;
    4049    Label1: TLabel;
     50    Label2: TLabel;
     51    Label3: TLabel;
     52    Label4: TLabel;
     53    Label5: TLabel;
     54    Label6: TLabel;
     55    PageControl1: TPageControl;
    4156    SpinEditFloat: TSpinEdit;
     57    SpinEditSInt: TSpinEdit;
    4258    SpinEditUInt: TSpinEdit;
    43     SpinEditSInt: TSpinEdit;
     59    TabSheet1: TTabSheet;
     60    TabSheet2: TTabSheet;
     61    procedure ButtonDecodeIndexedClick(Sender: TObject);
     62    procedure ButtonEncodeIndexedClick(Sender: TObject);
    4463    procedure ButtonDecodeRawClick(Sender: TObject);
    4564    procedure ButtonDecodeStringClick(Sender: TObject);
     
    5271    procedure ButtonUIntDecodeClick(Sender: TObject);
    5372    procedure ButtonUIntEncodeClick(Sender: TObject);
     73    procedure FormShow(Sender: TObject);
    5474  public
    5575    function StreamToString(Stream: TStream): string;
     
    81101    Stream.Free;
    82102    Block.Free;
     103  end;
     104end;
     105
     106procedure TMainForm.ButtonEncodeIndexedClick(Sender: TObject);
     107var
     108  IndexedBlock: TVarBlockIndexed;
     109  Stream: TMemoryStream;
     110begin
     111  try
     112    IndexedBlock := TVarBlockIndexed.Create;
     113    Stream := TMemoryStream.Create;
     114    if CheckBoxMask1.Checked then begin
     115      StringToStream(EditIndexedItem1.Text, Stream);
     116      IndexedBlock.WriteVarStream(0, Stream);
     117    end;
     118    if CheckBoxMask2.Checked then begin
     119      StringToStream(EditIndexedItem2.Text, Stream);
     120      IndexedBlock.WriteVarStream(1, Stream);
     121    end;
     122    if CheckBoxMask3.Checked then begin
     123      StringToStream(EditIndexedItem3.Text, Stream);
     124      IndexedBlock.WriteVarStream(2, Stream);
     125    end;
     126    Stream.Clear;
     127    IndexedBlock.WriteToStream(Stream);
     128    EditIndexed.Text := StreamToString(Stream);
     129  finally
     130    IndexedBlock.Free;
     131    Stream.Free;
     132  end;
     133end;
     134
     135procedure TMainForm.ButtonDecodeIndexedClick(Sender: TObject);
     136var
     137  IndexedBlock: TVarBlockIndexed;
     138  Stream: TMemoryStream;
     139begin
     140  try
     141    IndexedBlock := TVarBlockIndexed.Create;
     142    Stream := TMemoryStream.Create;
     143    StringToStream(EditIndexed.Text, Stream);
     144    IndexedBlock.ReadFromStream(Stream);
     145
     146    CheckBoxMask1.Checked := IndexedBlock.TestIndex(0);
     147    CheckBoxMask2.Checked := IndexedBlock.TestIndex(1);
     148    CheckBoxMask3.Checked := IndexedBlock.TestIndex(2);
     149
     150    Stream.Clear;
     151    if IndexedBlock.TestIndex(0) then begin
     152      IndexedBlock.ReadVarStream(0, Stream);
     153      EditIndexedItem1.Text := StreamToString(Stream);
     154    end else EditIndexedItem1.Text := '';
     155    if IndexedBlock.TestIndex(1) then begin
     156      IndexedBlock.ReadVarStream(1, Stream);
     157      EditIndexedItem2.Text := StreamToString(Stream);
     158    end else EditIndexedItem2.Text := '';
     159    if IndexedBlock.TestIndex(2) then begin
     160      IndexedBlock.ReadVarStream(2, Stream);
     161      EditIndexedItem3.Text := StreamToString(Stream);
     162    end else EditIndexedItem3.Text := '';
     163  finally
     164    IndexedBlock.Free;
     165    Stream.Free;
    83166  end;
    84167end;
     
    207290    Block.Free;
    208291  end;
     292end;
     293
     294procedure TMainForm.FormShow(Sender: TObject);
     295begin
     296  PageControl1.TabIndex := 0;
    209297end;
    210298
     
    246334    Delete(Text, 1, Pos(' ', Text));
    247335  end;
    248   if TryHexToInt(Text, Number) and (Number < 256) then
     336  if TryHexToInt(Text, Number) and (Number < 256) and (Text <> '') then
    249337    Stream.WriteByte(Number);
    250338end;
  • CoolStreaming/Demo/VarBlockSerializer/VarBlockSerializerDemo.lpi

    r172 r173  
    4343      </Item3>
    4444    </RequiredPackages>
    45     <Units Count="6">
     45    <Units Count="8">
    4646      <Unit0>
    4747        <Filename Value="VarBlockSerializerDemo.lpr"/>
    4848        <IsPartOfProject Value="True"/>
    4949        <UnitName Value="VarBlockSerializerDemo"/>
    50         <UsageCount Value="20"/>
     50        <UsageCount Value="55"/>
    5151      </Unit0>
    5252      <Unit1>
     
    5656        <ResourceBaseClass Value="Form"/>
    5757        <UnitName Value="UMainForm"/>
     58        <IsVisibleTab Value="True"/>
    5859        <EditorIndex Value="0"/>
    5960        <WindowIndex Value="0"/>
    60         <TopLine Value="138"/>
    61         <CursorPos X="13" Y="150"/>
    62         <UsageCount Value="20"/>
     61        <TopLine Value="294"/>
     62        <CursorPos X="25" Y="296"/>
     63        <UsageCount Value="55"/>
    6364        <Loaded Value="True"/>
    6465        <LoadedDesigner Value="True"/>
     
    6768        <Filename Value="E:\Projekty2\FreePascalManager\trunk\Instance\1\Lazarus\lcl\spin.pp"/>
    6869        <UnitName Value="Spin"/>
    69         <EditorIndex Value="4"/>
     70        <EditorIndex Value="6"/>
    7071        <WindowIndex Value="0"/>
    7172        <TopLine Value="172"/>
    7273        <CursorPos X="17" Y="185"/>
    73         <UsageCount Value="10"/>
     74        <UsageCount Value="28"/>
    7475        <Loaded Value="True"/>
    7576      </Unit2>
     
    7778        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    7879        <UnitName Value="UVarBlockSerializer"/>
    79         <IsVisibleTab Value="True"/>
    80         <EditorIndex Value="1"/>
    81         <WindowIndex Value="0"/>
    82         <TopLine Value="1"/>
    83         <CursorPos X="1" Y="18"/>
    84         <UsageCount Value="10"/>
     80        <EditorIndex Value="2"/>
     81        <WindowIndex Value="0"/>
     82        <TopLine Value="753"/>
     83        <CursorPos X="54" Y="764"/>
     84        <UsageCount Value="28"/>
    8585        <Loaded Value="True"/>
    8686      </Unit3>
    8787      <Unit4>
    8888        <Filename Value="E:\Projekty2\FreePascalManager\trunk\Instance\1\FPC\rtl\objpas\classes\classesh.inc"/>
    89         <EditorIndex Value="2"/>
     89        <EditorIndex Value="4"/>
    9090        <WindowIndex Value="0"/>
    9191        <TopLine Value="773"/>
    9292        <CursorPos X="14" Y="786"/>
    93         <UsageCount Value="10"/>
     93        <UsageCount Value="28"/>
    9494        <Loaded Value="True"/>
    9595      </Unit4>
    9696      <Unit5>
    9797        <Filename Value="E:\Projekty2\FreePascalManager\trunk\Instance\1\FPC\rtl\objpas\classes\streams.inc"/>
    98         <EditorIndex Value="3"/>
     98        <EditorIndex Value="5"/>
    9999        <WindowIndex Value="0"/>
    100100        <TopLine Value="134"/>
    101101        <CursorPos X="23" Y="151"/>
    102         <UsageCount Value="10"/>
     102        <UsageCount Value="28"/>
    103103        <Loaded Value="True"/>
    104104      </Unit5>
     105      <Unit6>
     106        <Filename Value="E:\Projekty2\FreePascalManager\trunk\Instance\1\Lazarus\lcl\include\control.inc"/>
     107        <EditorIndex Value="1"/>
     108        <WindowIndex Value="0"/>
     109        <TopLine Value="2798"/>
     110        <CursorPos X="1" Y="2808"/>
     111        <UsageCount Value="11"/>
     112        <Loaded Value="True"/>
     113      </Unit6>
     114      <Unit7>
     115        <Filename Value="..\..\UStreamHelper.pas"/>
     116        <UnitName Value="UStreamHelper"/>
     117        <EditorIndex Value="3"/>
     118        <WindowIndex Value="0"/>
     119        <TopLine Value="192"/>
     120        <CursorPos X="1" Y="205"/>
     121        <UsageCount Value="11"/>
     122        <Loaded Value="True"/>
     123      </Unit7>
    105124    </Units>
    106     <JumpHistory Count="30" HistoryIndex="29">
     125    <JumpHistory Count="29" HistoryIndex="28">
    107126      <Position1>
    108127        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    109         <Caret Line="249" Column="1" TopLine="231"/>
     128        <Caret Line="778" Column="1" TopLine="765"/>
    110129      </Position1>
    111130      <Position2>
    112131        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    113         <Caret Line="240" Column="1" TopLine="231"/>
     132        <Caret Line="766" Column="1" TopLine="761"/>
    114133      </Position2>
    115134      <Position3>
    116135        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    117         <Caret Line="244" Column="1" TopLine="231"/>
     136        <Caret Line="767" Column="1" TopLine="761"/>
    118137      </Position3>
    119138      <Position4>
    120139        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    121         <Caret Line="245" Column="1" TopLine="231"/>
     140        <Caret Line="768" Column="1" TopLine="761"/>
    122141      </Position4>
    123142      <Position5>
    124143        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    125         <Caret Line="246" Column="1" TopLine="231"/>
     144        <Caret Line="769" Column="1" TopLine="761"/>
    126145      </Position5>
    127146      <Position6>
    128147        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    129         <Caret Line="247" Column="1" TopLine="231"/>
     148        <Caret Line="770" Column="1" TopLine="761"/>
    130149      </Position6>
    131150      <Position7>
    132         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    133         <Caret Line="249" Column="1" TopLine="231"/>
     151        <Filename Value="UMainForm.pas"/>
     152        <Caret Line="111" Column="41" TopLine="108"/>
    134153      </Position7>
    135154      <Position8>
    136         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    137         <Caret Line="240" Column="1" TopLine="231"/>
     155        <Filename Value="UMainForm.pas"/>
     156        <Caret Line="126" Column="28" TopLine="108"/>
    138157      </Position8>
    139158      <Position9>
    140159        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    141         <Caret Line="244" Column="1" TopLine="231"/>
     160        <Caret Line="810" Column="16" TopLine="802"/>
    142161      </Position9>
    143162      <Position10>
    144163        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    145         <Caret Line="245" Column="1" TopLine="231"/>
     164        <Caret Line="766" Column="1" TopLine="760"/>
    146165      </Position10>
    147166      <Position11>
    148167        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    149         <Caret Line="249" Column="1" TopLine="231"/>
     168        <Caret Line="767" Column="1" TopLine="760"/>
    150169      </Position11>
    151170      <Position12>
    152171        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    153         <Caret Line="240" Column="1" TopLine="231"/>
     172        <Caret Line="768" Column="1" TopLine="760"/>
    154173      </Position12>
    155174      <Position13>
    156175        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    157         <Caret Line="244" Column="1" TopLine="231"/>
     176        <Caret Line="769" Column="1" TopLine="760"/>
    158177      </Position13>
    159178      <Position14>
    160179        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    161         <Caret Line="245" Column="1" TopLine="231"/>
     180        <Caret Line="770" Column="1" TopLine="760"/>
    162181      </Position14>
    163182      <Position15>
    164183        <Filename Value="..\..\UVarBlockSerializer.pas"/>
    165         <Caret Line="246" Column="1" TopLine="231"/>
     184        <Caret Line="771" Column="1" TopLine="760"/>
    166185      </Position15>
    167186      <Position16>
    168         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    169         <Caret Line="247" Column="1" TopLine="231"/>
     187        <Filename Value="UMainForm.pas"/>
     188        <Caret Line="126" Column="28" TopLine="108"/>
    170189      </Position16>
    171190      <Position17>
    172         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    173         <Caret Line="246" Column="1" TopLine="231"/>
     191        <Filename Value="UMainForm.pas"/>
     192        <Caret Line="113" Column="1" TopLine="108"/>
    174193      </Position17>
    175194      <Position18>
    176         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    177         <Caret Line="247" Column="1" TopLine="231"/>
     195        <Filename Value="UMainForm.pas"/>
     196        <Caret Line="114" Column="1" TopLine="108"/>
    178197      </Position18>
    179198      <Position19>
    180         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    181         <Caret Line="249" Column="1" TopLine="231"/>
     199        <Filename Value="UMainForm.pas"/>
     200        <Caret Line="115" Column="1" TopLine="108"/>
    182201      </Position19>
    183202      <Position20>
    184         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    185         <Caret Line="250" Column="1" TopLine="231"/>
     203        <Filename Value="UMainForm.pas"/>
     204        <Caret Line="114" Column="13" TopLine="108"/>
    186205      </Position20>
    187206      <Position21>
    188         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    189         <Caret Line="251" Column="1" TopLine="231"/>
     207        <Filename Value="UMainForm.pas"/>
     208        <Caret Line="326" Column="3" TopLine="309"/>
    190209      </Position21>
    191210      <Position22>
    192211        <Filename Value="UMainForm.pas"/>
    193         <Caret Line="135" Column="52" TopLine="116"/>
     212        <Caret Line="113" Column="1" TopLine="100"/>
    194213      </Position22>
    195214      <Position23>
    196215        <Filename Value="UMainForm.pas"/>
    197         <Caret Line="136" Column="52" TopLine="117"/>
     216        <Caret Line="321" Column="1" TopLine="308"/>
    198217      </Position23>
    199218      <Position24>
    200         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    201         <Caret Line="230" Column="58" TopLine="228"/>
     219        <Filename Value="UMainForm.pas"/>
     220        <Caret Line="322" Column="1" TopLine="308"/>
    202221      </Position24>
    203222      <Position25>
    204         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    205         <Caret Line="47" Column="27" TopLine="44"/>
     223        <Filename Value="UMainForm.pas"/>
     224        <Caret Line="323" Column="1" TopLine="308"/>
    206225      </Position25>
    207226      <Position26>
    208227        <Filename Value="UMainForm.pas"/>
    209         <Caret Line="150" Column="13" TopLine="138"/>
     228        <Caret Line="324" Column="1" TopLine="308"/>
    210229      </Position26>
    211230      <Position27>
    212         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    213         <Caret Line="246" Column="11" TopLine="230"/>
     231        <Filename Value="UMainForm.pas"/>
     232        <Caret Line="330" Column="68" TopLine="309"/>
    214233      </Position27>
    215234      <Position28>
    216         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    217         <Caret Line="240" Column="1" TopLine="227"/>
     235        <Filename Value="UMainForm.pas"/>
     236        <Caret Line="113" Column="1" TopLine="100"/>
    218237      </Position28>
    219238      <Position29>
    220         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    221         <Caret Line="241" Column="1" TopLine="227"/>
     239        <Filename Value="UMainForm.pas"/>
     240        <Caret Line="114" Column="1" TopLine="101"/>
    222241      </Position29>
    223       <Position30>
    224         <Filename Value="..\..\UVarBlockSerializer.pas"/>
    225         <Caret Line="242" Column="1" TopLine="227"/>
    226       </Position30>
    227242    </JumpHistory>
    228243  </ProjectOptions>
  • CoolStreaming/UVarBlockSerializer.pas

    r172 r173  
    9393    procedure Clear;
    9494    function TestIndex(Index: Integer): Boolean;
    95     procedure WriteToVarBlock(Stream: TVarBlockSerializer);
    96     procedure ReadFromVarBlock(Stream: TVarBlockSerializer);
     95    procedure WriteToVarBlock(VarBlock: TVarBlockSerializer);
     96    procedure ReadFromVarBlock(VarBlock: TVarBlockSerializer);
    9797    procedure WriteToStream(Stream: TStream);
    9898    procedure ReadFromStream(Stream: TStream);
     
    533533    Temp := TVarBlockSerializer.Create;
    534534    StreamHelper := TStreamHelper.Create(Stream);
     535    Stream.Position := 0;
    535536    ReadVarBlock(Temp);
    536537    Stream.Size := 0;
     
    757758end;
    758759
    759 procedure TVarBlockIndexed.WriteToVarBlock(Stream: TVarBlockSerializer);
     760procedure TVarBlockIndexed.WriteToVarBlock(VarBlock: TVarBlockSerializer);
    760761var
    761762  Mask: Integer;
     
    764765begin
    765766  try
    766     StreamHelper := TStreamHelper.Create(Stream.Stream);
    767     Stream.Stream.Size := 0;
     767    StreamHelper := TStreamHelper.Create(VarBlock.Stream);
     768    VarBlock.Stream.Size := 0;
    768769    Mask := 0;
    769770    for I := 0 to Items.Count - 1 do
    770771      if Assigned(Items[I]) then Mask := Mask or (1 shl I);
    771     Stream.WriteVarUInt(Mask);
     772    VarBlock.WriteVarUInt(Mask);
    772773    for I := 0 to Items.Count - 1 do
    773774      if Assigned(Items[I]) then StreamHelper.WriteStream(TVarBlockSerializer(Items[I]).Stream,
    774775        TVarBlockSerializer(Items[I]).Stream.Size);
    775     if Enclose then Stream.BlockEnclose;
     776    if Enclose then VarBlock.BlockEnclose;
    776777  finally
    777778    StreamHelper.Free;
     
    779780end;
    780781
    781 procedure TVarBlockIndexed.ReadFromVarBlock(Stream: TVarBlockSerializer);
     782procedure TVarBlockIndexed.ReadFromVarBlock(VarBlock: TVarBlockSerializer);
    782783var
    783784  Mask: Integer;
    784785  I: Integer;
    785786begin
    786   if Enclose then Stream.BlockUnclose;
    787   Stream.Stream.Position := 0;
    788   Mask := Stream.ReadVarUInt;
     787  if Enclose then VarBlock.BlockUnclose;
     788  VarBlock.Stream.Position := 0;
     789  Mask := VarBlock.ReadVarUInt;
    789790  I := 0;
    790791  while Mask <> 0 do begin
    791     if Stream.TestMask(Mask, I) then begin
     792    if VarBlock.TestMask(Mask, I) then begin
    792793      if Items.Count <= I then Items.Count := I + 1;
    793794      Items[I] := TVarBlockSerializer.Create;
    794       Stream.ReadItemByMaskIndex(I, TVarBlockSerializer(Items[I]));
     795      VarBlock.ReadItemByMaskIndex(I, TVarBlockSerializer(Items[I]));
    795796      Mask := Mask xor (1 shl I); // Clear bit on current index
    796797    end;
Note: See TracChangeset for help on using the changeset viewer.