faridz@apache.org wrote:
> Author: faridz
> Date: Mon Oct 22 11:08:09 2007
> New Revision: 587175
>
> URL: http://svn.apache.org/viewvc?rev=587175&view=rev
> Log:
> 2007-10-22 Farid Zaripov <farid_zaripov@epam.com>
>
> * strstreambuf.html: Updated the example source and
> the program output according to changes in r587173.
>
> Modified:
> incubator/stdcxx/branches/4.2.x/doc/stdlibref/strstreambuf.html
>
> Modified: incubator/stdcxx/branches/4.2.x/doc/stdlibref/strstreambuf.html
> URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/doc/stdlibref/strstreambuf.html?rev=587175&r1=587174&r2=587175&view=diff
> ==============================================================================
> --- incubator/stdcxx/branches/4.2.x/doc/stdlibref/strstreambuf.html (original)
> +++ incubator/stdcxx/branches/4.2.x/doc/stdlibref/strstreambuf.html Mon Oct 22 11:08:09
2007
> @@ -335,9 +335,12 @@
> //
>
> #include <iomanip> // for setw
> -#include <iostream> // for cerr, cout, endl
> +#include <ios> // for dec, ends
> +#include <iostream> // for cerr, cout
> #include <strstream> // for istream, ostrstream
>
> +#include <examples.h>
We don't want to show this last #include directive in the
documentation (it's just an implementation detail, a hack really,
to get the examples to compile even with non-conforming compilers).
Also, see http://issues.apache.org/jira/browse/STDCXX-425.
Martin
> +
>
> int main ()
> {
> @@ -348,21 +351,19 @@
> std::istream in (out.rdbuf ());
>
> // output to out
> - out << "Anticonstitutionellement is a big word!!!\n";
> + out << "Anticonstitutionnellement is a big word!!!\n";
>
> // create a NTBS
> const char s[] ="Le rat des villes et le rat des champs.";
>
> // output the NTBS
> - out << s << std::endl;
> + out << s << '\n';
>
> // (try to) resize the buffer
> - if (out.rdbuf ()->pubsetbuf (0, 5000))
> - std::cout << "Successfully allocated buffer."
> - << std::endl;
> + if (out.rdbuf ()->pubsetbuf (0, 128L))
> + std::cout << "Successfully allocated buffer.\n";
> else
> - std::cerr << "Failed to allocate buffer."
> - << std::endl;
> + std::cerr << "Failed to allocate buffer.\n";
>
> // output the contents of the buffer to standard output
> std::cout << in.rdbuf ();
> @@ -371,28 +372,31 @@
> out << std::dec // decimal base
> << std::setfill ('#') // set fill character
> << std::setw (16) // set field width
> - << 0x100 << std::endl; // format
> + << 0x100 << '\n'; // format
>
> - // output the content of the input sequence to
> - // standard output
> - std::cout << in.rdbuf( ) << std::endl;
> + // output the content of the input sequence to standard output
> + std::cout << in.rdbuf( ) << '\n';
>
> // number of elements in the output sequence
> - std::cout << "Buffer size is " << out.rdbuf ()->pcount
()
> - << std::endl;
> + const std::streamsize pcount = std::streamsize (out.rdbuf ()->pcount ());
> +
> + std::cout << "Buffer size is " << pcount <<
'\n';
>
> - // (try to) resize the buffer to a minimum size
> - if (out.rdbuf()->pubsetbuf (0,out.rdbuf()->pcount() + 1))
> - std::cout << std::endl
> - << "Successfully resized buffer."
> - << std::endl;
> + // (try to) resize the buffer
> + if (out.rdbuf ()->pubsetbuf (0, pcount * 2L))
> + std::cout << "\nSuccessfully resized buffer to " <<
pcount * 2 << '\n';
> else
> - std::cerr << "Failed to resize buffer." << std::endl;
> + std::cerr << "\nFailed to resize buffer to " <<
pcount * 2 << '\n';
>
> - // output the contents of the streambuf object
> - // associated with out
> + // NUL-terminate the character array before streaming it out
> + out << std::ends;
> +
> + // output the contents of the streambuf object associated with out
> std::cout << out.rdbuf ()->str ();
>
> + // unfreeze the streambuf so it cleans up its allocated memory
> + out.rdbuf ()->freeze (false);
> +
> return 0;
> }
>
> @@ -402,6 +406,14 @@
> <UL><PRE>Successfully allocated buffer.
> Anticonstitutionnellement is a big word!!!
> Le rat des villes et le rat des champs.
> +#############256
> +
> +Buffer size is 100
> +
> +Successfully resized buffer to 200
> +Anticonstitutionnellement is a big word!!!
> +Le rat des villes et le rat des champs.
> +#############256
> </PRE></UL>
> <A NAME="sec11"><H3>See Also</H3></A>
> <P><B><I><A HREF="char-traits.html">char_traits</A></I></B>,
<B><I><A HREF="ios-base.html">ios_base</A></I></B>, <B><I><A
HREF="basic-ios.html">basic_ios</A></I></B>, <B><I><A
HREF="basic-streambuf.html">basic_streambuf</A></I></B>, <B><I><A
HREF="istrstream.html">istrstream</A></I></B>, <B><I><A
HREF="ostrstream.html">ostrstream</A></I></B>, <B><I><A
HREF="strstream.html">strstream</A></I></B></P>
>
>
|