Download The Big Book of Linux Ada Programming

Transcript
Big Online Book of Linux Ada Programming - 11 Advanced Ada Programming
Buf.Buffer(Buf.Read_Offset..Buf.Read_Offset+Xfer_Count-1);
Buf.Read_Offset := Buf.Read_Offset + Xfer_Count;
Last := Item'First + Xfer_Count - 1;
end Read;
--------------------------------------------------- Rewind the Read offset in the Memory Buffer
-------------------------------------------------procedure Rewind_Read(Buf: in out Memory_Buffer) is
begin
Buf.Read_Offset := Buf.Buffer'First;
end Rewind_Read;
--------------------------------------------------- Rewind the Write offset in the Memory Buffer
-------------------------------------------------procedure Rewind_Write(Buf: in out Memory_Buffer) is
begin
Buf.Read_Offset := Buf.Buffer'First;
-- Implies a Read offset rewind
Buf.Write_Offset := Buf.Buffer'First;
-- Rewind the write offset
end Rewind_Write;
end Memory_Stream;
-- $Id: main.adb,v 1.1 2000/11/26 05:00:18 wwg Exp $
-- (c) Warren W. Gay VE3WWG [email protected], [email protected]
--- Protected under the GNU GPL License
with Ada.Text_IO;
use Ada.Text_IO;
with Memory_Stream;
use Memory_Stream;
--------------------------------------------------- This is a demo main program, that makes use of
-- our home-brewed Memory_Buffer_Stream.
--- To demonstrate, a record of type my_rec is
-- written to the stream with known values, and
-- then is read back twice, into records T and U.
--- Then the write offset is rewound, and a new
-- float variable F is written, and then read
-- back into float variable G.
-------------------------------------------------procedure Main is
type my_rec is record
-- A demonstration record
A:
natural;
B:
integer;
S:
string(1..8);
Z:
float;
file:///G|/Linux/http-www.vaxxine.com-pegasoft-people-html/book/11.html (33 of 39) [7/20/2001 11:33:47 AM]