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.8 required=5.0 tests=BAYES_00,TO_MALFORMED autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,e0b85aa2bdf012f2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-03-28 07:51:02 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.aset.psu.edu!not-for-mail From: Robert Spooner Newsgroups: comp.lang.ada Subject: Re: Ada Streams representation - XML Date: Fri, 28 Mar 2003 10:46:32 -0500 Organization: Penn State University, Center for Academic Computing Message-ID: <3E846E58.3080905@psu.edu> References: <3e83277e@epflnews.epfl.ch> <3E834822.6000005@psu.edu> <3e841acf$1@epflnews.epfl.ch> NNTP-Posting-Host: nat3.arl.psu.edu Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: f04n12.cac.psu.edu 1048866393 28598 146.186.165.37 (28 Mar 2003 15:46:33 GMT) X-Complaints-To: usenet@f04n12.cac.psu.edu NNTP-Posting-Date: Fri, 28 Mar 2003 15:46:33 +0000 (UTC) To: =?ISO-8859-1?Q?Rodrigo_Garc=EDa?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en,de,fr-FR Xref: archiver1.google.com comp.lang.ada:35793 Date: 2003-03-28T10:46:32-05:00 List-Id: Rodrigo, Rodrigo Garc�a wrote: > Robert Spooner wrote: > >> Rodrigo, >> >> You can define your own stream representation for a _type_ by >> redefining 'read and 'write for that type. > > > Yes, I know that (RM 13.13.2(40)). The problem with that solution is > that you lose the default stream representation for that type. Besides, > it does not let you override the 'Write or 'Read attributes for > predefined non-limited types (e.g. "Integer") and the Stream_Element > type is still fixed. I don't know any way of changing the Stream_Element type, but for types for which you want to keep the default 'Read and 'Write, you can derive a new type from them (with no changes if you don't need any) and redefine 'Read and 'Write for the derived types. Then just do explicit conversions where necessary. You can also derive a new composite type composed of the new types from a composite type comprised of the original types, and explicit conversions between the composite types will work as well. > > I was thinking of a mechanism that would allow you, for instance, to > serialize a type using XML while you could still use ordinary > serialization. I am afraid that defining a new type of Stream (derived > from Root_Stream_Type) is not the solution, since this is thought for > specifying new back-ends and ways of reading/writing but not for stating > a different representation... Well, since type Root_Stream_Type is abstract, you have to derive a non abstract type from it to use streams, but the stream representation is provided through the 'Read and 'Write attributes of the types you are using. You then can use those attributes to read and write information to a Stream_Element_Array in memory (or to a file) using any representation scheme you choose (by implementing it in the overridden attributes,) including an XML representation. You then can manipulate the Stream_Element_Array as necessary. I have used streams to read and write to serial ports and TCP/IP circuits using non default representations of types this way. It's very useful, and once you have defined the representation by overriding the attributes for the elementary types you are using, it works automatically for composite types. The important thing to remember is that the stream representation (which can be whatever you want so long as it can be represented in an array of Stream_Element) is associated with the type, not the stream itself. Bob -- Robert L. Spooner Registered Professional Engineer Associate Research Engineer Intelligent Control Systems Department Applied Research Laboratory Phone: (814) 863-4120 The Pennsylvania State University FAX: (814) 863-7841 P. O. Box 30 State College, PA 16804-0030 rls19@psu.edu