Changeset 173 for CoolStreaming
- Timestamp:
- Feb 23, 2011, 7:42:22 AM (14 years ago)
- Location:
- CoolStreaming
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
CoolStreaming/Demo/VarBlockSerializer/UMainForm.lfm
r172 r173 1 1 object MainForm: TMainForm 2 2 Left = 263 3 Height = 4 663 Height = 405 4 4 Top = 119 5 Width = 6 315 Width = 644 6 6 Caption = 'VarBlockSerializer demo' 7 ClientHeight = 466 8 ClientWidth = 631 7 ClientHeight = 405 8 ClientWidth = 644 9 OnShow = FormShow 9 10 LCLVersion = '0.9.31' 10 object GroupBox1: TGroupBox11 object PageControl1: TPageControl 11 12 Left = 8 12 Height = 6413 Height = 392 13 14 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 18 18 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 27 268 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 253 389 end 254 390 end -
CoolStreaming/Demo/VarBlockSerializer/UMainForm.pas
r172 r173 15 15 TMainForm = class(TForm) 16 16 published 17 ButtonEncodeIndexed: TButton; 18 ButtonDecodeIndexed: TButton; 19 ButtonDecodeRaw: TButton; 17 20 ButtonDecodeString: TButton; 18 Button DecodeRaw: TButton;21 ButtonEncodeRaw: TButton; 19 22 ButtonEncodeString: TButton; 20 ButtonEncodeRaw: TButton;21 23 ButtonFloatDecode1: TButton; 22 24 ButtonFloatEncode1: TButton; 23 ButtonUIntDecode: TButton;24 25 ButtonSIntDecode: TButton; 25 26 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; 26 37 EditRaw: TEdit; 27 EditFloat: TEdit; 38 EditRawData: TEdit; 39 EditSInt: TEdit; 40 EditString: TEdit; 28 41 EditStringData: TEdit; 29 EditString: TEdit;30 EditRawData: TEdit;31 42 EditUInt: TEdit; 32 ButtonUIntEncode: TButton;33 EditSInt: TEdit;34 43 FloatSpinEdit1: TFloatSpinEdit; 35 44 GroupBox1: TGroupBox; … … 39 48 GroupBox5: TGroupBox; 40 49 Label1: TLabel; 50 Label2: TLabel; 51 Label3: TLabel; 52 Label4: TLabel; 53 Label5: TLabel; 54 Label6: TLabel; 55 PageControl1: TPageControl; 41 56 SpinEditFloat: TSpinEdit; 57 SpinEditSInt: TSpinEdit; 42 58 SpinEditUInt: TSpinEdit; 43 SpinEditSInt: TSpinEdit; 59 TabSheet1: TTabSheet; 60 TabSheet2: TTabSheet; 61 procedure ButtonDecodeIndexedClick(Sender: TObject); 62 procedure ButtonEncodeIndexedClick(Sender: TObject); 44 63 procedure ButtonDecodeRawClick(Sender: TObject); 45 64 procedure ButtonDecodeStringClick(Sender: TObject); … … 52 71 procedure ButtonUIntDecodeClick(Sender: TObject); 53 72 procedure ButtonUIntEncodeClick(Sender: TObject); 73 procedure FormShow(Sender: TObject); 54 74 public 55 75 function StreamToString(Stream: TStream): string; … … 81 101 Stream.Free; 82 102 Block.Free; 103 end; 104 end; 105 106 procedure TMainForm.ButtonEncodeIndexedClick(Sender: TObject); 107 var 108 IndexedBlock: TVarBlockIndexed; 109 Stream: TMemoryStream; 110 begin 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; 133 end; 134 135 procedure TMainForm.ButtonDecodeIndexedClick(Sender: TObject); 136 var 137 IndexedBlock: TVarBlockIndexed; 138 Stream: TMemoryStream; 139 begin 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; 83 166 end; 84 167 end; … … 207 290 Block.Free; 208 291 end; 292 end; 293 294 procedure TMainForm.FormShow(Sender: TObject); 295 begin 296 PageControl1.TabIndex := 0; 209 297 end; 210 298 … … 246 334 Delete(Text, 1, Pos(' ', Text)); 247 335 end; 248 if TryHexToInt(Text, Number) and (Number < 256) then336 if TryHexToInt(Text, Number) and (Number < 256) and (Text <> '') then 249 337 Stream.WriteByte(Number); 250 338 end; -
CoolStreaming/Demo/VarBlockSerializer/VarBlockSerializerDemo.lpi
r172 r173 43 43 </Item3> 44 44 </RequiredPackages> 45 <Units Count=" 6">45 <Units Count="8"> 46 46 <Unit0> 47 47 <Filename Value="VarBlockSerializerDemo.lpr"/> 48 48 <IsPartOfProject Value="True"/> 49 49 <UnitName Value="VarBlockSerializerDemo"/> 50 <UsageCount Value=" 20"/>50 <UsageCount Value="55"/> 51 51 </Unit0> 52 52 <Unit1> … … 56 56 <ResourceBaseClass Value="Form"/> 57 57 <UnitName Value="UMainForm"/> 58 <IsVisibleTab Value="True"/> 58 59 <EditorIndex Value="0"/> 59 60 <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"/> 63 64 <Loaded Value="True"/> 64 65 <LoadedDesigner Value="True"/> … … 67 68 <Filename Value="E:\Projekty2\FreePascalManager\trunk\Instance\1\Lazarus\lcl\spin.pp"/> 68 69 <UnitName Value="Spin"/> 69 <EditorIndex Value=" 4"/>70 <EditorIndex Value="6"/> 70 71 <WindowIndex Value="0"/> 71 72 <TopLine Value="172"/> 72 73 <CursorPos X="17" Y="185"/> 73 <UsageCount Value=" 10"/>74 <UsageCount Value="28"/> 74 75 <Loaded Value="True"/> 75 76 </Unit2> … … 77 78 <Filename Value="..\..\UVarBlockSerializer.pas"/> 78 79 <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"/> 85 85 <Loaded Value="True"/> 86 86 </Unit3> 87 87 <Unit4> 88 88 <Filename Value="E:\Projekty2\FreePascalManager\trunk\Instance\1\FPC\rtl\objpas\classes\classesh.inc"/> 89 <EditorIndex Value=" 2"/>89 <EditorIndex Value="4"/> 90 90 <WindowIndex Value="0"/> 91 91 <TopLine Value="773"/> 92 92 <CursorPos X="14" Y="786"/> 93 <UsageCount Value=" 10"/>93 <UsageCount Value="28"/> 94 94 <Loaded Value="True"/> 95 95 </Unit4> 96 96 <Unit5> 97 97 <Filename Value="E:\Projekty2\FreePascalManager\trunk\Instance\1\FPC\rtl\objpas\classes\streams.inc"/> 98 <EditorIndex Value=" 3"/>98 <EditorIndex Value="5"/> 99 99 <WindowIndex Value="0"/> 100 100 <TopLine Value="134"/> 101 101 <CursorPos X="23" Y="151"/> 102 <UsageCount Value=" 10"/>102 <UsageCount Value="28"/> 103 103 <Loaded Value="True"/> 104 104 </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> 105 124 </Units> 106 <JumpHistory Count=" 30" HistoryIndex="29">125 <JumpHistory Count="29" HistoryIndex="28"> 107 126 <Position1> 108 127 <Filename Value="..\..\UVarBlockSerializer.pas"/> 109 <Caret Line=" 249" Column="1" TopLine="231"/>128 <Caret Line="778" Column="1" TopLine="765"/> 110 129 </Position1> 111 130 <Position2> 112 131 <Filename Value="..\..\UVarBlockSerializer.pas"/> 113 <Caret Line=" 240" Column="1" TopLine="231"/>132 <Caret Line="766" Column="1" TopLine="761"/> 114 133 </Position2> 115 134 <Position3> 116 135 <Filename Value="..\..\UVarBlockSerializer.pas"/> 117 <Caret Line=" 244" Column="1" TopLine="231"/>136 <Caret Line="767" Column="1" TopLine="761"/> 118 137 </Position3> 119 138 <Position4> 120 139 <Filename Value="..\..\UVarBlockSerializer.pas"/> 121 <Caret Line=" 245" Column="1" TopLine="231"/>140 <Caret Line="768" Column="1" TopLine="761"/> 122 141 </Position4> 123 142 <Position5> 124 143 <Filename Value="..\..\UVarBlockSerializer.pas"/> 125 <Caret Line=" 246" Column="1" TopLine="231"/>144 <Caret Line="769" Column="1" TopLine="761"/> 126 145 </Position5> 127 146 <Position6> 128 147 <Filename Value="..\..\UVarBlockSerializer.pas"/> 129 <Caret Line=" 247" Column="1" TopLine="231"/>148 <Caret Line="770" Column="1" TopLine="761"/> 130 149 </Position6> 131 150 <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"/> 134 153 </Position7> 135 154 <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"/> 138 157 </Position8> 139 158 <Position9> 140 159 <Filename Value="..\..\UVarBlockSerializer.pas"/> 141 <Caret Line=" 244" Column="1" TopLine="231"/>160 <Caret Line="810" Column="16" TopLine="802"/> 142 161 </Position9> 143 162 <Position10> 144 163 <Filename Value="..\..\UVarBlockSerializer.pas"/> 145 <Caret Line=" 245" Column="1" TopLine="231"/>164 <Caret Line="766" Column="1" TopLine="760"/> 146 165 </Position10> 147 166 <Position11> 148 167 <Filename Value="..\..\UVarBlockSerializer.pas"/> 149 <Caret Line=" 249" Column="1" TopLine="231"/>168 <Caret Line="767" Column="1" TopLine="760"/> 150 169 </Position11> 151 170 <Position12> 152 171 <Filename Value="..\..\UVarBlockSerializer.pas"/> 153 <Caret Line=" 240" Column="1" TopLine="231"/>172 <Caret Line="768" Column="1" TopLine="760"/> 154 173 </Position12> 155 174 <Position13> 156 175 <Filename Value="..\..\UVarBlockSerializer.pas"/> 157 <Caret Line=" 244" Column="1" TopLine="231"/>176 <Caret Line="769" Column="1" TopLine="760"/> 158 177 </Position13> 159 178 <Position14> 160 179 <Filename Value="..\..\UVarBlockSerializer.pas"/> 161 <Caret Line=" 245" Column="1" TopLine="231"/>180 <Caret Line="770" Column="1" TopLine="760"/> 162 181 </Position14> 163 182 <Position15> 164 183 <Filename Value="..\..\UVarBlockSerializer.pas"/> 165 <Caret Line=" 246" Column="1" TopLine="231"/>184 <Caret Line="771" Column="1" TopLine="760"/> 166 185 </Position15> 167 186 <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"/> 170 189 </Position16> 171 190 <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"/> 174 193 </Position17> 175 194 <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"/> 178 197 </Position18> 179 198 <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"/> 182 201 </Position19> 183 202 <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"/> 186 205 </Position20> 187 206 <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"/> 190 209 </Position21> 191 210 <Position22> 192 211 <Filename Value="UMainForm.pas"/> 193 <Caret Line="1 35" Column="52" TopLine="116"/>212 <Caret Line="113" Column="1" TopLine="100"/> 194 213 </Position22> 195 214 <Position23> 196 215 <Filename Value="UMainForm.pas"/> 197 <Caret Line=" 136" Column="52" TopLine="117"/>216 <Caret Line="321" Column="1" TopLine="308"/> 198 217 </Position23> 199 218 <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"/> 202 221 </Position24> 203 222 <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"/> 206 225 </Position25> 207 226 <Position26> 208 227 <Filename Value="UMainForm.pas"/> 209 <Caret Line=" 150" Column="13" TopLine="138"/>228 <Caret Line="324" Column="1" TopLine="308"/> 210 229 </Position26> 211 230 <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"/> 214 233 </Position27> 215 234 <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"/> 218 237 </Position28> 219 238 <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"/> 222 241 </Position29> 223 <Position30>224 <Filename Value="..\..\UVarBlockSerializer.pas"/>225 <Caret Line="242" Column="1" TopLine="227"/>226 </Position30>227 242 </JumpHistory> 228 243 </ProjectOptions> -
CoolStreaming/UVarBlockSerializer.pas
r172 r173 93 93 procedure Clear; 94 94 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); 97 97 procedure WriteToStream(Stream: TStream); 98 98 procedure ReadFromStream(Stream: TStream); … … 533 533 Temp := TVarBlockSerializer.Create; 534 534 StreamHelper := TStreamHelper.Create(Stream); 535 Stream.Position := 0; 535 536 ReadVarBlock(Temp); 536 537 Stream.Size := 0; … … 757 758 end; 758 759 759 procedure TVarBlockIndexed.WriteToVarBlock( Stream: TVarBlockSerializer);760 procedure TVarBlockIndexed.WriteToVarBlock(VarBlock: TVarBlockSerializer); 760 761 var 761 762 Mask: Integer; … … 764 765 begin 765 766 try 766 StreamHelper := TStreamHelper.Create( Stream.Stream);767 Stream.Stream.Size := 0;767 StreamHelper := TStreamHelper.Create(VarBlock.Stream); 768 VarBlock.Stream.Size := 0; 768 769 Mask := 0; 769 770 for I := 0 to Items.Count - 1 do 770 771 if Assigned(Items[I]) then Mask := Mask or (1 shl I); 771 Stream.WriteVarUInt(Mask);772 VarBlock.WriteVarUInt(Mask); 772 773 for I := 0 to Items.Count - 1 do 773 774 if Assigned(Items[I]) then StreamHelper.WriteStream(TVarBlockSerializer(Items[I]).Stream, 774 775 TVarBlockSerializer(Items[I]).Stream.Size); 775 if Enclose then Stream.BlockEnclose;776 if Enclose then VarBlock.BlockEnclose; 776 777 finally 777 778 StreamHelper.Free; … … 779 780 end; 780 781 781 procedure TVarBlockIndexed.ReadFromVarBlock( Stream: TVarBlockSerializer);782 procedure TVarBlockIndexed.ReadFromVarBlock(VarBlock: TVarBlockSerializer); 782 783 var 783 784 Mask: Integer; 784 785 I: Integer; 785 786 begin 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; 789 790 I := 0; 790 791 while Mask <> 0 do begin 791 if Stream.TestMask(Mask, I) then begin792 if VarBlock.TestMask(Mask, I) then begin 792 793 if Items.Count <= I then Items.Count := I + 1; 793 794 Items[I] := TVarBlockSerializer.Create; 794 Stream.ReadItemByMaskIndex(I, TVarBlockSerializer(Items[I]));795 VarBlock.ReadItemByMaskIndex(I, TVarBlockSerializer(Items[I])); 795 796 Mask := Mask xor (1 shl I); // Clear bit on current index 796 797 end;
Note:
See TracChangeset
for help on using the changeset viewer.