⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 strstrea.html

📁 ST20 Embedded Toolset R2.0.5用于开发基于ST20芯片机顶盒软件的开发平台,2.0.5版本,国内找不到的.在国外论坛上花了N天才找到!
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<HTML><HEAD><TITLE>&lt;strstream&gt;</TITLE></HEAD><BODY><H1><A NAME="&lt;strstream&gt;"><CODE>&lt;strstream&gt;</CODE></A></H1><HR><P>Include the <A HREF="lib_cpp.html#iostreams">iostreams</A>standard header <B><CODE>&lt;strstream&gt;</CODE></B>to define several classes that supportiostreams operations onsequences stored in an allocated array of <I>char</I> object.Such sequences are easily converted to and from<A HREF="lib_over.html#C string">C strings</A>.</P><PRE>        // DECLARATIONSclass <B><A HREF="#strstreambuf">strstreambuf</A></B>;class <B><A HREF="#istrstream">istrstream</A></B>;class <B><A HREF="#ostrstream">ostrstream</A></B>;        // END OF DECLARATIONS</PRE><H2><A NAME="strstreambuf"><CODE>strstreambuf</CODE></A></H2><PRE>class <B>strstreambuf</B> : public streambuf {public:    explicit <B><A HREF="#strstreambuf::strstreambuf">strstreambuf</A></B>(streamsize count = 0);    <B><A HREF="#strstreambuf::strstreambuf">strstreambuf</A></B>(void (*allocfunc)(size_t),        void (*freefunc)(void *));    <B><A HREF="#strstreambuf::strstreambuf">strstreambuf</A></B>(char *getptr, streamsize count,        char *putptr = 0);    <B><A HREF="#strstreambuf::strstreambuf">strstreambuf</A></B>(signed char *getptr, streamsize count,        signed char *putptr = 0);    <B><A HREF="#strstreambuf::strstreambuf">strstreambuf</A></B>(unsigned char *getptr, streamsize count,        unsigned char *putptr = 0);    <B><A HREF="#strstreambuf::strstreambuf">strstreambuf</A></B>(const char *getptr, streamsize count);    <B><A HREF="#strstreambuf::strstreambuf">strstreambuf</A></B>(const signed char *getptr, streamsize count);    <B><A HREF="#strstreambuf::strstreambuf">strstreambuf</A></B>(const unsigned char *getptr, streamsize count);    void <B><A HREF="#strstreambuf::freeze">freeze</A></B>(bool freezeit = true);    char *<B><A HREF="#strstreambuf::str">str</A></B>();    streamsize <B><A HREF="#strstreambuf::pcount">pcount</A></B>();protected:    virtual streampos <B><A HREF="#strstreambuf::seekoff">seekoff</A></B>(streamoff off,        ios_base::seekdir way,        ios_base::openmode which =            ios_base::in | ios_base::out);    virtual streampos <B><A HREF="#strstreambuf::seekpos">seekpos</A></B>(streampos sp,        ios_base::openmode which =            ios_base::in | ios_base::out);    virtual int <B><A HREF="#strstreambuf::underflow">underflow</A></B>();    virtual int <B><A HREF="#strstreambuf::pbackfail">pbackfail</A></B>(int meta = EOF);    virtual int <B><A HREF="#strstreambuf::overflow">overflow</A></B>(int meta = EOF);    };</PRE><P>The class describes a<B><A HREF="streambu.html#stream buffer">stream buffer</A></B> that controlsthe transmission of elements to and from a sequence of elementsstored in a <I>char</I> array object. Depending on how itis constructed, the object can be allocated, extended, andfreed as necessary to accommodate changes in the sequence.</P><P>An object of class <CODE>strstreambuf</CODE>stores several bits of mode information as its<B><A NAME="strstreambuf mode">strstreambuf mode</A></B>.These bits indicate whether the controlled sequence:</P><UL><LI>has been <B>allocated</B>,and hence needs to be freed eventually</LI><LI>is <B>modifiable</B></LI><LI>is <B>extendable</B> by reallocating storage</LI><LI>has been <B>frozen</B>and hence needs to be unfrozen before the object is destroyed,or freed (if allocated) by an agency other than the object</LI></UL><P>A controlled sequence that is frozen cannot be modified or extended,regardless of the state of these separate mode bits.</P><P>The object also stores pointers to two functions that control<B><A NAME="strstreambuf allocation">strstreambuf allocation</A></B>.If these are null pointers, the object devises its own methodof allocating and freeing storage for the controlled sequence.</P><H3><A NAME="strstreambuf::freeze"><CODE>strstreambuf::freeze</CODE></A></H3><PRE>void <B><A HREF="#strstreambuf::freeze">freeze</A></B>(bool freezeit = true);</PRE><P>If <CODE>freezeit</CODE> is true, the function alters the stored<A HREF="#strstreambuf mode">strstreambuf mode</A> to make thecontrolled sequence frozen. Otherwise, it makes the controlledsequence not frozen.</P><H3><A NAME="strstreambuf::pcount"><CODE>strstreambuf::pcount</CODE></A></H3><PRE>streamsize <B>pcount</B>();</PRE><P>The member function returns a count of the number of elementswritten to the controlled sequence. Specifically, if<CODE><A HREF="streambu.html#streambuf::pptr">pptr</A>()</CODE> is anull pointer, the function returns zero. Otherwise, it returns<CODE>pptr() -<A HREF="streambu.html#streambuf::pbase">pbase</A>()</CODE>.</P><H3><A NAME="strstreambuf::overflow"><CODE>strstreambuf::overflow</CODE></A></H3><PRE>virtual int <B>overflow</B>(int meta = EOF);</PRE><P>If <CODE>meta != <A HREF="stdio.html#EOF">EOF</A></CODE>,the protected virtual member function endeavors to insert the element<CODE>(char)meta</CODE>into the<A HREF="streambu.html#output buffer">output buffer</A>.It can do so in various ways:</P><UL><LI>If a <A HREF="streambu.html#write position">write position</A>is available, it can store the element into the write positionand increment the next pointer for the output buffer.</LI><LI>If the stored<A HREF="#strstreambuf mode">strstreambuf mode</A> says thecontrolled sequence is modifiable, extendable, and not frozen,the function can make a write position available by allocatingnew for the output buffer. (Extending theoutput buffer this way also extends any associated<A HREF="streambu.html#input buffer">input buffer</A>.)</LI></UL><P>If the function cannot succeed, it returns<CODE>EOF</CODE>. Otherwise, if <CODE>meta == EOF</CODE> it returns somevalue other than <CODE>EOF</CODE>. Otherwise, it returns <CODE>meta</CODE>.</P><H3><A NAME="strstreambuf::pbackfail"><CODE>strstreambuf::pbackfail</CODE></A></H3><PRE>virtual int <B>pbackfail</B>(int meta = EOF);</PRE><P>The protected virtual member function endeavors to put back an elementinto the<A HREF="streambu.html#input buffer">input buffer</A>,then make it the current element (pointed toby the next pointer).<P>If <CODE>meta == <A HREF="stdio.html#EOF">EOF</A></CODE>,the element to push back is effectively the one already in the streambefore the current element. Otherwise, that element is replaced by<CODE>ch = (char)meta</CODE>.The function can put back an element in various ways:</P><UL><LI>If a <A HREF="streambu.html#putback position">putback position</A>is available, and the element stored there compares equal to <CODE>ch</CODE>,it can simply decrement the next pointer for the input buffer.</LI><LI>If a putback position is available,and if the <A HREF="#strstreambuf mode">strstreambuf mode</A>says the controlled sequence is modifiable, the functioncan store <CODE>ch</CODE> into the putback position and decrement thenext pointer for the input buffer.</LI></UL><P>If the function cannot succeed, it returns<CODE>EOF</CODE>. Otherwise, if <CODE>meta == EOF</CODE> it returns somevalue other than <CODE>EOF</CODE>. Otherwise, it returns <CODE>meta</CODE>.</P><H3><A NAME="strstreambuf::seekoff"><CODE>strstreambuf::seekoff</CODE></A></H3><PRE>virtual streampos <B>seekoff</B>(streamoff off,    ios_base::seekdir way,    ios_base::openmode which =        ios_base::in | ios_base::out);</PRE><P>The protected virtual member function endeavors to alter the currentpositions for the controlled streams. For an object of class<CODE>strstreambuf</CODE>, a stream position consistspurely of a stream offset. Offset zero designates the first elementof the controlled sequence.</P><P>The new position is determined as follows:</P><UL><LI>If <CODE>way ==ios_base::<A HREF="ios.html#ios_base::beg">beg</A></CODE>,the new position is the beginning of the stream plus <CODE>off</CODE>.<LI>If <CODE>way ==ios_base::<A HREF="ios.html#ios_base::cur">cur</A></CODE>,the new position is the current stream position plus <CODE>off</CODE>.<LI>If <CODE>way ==ios_base::<A HREF="ios.html#ios_base::end">end</A></CODE>,the new position is the end of the stream plus <CODE>off</CODE>.</UL><P>If<CODE>which &amp; ios_base::in</CODE> is nonzero andthe input buffer exist,the function alters the next position to read in the<A HREF="streambu.html#input buffer">input buffer</A>.If <CODE>which &amp; ios_base::out</CODE> is also nonzero,<CODE>way != ios_base::cur</CODE>,and the output buffer exists,the function also sets the next position to write tomatch the next position to read.</P><P>Otherwise, if <CODE>which &amp; ios_base::out</CODE> is nonzeroand the output buffer exists,the function alters the next position to write in the<A HREF="streambu.html#output buffer">output buffer</A>.Otherwise, the positioning operation fails.For a positioning operation to succeed, the resultingstream position must lie within the controlled sequence.</P><P>If the function succeeds in altering either or both stream positions,it returns the resultant stream position.Otherwise, it fails and returns an invalid stream position.</P><H3><A NAME="strstreambuf::seekpos"><CODE>strstreambuf::seekpos</CODE></A></H3><PRE>virtual streampos <B>seekpos</B>(streampos sp,    ios_base::openmode which =        ios_base::in | ios_base::out);</PRE><P>The protected virtual member function endeavors to alter the currentpositions for the controlled streams. For an object of class<CODE>strstreambuf</CODE>, a stream position consistspurely of a stream offset. Offset zero designates the first elementof the controlled sequence. The new position is determinedby <CODE>sp</CODE>.</P><P>If<CODE>which &amp; ios_base::in</CODE> is nonzeroand the input buffer exists,the function alters the next position to read in the<A HREF="streambu.html#input buffer">input buffer</A>.(If <CODE>which &amp; ios_base::out</CODE> is nonzeroand the output buffer exists,the function also sets the next position to write tomatch the next position to read.)Otherwise, if <CODE>which &amp; ios_base::out</CODE> is nonzeroand the output buffer exists,the function alters the next position to write in the<A HREF="streambu.html#output buffer">output buffer</A>.Otherwise, the positioning operation fails.For a positioning operation to succeed, the resultingstream position must lie within the controlled sequence.</P><P>If the function succeeds in altering either or both stream positions,it returns the resultant stream position.Otherwise, it fails and returns an invalid stream position.</P><H3><A NAME="strstreambuf::str"><CODE>strstreambuf::str</CODE></A></H3><PRE>char *<B>str</B>();</PRE>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -