You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by fa...@apache.org on 2007/10/22 20:08:10 UTC

svn commit: r587175 - /incubator/stdcxx/branches/4.2.x/doc/stdlibref/strstreambuf.html

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 <fa...@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 &lt;iomanip&gt;     // for setw
-#include &lt;iostream&gt;    // for cerr, cout, endl
+#include &lt;ios&gt;         // for dec, ends
+#include &lt;iostream&gt;    // for cerr, cout
 #include &lt;strstream&gt;   // for istream, ostrstream
 
+#include &lt;examples.h&gt;
+
 
 int main ()
 {
@@ -348,21 +351,19 @@
     std::istream in (out.rdbuf ());   
 
     // output to out
-    out &lt;&lt; "Anticonstitutionellement is a big word!!!\n";
+    out &lt;&lt; "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 &lt;&lt; s &lt;&lt; std::endl;   
+    out &lt;&lt; s &lt;&lt; '\n';
 
     // (try to) resize the buffer
-    if (out.rdbuf ()-&gt;pubsetbuf (0, 5000))
-        std::cout &lt;&lt; "Successfully allocated buffer." 
-                  &lt;&lt; std::endl;
+    if (out.rdbuf ()-&gt;pubsetbuf (0, 128L))
+        std::cout &lt;&lt; "Successfully allocated buffer.\n";
     else
-        std::cerr &lt;&lt; "Failed to allocate buffer." 
-                  &lt;&lt; std::endl;
+        std::cerr &lt;&lt; "Failed to allocate buffer.\n";
 
     // output the contents of the buffer to standard output
     std::cout &lt;&lt; in.rdbuf ();
@@ -371,28 +372,31 @@
     out &lt;&lt; std::dec              // decimal base
         &lt;&lt; std::setfill ('#')    // set fill character
         &lt;&lt; std::setw (16)        // set field width
-        &lt;&lt; 0x100 &lt;&lt; std::endl;   // format
+        &lt;&lt; 0x100 &lt;&lt; '\n';        // format
   
-    // output the content of the input sequence to 
-    // standard output
-    std::cout &lt;&lt; in.rdbuf( ) &lt;&lt; std::endl;
+    // output the content of the input sequence to standard output
+    std::cout &lt;&lt; in.rdbuf( ) &lt;&lt; '\n';
 
     // number of elements in the output sequence
-    std::cout &lt;&lt; "Buffer size is " &lt;&lt; out.rdbuf ()-&gt;pcount ()
-              &lt;&lt; std::endl;
+    const std::streamsize pcount = std::streamsize (out.rdbuf ()-&gt;pcount ());
+
+    std::cout &lt;&lt; "Buffer size is " &lt;&lt; pcount &lt;&lt; '\n';
 
-    // (try to) resize the buffer to a minimum size
-    if (out.rdbuf()-&gt;pubsetbuf (0,out.rdbuf()-&gt;pcount() + 1))
-        std::cout &lt;&lt; std::endl 
-                  &lt;&lt; "Successfully resized buffer." 
-                  &lt;&lt; std::endl;
+    // (try to) resize the buffer
+    if (out.rdbuf ()-&gt;pubsetbuf (0, pcount * 2L))
+        std::cout &lt;&lt; "\nSuccessfully resized buffer to " &lt;&lt; pcount * 2 &lt;&lt; '\n';
     else
-        std::cerr &lt;&lt; "Failed to resize buffer." &lt;&lt; std::endl;
+        std::cerr &lt;&lt; "\nFailed to resize buffer to " &lt;&lt; pcount * 2 &lt;&lt; '\n';
 
-    // output the contents of the streambuf object 
-    // associated with out
+    // NUL-terminate the character array before streaming it out
+    out &lt;&lt; std::ends;
+
+    // output the contents of the streambuf object associated with out
     std::cout &lt;&lt; out.rdbuf ()-&gt;str ();
 
+    // unfreeze the streambuf so it cleans up its allocated memory
+    out.rdbuf ()-&gt;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>



RE: svn commit: r587175 - /incubator/stdcxx/branches/4.2.x/doc/stdlibref/strstreambuf.html

Posted by Martin Sebor <se...@roguewave.com>.

Farid Zaripov-2 wrote:
> 
>> -----Original Message-----
>> From: Martin Sebor [mailto:sebor@roguewave.com] 
>> Sent: Monday, October 22, 2007 9:33 PM
>> To: stdcxx-dev@incubator.apache.org
>> Subject: Re: svn commit: r587175 - 
>> /incubator/stdcxx/branches/4.2.x/doc/stdlibref/strstreambuf.html
>> 
>> > +#include &lt;examples.h&gt;
>> 
>> 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.
> 
>   Fixed thus: http://svn.apache.org/viewvc?rev=587464&view=rev
> 
> Farid.
> 
> 

I had no idea we alreeady had the #include directives on so many
other pages. Thanks for cleaning it up!

Martin
-- 
View this message in context: http://www.nabble.com/Re%3A-svn-commit%3A-r587175----incubator-stdcxx-branches-4.2.x-doc-stdlibref-strstreambuf.html-tf4672865.html#a13367854
Sent from the stdcxx-dev mailing list archive at Nabble.com.


RE: svn commit: r587175 - /incubator/stdcxx/branches/4.2.x/doc/stdlibref/strstreambuf.html

Posted by Farid Zaripov <Fa...@epam.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Monday, October 22, 2007 9:33 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: svn commit: r587175 - 
> /incubator/stdcxx/branches/4.2.x/doc/stdlibref/strstreambuf.html
> 
> > +#include &lt;examples.h&gt;
> 
> 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.

  Fixed thus: http://svn.apache.org/viewvc?rev=587464&view=rev

Farid.

Re: svn commit: r587175 - /incubator/stdcxx/branches/4.2.x/doc/stdlibref/strstreambuf.html

Posted by Martin Sebor <se...@roguewave.com>.
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 <fa...@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 &lt;iomanip&gt;     // for setw
> -#include &lt;iostream&gt;    // for cerr, cout, endl
> +#include &lt;ios&gt;         // for dec, ends
> +#include &lt;iostream&gt;    // for cerr, cout
>  #include &lt;strstream&gt;   // for istream, ostrstream
>  
> +#include &lt;examples.h&gt;

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 &lt;&lt; "Anticonstitutionellement is a big word!!!\n";
> +    out &lt;&lt; "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 &lt;&lt; s &lt;&lt; std::endl;   
> +    out &lt;&lt; s &lt;&lt; '\n';
>  
>      // (try to) resize the buffer
> -    if (out.rdbuf ()-&gt;pubsetbuf (0, 5000))
> -        std::cout &lt;&lt; "Successfully allocated buffer." 
> -                  &lt;&lt; std::endl;
> +    if (out.rdbuf ()-&gt;pubsetbuf (0, 128L))
> +        std::cout &lt;&lt; "Successfully allocated buffer.\n";
>      else
> -        std::cerr &lt;&lt; "Failed to allocate buffer." 
> -                  &lt;&lt; std::endl;
> +        std::cerr &lt;&lt; "Failed to allocate buffer.\n";
>  
>      // output the contents of the buffer to standard output
>      std::cout &lt;&lt; in.rdbuf ();
> @@ -371,28 +372,31 @@
>      out &lt;&lt; std::dec              // decimal base
>          &lt;&lt; std::setfill ('#')    // set fill character
>          &lt;&lt; std::setw (16)        // set field width
> -        &lt;&lt; 0x100 &lt;&lt; std::endl;   // format
> +        &lt;&lt; 0x100 &lt;&lt; '\n';        // format
>    
> -    // output the content of the input sequence to 
> -    // standard output
> -    std::cout &lt;&lt; in.rdbuf( ) &lt;&lt; std::endl;
> +    // output the content of the input sequence to standard output
> +    std::cout &lt;&lt; in.rdbuf( ) &lt;&lt; '\n';
>  
>      // number of elements in the output sequence
> -    std::cout &lt;&lt; "Buffer size is " &lt;&lt; out.rdbuf ()-&gt;pcount ()
> -              &lt;&lt; std::endl;
> +    const std::streamsize pcount = std::streamsize (out.rdbuf ()-&gt;pcount ());
> +
> +    std::cout &lt;&lt; "Buffer size is " &lt;&lt; pcount &lt;&lt; '\n';
>  
> -    // (try to) resize the buffer to a minimum size
> -    if (out.rdbuf()-&gt;pubsetbuf (0,out.rdbuf()-&gt;pcount() + 1))
> -        std::cout &lt;&lt; std::endl 
> -                  &lt;&lt; "Successfully resized buffer." 
> -                  &lt;&lt; std::endl;
> +    // (try to) resize the buffer
> +    if (out.rdbuf ()-&gt;pubsetbuf (0, pcount * 2L))
> +        std::cout &lt;&lt; "\nSuccessfully resized buffer to " &lt;&lt; pcount * 2 &lt;&lt; '\n';
>      else
> -        std::cerr &lt;&lt; "Failed to resize buffer." &lt;&lt; std::endl;
> +        std::cerr &lt;&lt; "\nFailed to resize buffer to " &lt;&lt; pcount * 2 &lt;&lt; '\n';
>  
> -    // output the contents of the streambuf object 
> -    // associated with out
> +    // NUL-terminate the character array before streaming it out
> +    out &lt;&lt; std::ends;
> +
> +    // output the contents of the streambuf object associated with out
>      std::cout &lt;&lt; out.rdbuf ()-&gt;str ();
>  
> +    // unfreeze the streambuf so it cleans up its allocated memory
> +    out.rdbuf ()-&gt;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>
> 
>