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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!newspeer1.nac.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: A custom stream type Date: Sun, 27 Jul 2014 23:39:45 +0300 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net QEXRi7qWqUm2Ek3KF336nAzQkW73i5Nn1FBvhYWyMzOEHxasm8 Cancel-Lock: sha1:DcbXljmD6V3nBBfUROj4n4bYAFk= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: Xref: number.nntp.dca.giganews.com comp.lang.ada:187949 Date: 2014-07-27T23:39:45+03:00 List-Id: On 14-07-27 23:08 , Victor Porton wrote: > I want to create a custom stream type (not the files provided by the OS, but > something different, such as saving results of write operations into a > container, or calling a C stream library or whatever). > > How to do it with Ada2012? Derive your stream type from the root of all streams: with Ada.Streams; ... type My_Stream is new Ada.Streams.Root_Stream_Type with record ... end record; and then override (i.e. implement) the Read and Write operations for My_Stream. See the package Ada.Streams, RM 13.13.1. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .