www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Canonical/Idiomatic in memory files

reply Russel Winder <russel winder.org.uk> writes:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi,

I think I am missing something very obvious=E2=80=A6

For unit tests I want a std.stdio.File object that is backed by an in
memory string buffer rather than an actual file on disc, be it temporary
or otherwise.  I think I am missing where this is documented in the
documentation. Or is it actually not available?

Thanks.

--=20
Russel.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder ekiga.n=
et
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
May 28 2013
next sibling parent reply Martin Nowak <code dawg.eu> writes:
On 05/28/2013 05:04 PM, Russel Winder wrote:
 Hi,

 I think I am missing something very obvious…

 For unit tests I want a std.stdio.File object that is backed by an in
 memory string buffer rather than an actual file on disc, be it temporary
 or otherwise.  I think I am missing where this is documented in the
 documentation. Or is it actually not available?

 Thanks.

http://dlang.org/phobos/std_stream.html#.MemoryStream.
May 28 2013
next sibling parent Paulo Pinto <pjmlp progtools.org> writes:
Am 29.05.2013 06:48, schrieb Russel Winder:
 On Tue, 2013-05-28 at 19:51 +0200, Martin Nowak wrote:
 […]
 This is only available for std.stream
 http://dlang.org/phobos/std_stream.html#.MemoryStream.

This package has a big red "deprecated" notice, so I didn't look at it. Is this an indication that I should? Is there a planned replacement?

Actually I am also making heavy use of it, as I am porting to D a Java based application that uses streams. Relying on std.stream makes the porting easier, but I am also wondering about it. -- Paulo
May 29 2013
prev sibling parent Martin Nowak <code dawg.eu> writes:
On 05/29/2013 06:48 AM, Russel Winder wrote:
 Is there a planned replacement?

May 29 2013
prev sibling next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 5/28/2013 8:04 AM, Russel Winder wrote:
 Hi,

 I think I am missing something very obvious…

 For unit tests I want a std.stdio.File object that is backed by an in
 memory string buffer rather than an actual file on disc, be it temporary
 or otherwise.  I think I am missing where this is documented in the
 documentation. Or is it actually not available?

Part of the idea of using ranges is you can switch to a memory buffer instead of an actual file.
May 28 2013
prev sibling parent Russel Winder <russel winder.org.uk> writes:
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Tue, 2013-05-28 at 19:51 +0200, Martin Nowak wrote:
[=E2=80=A6]
 This is only available for std.stream=20
 http://dlang.org/phobos/std_stream.html#.MemoryStream.

This package has a big red "deprecated" notice, so I didn't look at it. Is this an indication that I should? Is there a planned replacement? --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
May 28 2013