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

📄 istream.html

📁 ST20 Embedded Toolset R2.0.5用于开发基于ST20芯片机顶盒软件的开发平台,2.0.5版本,国内找不到的.在国外论坛上花了N天才找到!
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<P>The function:</P><PRE>istream&amp; <B>operator&gt;&gt;</B>(bool&amp; val);</PRE><P>extracts a field and converts it to a boolean value.The function endeavors to match a complete, nonempty<B><A NAME="boolean input field">boolean input field</A></B>.If successful it convertsthe boolean input field to a value of type <CODE>bool</CODE>and stores that value in <CODE>val</CODE>.</P><P>A boolean input field takes one of two forms.If <CODE><A HREF="ios.html#ios_base::flags">flags</A>() &amp;ios_base::<A HREF="ios.html#ios_base::boolalpha">boolalpha</A></CODE>is false, it is the same as an<A HREF="#integer input field">integer input field</A>, except that theconverted value must be either 0 (for false) or 1 (for true).Otherwise, the sequence must match either<CODE>false</CODE> (for false), or<CODE>true</CODE> (for true).The function returns <CODE>*this</CODE>.</P><P>The functions:</P><PRE>istream&amp; <B>operator&gt;&gt;</B>(short&amp; val);istream&amp; <B>operator&gt;&gt;</B>(unsigned short&amp; val);istream&amp; <B>operator&gt;&gt;</B>(int&amp; val);istream&amp; <B>operator&gt;&gt;</B>(unsigned int&amp; val);istream&amp; <B>operator&gt;&gt;</B>(long&amp; val);istream&amp; <B>operator&gt;&gt;</B>(unsigned long&amp; val);istream&amp; <B>operator&gt;&gt;</B>(void *&amp; val);</PRE><P>each extract a field and convert it to a numeric value.Each function endeavors to match a complete, nonempty<B><A NAME="integer input field">integer input field</A></B>.If successful, it stores the result in <CODE>val</CODE>.Otherwise, the function stores nothing in <CODE>val</CODE> and calls<CODE><A HREF="ios.html#ios::setstate">setstate</A>(ios_base::failbit)</CODE>.If the function encounters end of file, it calls<CODE>setstate(ios_base::eofbit)</CODE>.</P><P>The integer input field is converted by the same rules used by the<A HREF="lib_scan.html#Scan Functions">scan functions</A>for matching and converting a series of <I>char</I> elements from a file.The equivalent<A HREF="lib_scan.html#scan conversion specification">scan conversionspecification</A> is determined as follows:</P><UL><LI>If <CODE><A HREF="ios.html#ios_base::flags">flags</A>() &amp;ios_base::<A HREF="ios.html#ios_base::basefield">basefield</A> ==ios_base::<A HREF="ios.html#ios_base::oct">oct</A></CODE>, theconversion specification is <CODE>lo</CODE>.</LI><LI>If <CODE>flags() &amp; ios_base::basefield ==ios_base::<A HREF="ios.html#ios_base::hex">hex</A></CODE>, theconversion specification is <CODE>lx</CODE>.</LI><LI>If <CODE>flags() &amp; ios_base::basefield == 0</CODE>, theconversion specification is <CODE>li</CODE>.</LI><LI>Otherwise, the conversion specification is <CODE>ld</CODE>if <CODE>val</CODE> has a signed type, <CODE>lu</CODE> if <CODE>val</CODE>has an unsigned type, or <CODE>p</CODE> if <CODE>val</CODE> has type<CODE>void *</CODE>.</LI></UL><P>If the converted value cannotbe represented as the type of <CODE>val</CODE>, the function calls<CODE><A HREF="ios.html#ios::setstate">setstate</A>(failbit)</CODE>.In any case, the function returns <CODE>*this</CODE>.</P><P>The functions:</P><PRE>istream&amp; <B>operator&gt;&gt;</B>(float&amp; val);istream&amp; <B>operator&gt;&gt;</B>(double&amp; val);istream&amp; <B>operator&gt;&gt;</B>(long double&amp; val);</PRE><P>each extract a field and convert it to a numeric value.Each function endeavors to match a complete, nonemptyA period (<CODE>.</CODE>) separates the integer digits from thefraction digits.The equivalent scan conversion specifier is <CODE>f</CODE>if <CODE>val</CODE> has type <I>float,</I> <CODE>lf</CODE> if <CODE>val</CODE>has type <I>double,</I> or <CODE>Lf</CODE> if <CODE>val</CODE> has type<I>long double.</I></P><P>If the converted value cannotbe represented as the type of <CODE>val</CODE>, the function calls<CODE><A HREF="ios.html#ios::setstate">setstate</A>(failbit)</CODE>.In any case, it returns <CODE>*this</CODE>.</P><H3><A NAME="istream::peek"><CODE>istream::peek</CODE></A></H3><PRE>int_type <B>peek</B>();</PRE><P>The <A HREF="#unformatted input functions">unformatted input function</A>extracts an element, if possible, as if by returning<CODE>rdbuf()-&gt;<A HREF="streambu.html#streambuf::sgetc">sgetc</A>()</CODE>.Otherwise, it returns<CODE>traits_type::<A HREF="string2.html#char_traits::eof">eof</A>()</CODE>.</P><H3><A NAME="istream::putback"><CODE>istream::putback</CODE></A></H3><PRE>istream&amp; <B>putback</B>(char_type ch);</PRE><P>The <A HREF="#unformatted input functions">unformatted input function</A>puts back <CODE>ch</CODE>, if possible, as if by calling<CODE>rdbuf()-&gt;<A HREF="streambu.html#streambuf::sputbackc">sputbackc</A>()</CODE>.If <CODE><A HREF="ios.html#ios::rdbuf">rdbuf</A>()</CODE>is a null pointer, or if the call to <CODE>sputbackc</CODE> returns<CODE>traits_type::<A HREF="string2.html#char_traits::eof">eof</A>()</CODE>,the function calls<CODE><A HREF="ios.html#ios::setstate">setstate</A>(badbit)</CODE>.In any case, it returns <CODE>*this</CODE>.</P><H3><A NAME="istream::read"><CODE>istream::read</CODE></A></H3><PRE>istream&amp; <B>read</B>(char_type *str, streamsize count);</PRE><P>The <A HREF="#unformatted input functions">unformatted input function</A>extracts up to <CODE>count</CODE> elementsand stores them in the array beginning at <CODE>str</CODE>.Extraction stops early on end-of-file, in which case the function calls<CODE><A HREF="ios.html#ios::setstate">setstate</A>(failbit)</CODE>.In any case, it returns <CODE>*this</CODE>.</P><H3><A NAME="istream::readsome"><CODE>istream::readsome</CODE></A></H3><PRE>streamsize <B>readsome</B>(char_type *str, streamsize count);</PRE><P>The <A HREF="#unformatted input functions">unformatted input function</A>extracts up to <CODE>count</CODE> elementsand stores them in the array beginning at <CODE>str</CODE>.If <CODE><A HREF="ios.html#ios::good">good</A>()</CODE> isfalse, the function calls<CODE><A HREF="ios.html#ios::setstate">setstate</A>(failbit)</CODE>.Otherwise, it assigns the value of<CODE>rdbuf()-&gt;<A HREF="streambu.html#streambuf::in_avail">in_avail</A>()</CODE>to <CODE>N</CODE>. If <CODE>N &lt; 0</CODE>, the function calls<CODE><A HREF="ios.html#ios::setstate">setstate</A>(eofbit)</CODE>.Otherwise, it replaces the value stored in <CODE>N</CODE> withthe smaller of <CODE>count</CODE> and <CODE>N</CODE>, then calls<CODE><A HREF="#istream::read">read</A>(str, N)</CODE>.In any case, the function returns<CODE><A HREF="#istream::gcount">gcount</A>()</CODE>.</P><H3><A NAME="istream::seekg"><CODE>istream::seekg</CODE></A></H3><PRE>istream&amp; <B>seekg</B>(pos_type pos);istream&amp; <B>seekg</B>(off_type off,    ios_base::seek_dir way);</PRE><P>If <CODE><A HREF="ios.html#ios::fail">fail</A>()</CODE> is false,the first member function calls<CODE>newpos = <A HREF="ios.html#ios::rdbuf">rdbuf</A>()-&gt;<A HREF="streambu.html#streambuf::pubseekpos">pubseekpos</A>(pos,<A HREF="ios.html#ios_base::in">in</A>)</CODE>,for some <CODE>pos_type</CODE> temporary object <CODE>newpos</CODE>.If <CODE>fail()</CODE> is false, the second function calls<CODE>newpos = rdbuf()-&gt;<A HREF="streambu.html#streambuf::pubseekoff">pubseekoff</A>(off, way,<A HREF="ios.html#ios_base::in">in</A>)</CODE>.In either case, if <CODE>(off_type)newpos == (off_type)(-1)</CODE>(the positioning operation fails) the function calls<CODE>istr.<A HREF="ios.html#ios::setstate">setstate</A>(failbit)</CODE>.Both functions return <CODE>*this</CODE>.</P><H3><A NAME="istream::sentry"><CODE>istream::sentry</CODE></A></H3><PRE>class <B>sentry</B> {public:    explicit <B>sentry</B>(istream&lt;Elem, Tr&gt;&amp; istr,        bool noskip = false);    <B>operator bool</B>() const;    };</PRE><P>The nested class describes an object whose declaration structures the<A HREF="#formatted input functions">formatted input functions</A> and the<A HREF="#unformatted input functions">unformatted input functions</A>.If <CODE>istr.<A HREF="ios.html#ios::good">good</A>()</CODE>is true, the constructor:</P><UL><LI>calls <CODE>istr.<A HREF="ios.html#ios::tie">tie</A>-&gt;<A HREF="ostream.html#ostream::flush">flush</A>()</CODE>if <CODE>istr.tie()</CODE> is not a null pointer</LI><LI>effectively calls <CODE><A HREF="#ws">ws</A>(istr)</CODE> if<CODE>istr.<A HREF="ios.html#ios_base::flags">flags</A>() &amp;<A HREF="ios.html#ios_base::skipws">skipws</A></CODE> is nonzero</LI></UL><P>If, after any such preparation,<CODE>istr.good()</CODE> is false, the constructor calls<CODE>istr.<A HREF="ios.html#ios::setstate">setstate</A>(failbit)</CODE>.In any case, the constructor stores the value returned by <CODE>istr.good()</CODE>in <B>status</B>.A later call to <CODE>operator bool()</CODE> delivers this stored value.</P><H3><A NAME="istream::sync"><CODE>istream::sync</CODE></A></H3><PRE>int <B>sync</B>();</PRE><P>If <CODE><A HREF="ios.html#ios::rdbuf">rdbuf</A>()</CODE> isa null pointer, the function returns -1. Otherwise, it calls<CODE>rdbuf()-&gt;<A HREF="streambu.html#streambuf::pubsync">pubsync</A>()</CODE>.If that returns -1, the function calls<CODE><A HREF="ios.html#ios::setstate">setstate</A>(badbit)</CODE>and returns -1. Otherwise, the function returns zero.</P><H3><A NAME="istream::tellg"><CODE>istream::tellg</CODE></A></H3><PRE>pos_type <B>tellg</B>();</PRE><P>If <CODE><A HREF="ios.html#ios::fail">fail</A>()</CODE> is false,the member function returns<CODE><A HREF="ios.html#ios::rdbuf">rdbuf</A>()-&gt;<A HREF="streambu.html#streambuf::pubseekoff">pubseekoff</A>(0,<A HREF="ios.html#ios_base::cur">cur</A>,<A HREF="ios.html#ios_base::in">in</A>)</CODE>.Otherwise, it returns <CODE>pos_type(-1)</CODE>.</P><H3><A NAME="istream::unget"><CODE>istream::unget</CODE></A></H3><PRE>istream&amp; <B>unget</B>();</PRE><P>The <A HREF="#unformatted input functions">unformatted input function</A>puts back the previous element in the stream, if possible, as if by calling<CODE>rdbuf()-&gt;<A HREF="streambu.html#streambuf::sungetc">sungetc</A>()</CODE>.If <CODE><A HREF="ios.html#ios::rdbuf">rdbuf</A>()</CODE>is a null pointer, or if the call to <CODE>sungetc</CODE> returns<CODE>traits_type::<A HREF="string2.html#char_traits::eof">eof</A>()</CODE>,the function calls<CODE><A HREF="ios.html#ios::setstate">setstate</A>(badbit)</CODE>.In any case, it returns <CODE>*this</CODE>.</P><H2><A NAME="operator&gt;&gt;"><CODE>operator&gt;&gt;</CODE></A></H2><PRE>istream&amp;    <B>operator&gt;&gt;</B>(istream&amp; istr, char *str);istream&amp;    <B>operator&gt;&gt;</B>(istream&amp; istr, char&amp; ch);istream&amp;    <B>operator&gt;&gt;</B>(istream&amp; istr, signed char *str);istream&amp;    <B>operator&gt;&gt;</B>(istream&amp; istr, signed char&amp; ch);istream&amp;    <B>operator&gt;&gt;</B>(istream&amp; istr, unsigned char *str);istream&amp;    <B>operator&gt;&gt;</B>(istream istr, unsigned char&amp; ch);</PRE><P>All of these functions are<A HREF="#formatted input functions">formatted input functions</A>.The function:</P><PRE>istream&amp;    <B>operator&gt;&gt;</B>(istream&amp; istr, char *str);</PRE><P>extracts up to <CODE>N - 1</CODE> elementsand stores them in the array beginning at <CODE>str</CODE>.If <CODE>istr.<A HREF="ios.html#ios_base::width">width</A>()</CODE> is greaterthan zero, <CODE>N</CODE> is <CODE>istr.width()</CODE>; otherwise it isthe size ofthe largest array of <I>char</I> that can be declared.The function always stores<CODE>char(0)</CODE> afterany extracted elements it stores. Extraction stops early on end-of-file,on a character with value <CODE>char(0)</CODE> (which is not extracted),or on any element (which is not extracted) that would be discarded by<CODE><A HREF="#ws">ws</A></CODE>.If the function extracts no elements, it calls<CODE>istr.<A HREF="ios.html#ios::setstate">setstate</A>(failbit)</CODE>.In any case, it calls <CODE>istr.width(0)</CODE> andreturns <CODE>istr</CODE>.</P><P>The function:</P><PRE>istream&amp;    <B>operator&gt;&gt;</B>(istream&amp; istr, char&amp; ch);</PRE><P>extracts an element, if possible, and stores it in <CODE>ch</CODE>.Otherwise, it calls<CODE>is.<A HREF="ios.html#ios::setstate">setstate</A>(failbit)</CODE>.In any case, it returns <CODE>istr</CODE>.</P><P>The function:</P><PRE>istream&amp;    <B>operator&gt;&gt;</B>(istream&amp; istr, signed char *str);</PRE><P>returns <CODE>istr &gt;&gt; (char *)str</CODE>.</P><P>The function:</P><PRE>istream&amp;    <B>operator&gt;&gt;</B>(istream&amp; istr, signed char&amp; ch);</PRE><P>returns <CODE>istr &gt;&gt; (char&amp;)ch</CODE>.</P><P>The function:</P><PRE>istream&amp;    <B>operator&gt;&gt;</B>(istream&amp; istr, unsigned char *str);</PRE><P>returns <CODE>istr &gt;&gt; (char *)str</CODE>.</P><P>The function:</P><PRE>istream&amp;    <B>operator&gt;&gt;</B>(istream&amp; istr, unsigned char&amp; ch);</PRE><P>returns <CODE>istr &gt;&gt; (char&amp;)ch</CODE>.</P><H2><A NAME="ws"><CODE>ws</CODE></A></H2><PRE>istream&amp; <B>ws</B>(istream&amp; istr);</PRE><P>The manipulator extracts and discards any elements<CODE>ch</CODE> for which<CODE><A HREF="ctype.html#isspace">isspace</A>(ch)</CODE>is true.</P><P>The function calls<CODE><A HREF="ios.html#ios::setstate">setstate</A>(eofbit)</CODE>if it encounters end-of-file while extracting elements.It returns <CODE>istr</CODE>.</P><HR><P>See also the<B><A HREF="index.html#Table of Contents">Table of Contents</A></B> and the<B><A HREF="_index.html">Index</A></B>.</P><P><I><A HREF="crit_pjp.html">Copyright</A> &#169; 1992-2002by P.J. Plauger. All rights reserved.</I></P><!--V4.01:1125--></BODY></HTML>

⌨️ 快捷键说明

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