Redirecting standard file output to a string.

6 Messages Forum Options Options
Permalink
marvin_littlewood_426716
Redirecting standard file output to a string.
Reply Threaded More
Print post
Permalink
Hello everyone!

I was wondering why STD_FILES uses PLAIN_TEXT_FILE for input, output
and error, rather than IO_MEDIUM.

The reason I ask, is that doing so makes it difficult (and time
consuming) to redirect the output to a string. I found myself having to
create an ugly descendant of PLAIN_TEXT_FILE, which wrote to a string
instead of using the C file-output functions. It would have been more
elegant and quicker had IO_MEDIUM been the base class.

Has STD_FILES chosen too specific a type for these features? And is
there a better way of re-directing the io.output to a string?

Mark


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/eiffel_software/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/eiffel_software/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:eiffel_software-digest@...
    mailto:eiffel_software-fullfeatured@...

<*> To unsubscribe from this group, send an email to:
    eiffel_software-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Emmanuel Stapf
RE: Redirecting standard file output to a string.
Reply Threaded More
Print post
Permalink
> I was wondering why STD_FILES uses PLAIN_TEXT_FILE for input, output
> and error, rather than IO_MEDIUM.

Actually I'm not sure why. Most likely the plain text nature of the output has to
do with this. There are some features such as `flush' and `read_word' which are
useful but not present in IO_MEDIUM.
 
> The reason I ask, is that doing so makes it difficult (and time
> consuming) to redirect the output to a string. I found myself having to
> create an ugly descendant of PLAIN_TEXT_FILE, which wrote to a string
> instead of using the C file-output functions. It would have been more
> elegant and quicker had IO_MEDIUM been the base class.

Make sense.
 
> Has STD_FILES chosen too specific a type for these features? And is
> there a better way of re-directing the io.output to a string?

At the moment, I don't see an easy way.

Regards,
Manu



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/eiffel_software/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/eiffel_software/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:eiffel_software-digest@...
    mailto:eiffel_software-fullfeatured@...

<*> To unsubscribe from this group, send an email to:
    eiffel_software-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------  
rfo
RE: Redirecting standard file output to a string.
Reply Threaded More
Print post
Permalink
In reply to this post by marvin_littlewood_426716
Hi Manu!

I went back into the vault and found that STD_FILES actually used to use
IO_MEDIUM.
In fact, I had made use of that to define a new class BUFFER_MEDIUM to
support redirection of print statements for a macro facility feedback
mechanism.  It worked quite nicely as I recall.  I had my own version of
STD_FILEs that simply redefined a few things from the standard one and
excluded the original from my Ace file.
I guess is safe to assume that won't work anymore :)

     R

==================================================
Roger F. Osmond
----------------------------------------
Amalasoft Corporation
273 Harwood Avenue
Littleton, MA 01460

> -------- Original Message --------
> Subject: RE: [eiffel_software] Redirecting standard file output to a
> string.
> From: "Emmanuel Stapf [ES]" <manus@...>
> Date: Wed, July 23, 2008 6:37 pm
> To: <eiffel_software@...>
> > I was wondering why STD_FILES uses PLAIN_TEXT_FILE for input, output
> > and error, rather than IO_MEDIUM.
> Actually I'm not sure why. Most likely the plain text nature of the output has to
> do with this. There are some features such as `flush' and `read_word' which are
> useful but not present in IO_MEDIUM.
>  
> > The reason I ask, is that doing so makes it difficult (and time
> > consuming) to redirect the output to a string. I found myself having to
> > create an ugly descendant of PLAIN_TEXT_FILE, which wrote to a string
> > instead of using the C file-output functions. It would have been more
> > elegant and quicker had IO_MEDIUM been the base class.
> Make sense.
>  
> > Has STD_FILES chosen too specific a type for these features? And is
> > there a better way of re-directing the io.output to a string?
> At the moment, I don't see an easy way.
> Regards,
> Manu


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/eiffel_software/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/eiffel_software/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:eiffel_software-digest@...
    mailto:eiffel_software-fullfeatured@...

<*> To unsubscribe from this group, send an email to:
    eiffel_software-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Emmanuel Stapf
RE: Redirecting standard file output to a string.
Reply Threaded More
Print post
Permalink
> I went back into the vault and found that STD_FILES actually used to use
> IO_MEDIUM.

Out of curiosity I checked what I could. In 1990, it was using FILE, in 1993 it was using UNIX_FILE and was switched to PLAIN_TEXT_FILE in 1994. So I'm wondering from where you had IO_MEDIUM. Do you remember which version it was?

Regards,
Manu


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/eiffel_software/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/eiffel_software/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:eiffel_software-digest@...
    mailto:eiffel_software-fullfeatured@...

<*> To unsubscribe from this group, send an email to:
    eiffel_software-unsubscribe@...

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------  
marvin_littlewood_426716
Re: Redirecting standard file output to a string.
Reply Threaded More
Print post
Permalink
In reply to this post by Emmanuel Stapf
--- In eiffel_software@..., "Emmanuel Stapf [ES]"
<manus@...> wrote:
>
> > Has STD_FILES chosen too specific a type for these features? And
is
> > there a better way of re-directing the io.output to a string?
>
> At the moment, I don't see an easy way.
>
Hi Manu

Thanks for your comments. I was worried that I had missed something.
I think some of the ideas used in the C++ iostreams abstractions
could work quite well in Eiffel but I cannot see an obvious place to
follow this up.

Is this the correct place to discuss the libraries? If not, is there
another forum? (I noticed one discussing the ELKS libraries - if I
recall correctly - but found no new posts there.)

Thanks again

Mark

Emmanuel Stapf
RE: Re: Redirecting standard file output to a string.
Reply Threaded More
Print post
Permalink
> Is this the correct place to discuss the libraries? If not, is there
> another forum? (I noticed one discussing the ELKS libraries - if I
> recall correctly - but found no new posts there.)

FreeELKS on which EiffelBase relies has its own mailing list and I think we should
brings this issue there.

Regards,
Manu

------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------