Re: I/O streaming with custom data transport



Maciej Sobczak <no.spam@xxxxxxxxxxx> writes:

procedure Write_Hello(Stream : in out Stream_Access) is
begin
String'Write(Stream, "Hello");
end Write_Hello;

I don't understand this. Ada streams are streams of Stream_Elements
(usually bytes), and the 'Read/'Write attributes encode things in
some way that is not necessarily human-readable. For example,
I think the above outputs the bounds of the string in some
binary form.

But the original question was about streams of characters,
intended to be human-readable. Right?

So how do Ada's streams help, here?

It seems to me what you want is an abstract Character_Output_Stream
type, with a primitive (or class-wide?) operation that puts a Character
to the stream. Then you can make derived types for sending to a file,
to an in-memory buffer, etc.

- Bob
.



Relevant Pages

  • Re: Workable encryption in Tcl??
    ... like TCL deals with the abstract ... > abstract characters using the concrete UTF-8 encoding, ... > character streams and octet streams when doing input and output. ...
    (comp.lang.tcl)
  • Re: Workable encryption in Tcl??
    ... abstract characters using the concrete UTF-8 encoding, ... character streams and octet streams when doing input and output. ... How does this relate to encryption? ...
    (comp.lang.tcl)
  • Re: Confusion about I/O Streams
    ... > I have to admit I've never fully understood the different Java I/O streams ... > so I've been reviewing them in the Java Tutorial. ... Characters are a higher-level abstraction than bytes. ... If you've got a String, you can get a bytefrom it using: ...
    (comp.lang.java.help)
  • Re: pointer to const int
    ... the missing new-line at the end of the output.) ... Therefore, to accommodate those implementations, C89 made it undefined behavior. ... streams of characters. ... in a single operation cannot write a few characters at the ...
    (comp.lang.c)
  • Re: fseek
    ... >>Newline conversion is one of the common changes, ... Both binary and text streams are a sequence ... > of characters as far as the standard is concerned. ...
    (comp.lang.c)