X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=libstdc%2B%2B-v3%2Fdoc%2Fhtml%2Fmanual%2Fstringstreams.html;fp=libstdc%2B%2B-v3%2Fdoc%2Fhtml%2Fmanual%2Fstringstreams.html;h=ccd6fdd4860892aa3dd8f6dd55f6a2b30a7f42b2;hb=6fed43773c9b0ce596dca5686f37ac3fc0fa11c0;hp=0000000000000000000000000000000000000000;hpb=27b11d56b743098deb193d510b337ba22dc52e5c;p=msp430-gcc.git diff --git a/libstdc++-v3/doc/html/manual/stringstreams.html b/libstdc++-v3/doc/html/manual/stringstreams.html new file mode 100644 index 00000000..ccd6fdd4 --- /dev/null +++ b/libstdc++-v3/doc/html/manual/stringstreams.html @@ -0,0 +1,37 @@ + + +
Table of Contents
+
Stringstreams (defined in the header <sstream>
)
+ are in this author's opinion one of the coolest things since
+ sliced time. An example of their use is in the Received Wisdom
+ section for Chapter 21 (Strings),
+ describing how to
+ format strings.
+
The quick definition is: they are siblings of ifstream and ofstream,
+ and they do for std::string
what their siblings do for
+ files. All that work you put into writing <<
and
+ >>
functions for your classes now pays off
+ again! Need to format a string before passing the string
+ to a function? Send your stuff via <<
to an
+ ostringstream. You've read a string as input and need to parse it?
+ Initialize an istringstream with that string, and then pull pieces
+ out of it with >>
. Have a stringstream and need to
+ get a copy of the string inside? Just call the str()
+ member function.
+
This only works if you've written your
+ <<
/>>
functions correctly, though,
+ and correctly means that they take istreams and ostreams as
+ parameters, not ifstreams and ofstreams. If they
+ take the latter, then your I/O operators will work fine with
+ file streams, but with nothing else -- including stringstreams.
+
If you are a user of the strstream classes, you need to update
+ your code. You don't have to explicitly append ends
to
+ terminate the C-style character array, you don't have to mess with
+ "freezing" functions, and you don't have to manage the
+ memory yourself. The strstreams have been officially deprecated,
+ which means that 1) future revisions of the C++ Standard won't
+ support them, and 2) if you use them, people will laugh at you.
+