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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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-09 17:55:02 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!netnews.com!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: implementation question about writing and reading from files References: <9kv5rs$6hosn$2@ID-102190.news.dfncis.de> X-Newsreader: Tom's custom newsreader Message-ID: Date: Fri, 10 Aug 2001 00:55:02 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 997404902 24.7.82.199 (Thu, 09 Aug 2001 17:55:02 PDT) NNTP-Posting-Date: Thu, 09 Aug 2001 17:55:02 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:11730 Date: 2001-08-10T00:55:02+00:00 List-Id: >the parameters mean...obviously File_Type is the file i'm getting, but what >about the Item and Last parameters? Is Stream_Element a generic type I have >to declare, and if so, how and where do I do that? If not, how can I ensure >I'm getting the amount of data out of the file that I want on any platform? > >The From param in Read - what does this represent exactly? from byte #? >from Stream_Element # in the stream? You need a book, or look at www.adapower.com for the Ada 95 Reference Manual (ARM). A.12.1(31) says "The position of the first element in the file is 1." The Ada.Streams.Stream_IO Read and Write operate with Stream_Element_Array's, which are defined in Ada.Streams, where ARM 13.13.1(4) says type Stream_Element is mod (implementation defined); Probably a Stream_Element is a single byte, but there are weird systems where it might be a 20 bit word or something. Check your compiler's docs. >How do i instantiate a stream that I can just write to and read from >at my leisure? You can certainly do Ada.Streams.Stream_IO Read and Write at your leisure. There's nothing to instantiate, just use it. It's even simpler than Text/Sequential/Direct_IO. >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? Ada.Streams.Stream_IO.Read/Write ought to be fast. They don't do any formatting or buffering or anything, just straightforward byte (actually Stream_Element_Array) IO. If you Declare Glob : Ada.Streams.Stream_Element_Array(1 .. 1_000_000); you can read or write the whole thing in one call. >And also, if I want to use a stream for keeping data in memory, how do i >that? Not with Ada.Streams.Stream_IO. There is something else entirely, Ada.Streams, that handles automatically reading and writing everything from a boolean to an array of tagged records. It doesn't actually do any IO - it just handles converting things to and from byte streams (well, actually Stream_Element_Arrays) and calls your routine to do the actual IO. If you want to move things in memory, have your routine do that, and not do any IO. What is the level of abstraction here? If you aren't looking at the contents of the data, but just shoving it around, use Ada.Streams.Stream_IO. If you are looking at is as structured information that you want to pay attention to, then use Ada.Streams as well, or even use Ada.Direct_IO if it's just a series of fixed size records.