Topic: Deprecated strstream replacement


Author: "Sebastian Moleski" <sebmol@gmx.net>
Date: Sun, 15 Oct 2000 03:35:41 GMT
Raw View
The Standard offers stringstream as an alternative. So I don't see a problem
with deprecating the old strstreams.

sm


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]





Author: remove.haberg@matematik.su.se (Hans Aberg)
Date: 2000/10/15
Raw View
In article <MPG.145198007342910f98b905@news.mindspring.com>,
brahms@mindspring.com (Stan Brown) wrote:
>I understand your frustration that the standard does not say why
>strstreams are deprecated, but then it generally does not explain
>the reasons for any of the decisions. That's not the job of the
>standard. (The C89 standard did have an accompanying Rationale to
>explain the committee's decisions.)

In view that a replacement exists, stringstream, which works together with
the string class instead of the old C strings, it would suffice to point
that out, and no further explanations would be needed.

But otherwise, if you look into the Appendix C, compatibility with ISO C,
you will find fairly detailed explanations there.

It is a good idea for the standard to provide sufficiently with hints that
the reader quickly can be coordinated.

  Hans Aberg      * Anti-spam: remove "remove." from email address.
                  * Email: Hans Aberg <remove.haberg@member.ams.org>
                  * Home Page: <http://www.matematik.su.se/~haberg/>
                  * AMS member listing: <http://www.ams.org/cml/>

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: kuehl@ramsen.informatik.uni-konstanz.de (Dietmar Kuehl)
Date: 2000/10/16
Raw View
Hi,
Sebastian Moleski (sebmol@gmx.net) wrote:
: The Standard offers stringstream as an alternative. So I don't see a problem
: with deprecating the old strstreams.

Well, the string stream replacements does not provide the possibility
to use a user provided buffer for reading or writing. This is sometimes
desirable to avoid memory allocation and copying of the contents. This
can be done with the deprecated 'char*' streams. However, it is easy to
create a stream buffer specialized for this (takes maybe 30 lines of
code).
--
<mailto:dietmar_kuehl@yahoo.de>
<http://www.fmi.uni-konstanz.de/~kuehl/>
I am a realistic optimist - that's why I appear to be slightly pessimistic

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: remove.haberg@matematik.su.se (Hans Aberg)
Date: 2000/10/13
Raw View
The strstream's classes are deprecated in the C++ standard.

The question is though if one wants to use streams parsing/printing on
strings just to ensure that the result is exactly the same as in the case
of other streams, what is one expected to use? -- The C++ standard does
not explain the reason for deprecraction, nor does it indicate suitable
replacements, a weakness, I think.

[It is OK for me that practical how-to-do it followups are posted to
comp.lang.c++.moderated.]

  Hans Aberg      * Anti-spam: remove "remove." from email address.
                  * Email: Hans Aberg <remove.haberg@member.ams.org>
                  * Home Page: <http://www.matematik.su.se/~haberg/>
                  * AMS member listing: <http://www.ams.org/cml/>

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: James Kuyper <kuyper@wizard.net>
Date: 2000/10/14
Raw View
Hans Aberg wrote:
>
> The strstream's classes are deprecated in the C++ standard.
>
> The question is though if one wants to use streams parsing/printing on
> strings just to ensure that the result is exactly the same as in the case
> of other streams, what is one expected to use? -- The C++ standard does
> not explain the reason for deprecraction, nor does it indicate suitable
> replacements, a weakness, I think.

I agree, any deprecated feature's description should contain a cross
reference to the preferred replacement. In this case, it's
std::stringstream.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: brahms@mindspring.com (Stan Brown)
Date: 2000/10/14
Raw View
Hans Aberg <haberg@matematik.su.se> wrote in comp.std.c++:
>The question is though if one wants to use streams parsing/printing on
>strings just to ensure that the result is exactly the same as in the case
>of other streams, what is one expected to use? -- The C++ standard does
>not explain the reason for deprecation, nor does it indicate suitable
>replacements, a weakness, I think.

>From the standard:

 [depr.str.strstreams] D.7 char* streams
 1 The header <strstream> defines three types that associate
   stream buffers with character array objects and assist
   reading and writing such objects.

>From this I conclude that strstreams are deprecated because they use
character arrays instead of real strings (and possibly for other
reasons left unstated).

I understand your frustration that the standard does not say why
strstreams are deprecated, but then it generally does not explain
the reasons for any of the decisions. That's not the job of the
standard. (The C89 standard did have an accompanying Rationale to
explain the committee's decisions.)

Since a number of committee members read this newsgroup, perhaps one
of them will let us know if there were any other factors in the
deprecation, beside the use of character arrays.

The standard doesn't give any guidance in that subclause, as far as
I could see, but the preferred replacement is stringstreams, using
the header <sstream>:

 [lib.string.streams] 27.7 String   based streams
 1 The header <sstream> defines four template classes, and six
   types, that associate stream buffers with objects of class
   basic_string, as described in 21.2.

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
                                  http://oakroadsystems.com
C++ FAQ Lite: http://www.parashift.com/c++-faq-lite/
the C++ standard: http://webstore.ansi.org/
reserved C++ identifiers: http://oakroadsystems.com/tech/cppredef.htm
more FAQs: http://oakroadsystems.com/tech/faqget.htm

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: sirwillard@my-deja.com
Date: 2000/10/14
Raw View
In article <remove.haberg-1310002038520001@du138-226.ppp.su-
anst.tninet.se>,
  remove.haberg@matematik.su.se (Hans Aberg) wrote:
> The strstream's classes are deprecated in the C++ standard.
>
> The question is though if one wants to use streams parsing/printing on
> strings just to ensure that the result is exactly the same as in the
case
> of other streams, what is one expected to use? -- The C++ standard
does
> not explain the reason for deprecraction, nor does it indicate
suitable
> replacements, a weakness, I think.

strstream was deprecated in favor of stringstream, found in <sstream>.

--
William E. Kempf
Software Engineer, MS Windows Programmer


Sent via Deja.com http://www.deja.com/
Before you buy.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: joerg.barfurth@attglobal.net (Joerg Barfurth)
Date: 2000/10/14
Raw View
Hans Aberg <remove.haberg@matematik.su.se> wrote:

> The strstream's classes are deprecated in the C++ standard.
>=20
> The question is though if one wants to use streams parsing/printing on
> strings just to ensure that the result is exactly the same as in the ca=
se
> of other streams, what is one expected to use?

Ever looked at <sstream> ? Use [i|o]stringstream

> -- The C++ standard does
> not explain the reason for deprecraction, nor does it indicate suitable
> replacements, a weakness, I think.

Just guessing (as I was not on the committee):

If you look at strstream and stringstream, you'll find that stringstream
works smoothly with std::string, while strstream is more oriented
towards buffers and C-style strings.

But much more serious is the undecided stance of strstream towards
ownership of the streams' contents. To call the resulting behavior
error-prone would still be an understatement (IMO):

HTH, J=F6rg

--=20
J=F6rg Barfurth                         joerg.barfurth@attglobal.net
-------------- using std::disclaimer; -----------------------------
Download:     StarOffice 5.2 at       http://www.sun.com/staroffice
Participate:  OpenOffice now at       http://www.OpenOffice.org

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]