Hi,
I am trying to learn Ada/Gnat,and am a bit stuck on the I/O. Maybe someone has a quick tip for me.
I am reprogramming something I had done in C++. Most of it is straightforward, except the input side. Get_Line is much to slow, so I am trying to loop reading into a stringbuffer of, say 50 Mb, , to extract and handle the separate lines later on.
I have tried to use 'read on an unbounded string, but this loads strings with 80 chars at a time and crashes at the end. What is the right way to do this ?
Code:
with Ada.Text_IO,Ada.Integer_Text_IO, ada.streams.stream_io,Ada.Strings.Unbounded ;
use Ada.Text_IO,Ada.Integer_Text_IO, ada.streams.stream_io,Ada.Strings.Unbounded ;
with Ada.Direct_IO;
procedure CompareC is
subtype unstring is Unbounded_string;
package unString_IO is new Ada.Direct_IO (unstring);
chunk: unstring;
unb_File : unString_IO.File_type;
count : integer :=1;
begin
unString_IO.open( unb_file,unstring_IO.in_file, "testfile" );
while not unstring_IO.End_of_File( unb_file ) loop
unString_IO.Read (unb_File, Item => chunk);
-- write etc...
end loop;
unString_IO.Close( unb_file );
Put("Done");
end CompareC;
I know, I should really buy the book, but I am just trying if Ada is worth it
.Sites like
http://www.infres.enst.fr/~pautet/Ada95/a95list.htm and Big Book of Ada Linux are not very helpful inthis particular thing