blob: 8f8c10ff86c5ef44402d043ec47d238fe963f6f3 [file] [log] [blame]
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed
with this work for additional information regarding copyright
ownership. The ASF licenses this file to you under the Apache
License, Version 2.0 (the License); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License.
Copyright 1999-2007 Rogue Wave Software, Inc.
-->
<HTML>
<HEAD>
<TITLE>ostrstream</TITLE>
<LINK REL=StyleSheet HREF="../rw.css" TYPE="text/css" TITLE="Apache stdcxx Stylesheet"></HEAD>
<BODY BGCOLOR=#FFFFFF>
<A HREF="ostreambuf-iterator.html"><IMG SRC="images/bprev.gif" WIDTH=20 HEIGHT=21 ALT="Previous file" BORDER=O></A><A HREF="noframes.html"><IMG SRC="images/btop.gif" WIDTH=56 HEIGHT=21 ALT="Top of Document" BORDER=O></A><A HREF="booktoc.html"><IMG SRC="images/btoc.gif" WIDTH=56 HEIGHT=21 ALT="Contents" BORDER=O></A><A HREF="tindex.html"><IMG SRC="images/bindex.gif" WIDTH=56 HEIGHT=21 ALT="Index page" BORDER=O></A><A HREF="out-of-range.html"><IMG SRC="images/bnext.gif" WIDTH=25 HEIGHT=21 ALT="Next file" BORDER=O></A><DIV CLASS="DOCUMENTNAME"><B>Apache C++ Standard Library Reference Guide</B></DIV>
<H2>ostrstream</H2>
<P><B>Library:</B>&nbsp;&nbsp;<A HREF="2-11.html">Input/output</A></P>
<PRE><HR><B><I>ostrstream</I></B> <IMG SRC="images/inherits.gif"> <B><I><A HREF="basic-ostream.html">basic_ostream</A></I></B> <IMG SRC="images/inherits.gif"> <B><I><A HREF="basic-ios.html">basic_ios</A></I></B> <IMG SRC="images/inherits.gif"> <B><I><A HREF="ios-base.html">ios_base</A></I></B> <HR></PRE>
<UL>
<LI><A HREF="#sec1">Local Index</A></LI>
<LI><A HREF="#sec2">Summary</A></LI>
<LI><A HREF="#sec3">Synopsis</A></LI>
<LI><A HREF="#sec4">Description</A></LI>
<LI><A HREF="#sec5">Interface</A></LI>
<LI><A HREF="#sec6">Member Types</A></LI>
<LI><A HREF="#sec7">Constructors</A></LI>
<LI><A HREF="#sec8">Destructors</A></LI>
<LI><A HREF="#sec9">Member Functions</A></LI>
<LI><A HREF="#sec10">Example</A></LI>
<LI><A HREF="#sec11">See Also</A></LI>
<LI><A HREF="#sec12">Standards Conformance</A></LI>
</UL>
<A NAME="sec1"><H3>Local Index</H3></A>
<H4>Members</H4>
<UL><TABLE CELLPADDING=3>
<TR><TD VALIGN=top>
<A HREF="#idx1079">char_type</A><BR>
<A HREF="#idx1087">freeze()</A><BR>
<A HREF="#idx1080">int_type</A><BR>
</TD>
<TD VALIGN=top><A HREF="#idx1081">off_type</A><BR>
<A HREF="#idx1084">ostrstream()</A><BR>
<A HREF="#idx1088">pcount()</A><BR>
</TD>
<TD VALIGN=top><A HREF="#idx1082">pos_type</A><BR>
<A HREF="#idx1089">rdbuf()</A><BR>
<A HREF="#idx1090">str()</A><BR>
</TD>
<TD VALIGN=top><A HREF="#idx1083">traits_type</A><BR>
<A HREF="#idx1086">~ostrstream()</A><BR>
</TD></TR>
</TABLE></UL>
<A NAME="sec2"><H3>Summary</H3></A>
<P>Writes to an array in memory</P>
<A NAME="sec3"><H3>Synopsis</H3></A>
<PRE>#include &lt;strstream&gt;
namespace std {
class ostrstream;
}
</PRE>
<A NAME="sec4"><H3>Description</H3></A>
<P>The class <B><I>ostrstream</I></B> writes to an array in memory. It uses a private <B><I><A HREF="strstreambuf.html">strstreambuf</A></I></B> object to control the associated array object. It inherits from <B><I><A HREF="basic-ostream.html">basic_ostream</A></I></B>, and therefore can use all the formatted and unformatted output functions.</P>
<BLOCKQUOTE><HR><B>
NOTE -- This is a deprecated feature and might not be available in future versions.
</B><HR></BLOCKQUOTE>
<A NAME="sec5"><H3>Interface</H3></A>
<UL><PRE>namespace std {
class ostrstream
: public basic_ostream&lt;char&gt; {
public:
typedef char char_type;
typedef char_traits&lt;char_type&gt; traits_type;
typedef typename traits_type::int_type int_type;
typedef typename traits_type::pos_type pos_type;
typedef typename traits_type::off_type off_type;
ostrstream();
ostrstream(char *s, int n,
ios_base::openmode = ios_base::out);
virtual ~ostrstream();
strstreambuf *rdbuf() const;
void freeze(int freezefl = 1);
char *str();
int pcount() const;
};
}
</PRE></UL>
<A NAME="sec6"><H3>Member Types</H3></A>
<A NAME="idx1079"></A><PRE><B>char_type</B></PRE>
<UL>
<P>The type <SAMP>char_type</SAMP> is a synonym of type <SAMP>char</SAMP>.</P>
</UL>
<A NAME="idx1080"></A><PRE><B>int_type</B></PRE>
<UL>
<P>The type<SAMP> int_type</SAMP> is a synonym of type <SAMP>traits_type::in_type</SAMP>.</P>
</UL>
<A NAME="idx1081"></A><PRE><B>off_type</B></PRE>
<UL>
<P>The type <SAMP>off_type</SAMP> is a synonym of type <SAMP>traits_type::off_type</SAMP>.</P>
</UL>
<A NAME="idx1082"></A><PRE><B>pos_type</B></PRE>
<UL>
<P>The type <SAMP>pos_type</SAMP> is a synonym of type <SAMP>traits_type::pos_type</SAMP>.</P>
</UL>
<A NAME="idx1083"></A><PRE><B>traits_type</B></PRE>
<UL>
<P>The type <SAMP>traits_type</SAMP> is a synonym of type <SAMP>char_traits&lt;char&gt;</SAMP>.</P>
</UL>
<A NAME="sec7"><H3>Constructors</H3></A>
<A NAME="idx1084"></A><PRE><B>ostrstream</B>();</PRE>
<UL>
<P>Constructs an object of class <B><I>ostrstream</I></B>, initializing the base class <B><I><A HREF="basic-ostream.html">basic_ostream</A></I></B> with the associated <B><I><A HREF="strstreambuf.html">strstreambuf</A></I></B> object. The <B><I>strstreambuf</I></B> object is initialized by calling its default constructor <SAMP>strstreambuf()</SAMP>.</P>
</UL>
<A NAME="idx1085"></A><PRE><B>ostrstream</B>(char* s, int n, ios_base::openmode
mode = ios_base::out); </PRE>
<UL>
<P>Constructs an object of class <B><I>ostrstream</I></B>, initializing the base class <B><I><A HREF="basic-ostream.html">basic_ostream</A></I></B> with the associated <B><I><A HREF="strstreambuf.html">strstreambuf</A></I></B> object. The <B><I>strstreambuf</I></B> object is initialized by calling one of two constructors:</P>
<UL>
<LI><P CLASS="LIST">If <SAMP>mode &amp; app == 0</SAMP>, it calls <SAMP>strstreambuf(s,n,s)</SAMP></P></LI>
<LI><P CLASS="LIST">Otherwise it calls <SAMP>strstreambuf(s,n,s + ::strlen(s))</SAMP></P></LI>
</UL>
</UL>
<A NAME="sec8"><H3>Destructors</H3></A>
<A NAME="idx1086"></A><PRE>virtual <B>~ostrstream</B>();</PRE>
<UL>
<P>Destroys an object of class <B><I>ostrstream</I></B>. </P>
</UL>
<A NAME="sec9"><H3>Member Functions</H3></A>
<A NAME="idx1087"></A><PRE>void
<B>freeze</B>(bool freezefl = true); </PRE>
<UL>
<P>Calls <SAMP>rdbuf()-&gt;freeze(freezefl)</SAMP>.</P>
</UL>
<A NAME="idx1088"></A><PRE>int
<B>pcount</B>() const; </PRE>
<UL>
<P>Returns <SAMP>rdbuf()-&gt;pcount()</SAMP>.</P>
</UL>
<A NAME="idx1089"></A><PRE>strstreambuf*
<B>rdbuf</B>() const; </PRE>
<UL>
<P>Returns a pointer to the private <B><I><A HREF="strstreambuf.html">strstreambuf</A></I></B> object associated with the stream.</P>
</UL>
<A NAME="idx1090"></A><PRE>char*
<B>str</B>();</PRE>
<UL>
<P>Returns <SAMP>rdbuf()-&gt;str()</SAMP>.</P>
</UL>
<A NAME="sec10"><H3>Example</H3></A>
<P>See examples for <B><I><A HREF="strstream.html">strstream</A></I></B>, <B><I><A HREF="istrstream.html">istrstream</A></I></B>, and <B><I><A HREF="strstreambuf.html">strstreambuf</A></I></B>.</P>
<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="strstreambuf.html">strstreambuf</A></I></B>, <B><I><A HREF="istrstream.html">istrstream</A></I></B>, <B><I><A HREF="strstream.html">strstream</A></I></B></P>
<A NAME="sec12"><H3>Standards Conformance</H3></A>
<P><I>Deprecated. See ISO/IEC 14882:1998 -- International Standard for Information Systems --Programming Language C++,</I> Annex D Compatibility features Section D.7.3</P>
<BR>
<HR>
<A HREF="ostreambuf-iterator.html"><IMG SRC="images/bprev.gif" WIDTH=20 HEIGHT=21 ALT="Previous file" BORDER=O></A><A HREF="noframes.html"><IMG SRC="images/btop.gif" WIDTH=56 HEIGHT=21 ALT="Top of Document" BORDER=O></A><A HREF="booktoc.html"><IMG SRC="images/btoc.gif" WIDTH=56 HEIGHT=21 ALT="Contents" BORDER=O></A><A HREF="tindex.html"><IMG SRC="images/bindex.gif" WIDTH=56 HEIGHT=21 ALT="Index page" BORDER=O></A><A HREF="out-of-range.html"><IMG SRC="images/bnext.gif" WIDTH=20 HEIGHT=21 ALT="Next file" BORDER=O></A>
<!-- Google Analytics tracking code -->
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-1775151-1";
urchinTracker();
</script>
<!-- end of Google Analytics tracking code -->
</BODY>
</HTML>