From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8efa3c7b8890281b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-10 07:50:12 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: <3b6dc4ed@post.newsfeeds.com> <9kv5rs$6hosn$2@ID-102190.news.dfncis.de> Subject: Re: implementation question about writing and reading from files Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Fri, 10 Aug 2001 10:49:59 EDT Organization: http://www.newsranger.com Date: Fri, 10 Aug 2001 14:49:59 GMT Xref: archiver1.google.com comp.lang.ada:11765 Date: 2001-08-10T14:49:59+00:00 List-Id: In article <9kv5rs$6hosn$2@ID-102190.news.dfncis.de>, Francis Crick says... >And also, if I want to use a stream for keeping data in memory, how do i >that? How do i instantiate a stream that I can just write to and read from >at my leisure? The only language-defined streams are in Ada.Streams.Stream_IO, Ada.Text_IO.Text_Streams, and Ada.Wide_Text_IO.Text_Streams. I believe they all deal with files. If you want to use one to make yourself a buffer, you will have to code it yourself by deriving it from Ada.Streams.Root_Stream_Type and overriding "Read" and "Write". > Also, the data I'm moving is large, and chances are I won't >be using it for much else other than writing back to other file streams, so >how can i make the reading and writing as fast as possible? Could I make it >read a whole mb in one go as a single unit? The easiest way to do that is to unchecked_conversion your data (or better yet, a pointer to it) into a Ada.Streams.Stream_Element_Array, then call Ada.Streams.Write directly. If you just use the stream attributes, it will perform one write for each element, which I've found to be significantly slower (even when the target is a memory-based stream). A good Ada book should go over the basics of this. Stream use is a complicated enough topic that you really ought to have such a resource to learn the basics from. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com