From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: set_index and and end_of_file with just a stream reference Date: Sun, 21 Feb 2021 01:22:37 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <4d2daa8c-c159-48a4-bdf7-e9aa3b537bcan@googlegroups.com> <4d0aa284-8042-4260-ac58-6d3ac9a82b00n@googlegroups.com> <1cd1f911-ab74-464a-8eff-b6f3d79bfe8an@googlegroups.com> NNTP-Posting-Host: 5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:61401 List-Id: On 2021-02-20 20:08, Mehdi Saada wrote: > Okay :-) > what I wanted is: > I read an acronyme in the stream file, if good I input the adjacent record type, otherwise I would advance on the stream until the next acronyme with set_index(stream_access, index(stream_access) + composite_type_stream_size) and read the next acronyme (unbounded_string). > Now I just input both objects and verify the acronyme. > But I don't like writing an object that maybe won't be used. So, the problem is "compartmentalization" of a stream. [As Simon said you better read/write everything as is] If you really want to implement it, one technique is chained "virtual" stream. You create a stream type like this: type Compartment_Stream ( Source : not null access Root_Stream_Type'Class ) is new Root_Stream_Type with ... The Read/Write operations call to Read/Write of Source, but add delimiters separating "compartments." E.g. the stream elements 0..254 are encoded as is. The element 255 is encoded as a pair (255,255). The pairs (255,*) are treated as an "end of a compartment" and ignored. This way you can add a Skip operation to Compartment_Stream that reads everything until first (255,*). You can even create a nested structure of compartments using this schema. E.g. encode start of a compartment as (255,0) and its end as (255,1) etc. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de