📄 locale2.html
字号:
and <CODE>last1</CODE>. (Thus, it is roughly analogous to the macro<CODE><A HREF="stdlib.html#MB_CUR_MAX">MB_CUR_MAX</A></CODE>, at leastwhen <CODE>Byte</CODE> is type <CODE>char</CODE>.)</P><P>The template version always returns 1.</P><H3><CODE><A NAME="codecvt::do_out">codecvt::do_out</A></CODE></H3><PRE>virtual result <B>do_out</B>(Statype state&, const Elem *first1, const Elem *last1, const Elem *next1, Byte *first2, Byte *last2, Byte *next2);</PRE><P>The protected virtual member function endeavors to convert thesource sequence at <CODE>[first1, last1)</CODE>to a destination sequence that itstores within <CODE>[first2, last2)</CODE>. It always stores in<CODE>next1</CODE> a pointer to the first unconverted element inthe source sequence, and it always stores in <CODE>next2</CODE> apointer to the first unaltered element in the destination sequence.</P><P><CODE>state</CODE> must represent the<A HREF="charset.html#initial conversion state">initial conversion state</A>at the beginning of a new source sequence. The function alters its storedvalue, as needed, to reflect the current state of asuccessful conversion. Its stored value is otherwise unspecified.</P><P>The function returns:</P><UL><LI><CODE>codecvt_base::<A HREF="#codecvt_base::error">error</A></CODE>if the source sequence is ill formed</LI><LI><CODE>codecvt_base::<A HREF="#codecvt_base::noconv">noconv</A></CODE>if the function performs no conversion</LI><LI><CODE>codecvt_base::<A HREF="#codecvt_base::ok">ok</A></CODE>if the conversion succeeds</LI><LI><CODE>codecvt_base::<A HREF="#codecvt_base::partial">partial</A></CODE>if the source is insufficient, or if the destination is not large enough,for the conversion to succeed</LI></UL><P>The template version always returns <CODE>noconv</CODE>.</P><H3><CODE><A NAME="codecvt::do_unshift">codecvt::do_unshift</A></CODE></H3><PRE>virtual result <B>do_unshift</B>(Statype state&, Byte *first2, Byte *last2, Byte *next2);</PRE><P>The protected virtual member function endeavors to convert thesource element <CODE>Elem(0)</CODE>to a destination sequence that itstores within <CODE>[first2, last2)</CODE>, except for the terminatingelement <CODE>Byte(0)</CODE>. It always stores in <CODE>next2</CODE> apointer to the first unaltered element in the destination sequence.</P><P><CODE>state</CODE> must represent the<A HREF="charset.html#initial conversion state">initial conversion state</A>at the beginning of a new source sequence. The function alters its storedvalue, as needed, to reflect the current state of asuccessful conversion. Typically, converting the source element<CODE>Elem(0)</CODE> leaves the current state in the initial conversion state.</P><P>The function returns:</P><UL><LI><CODE>codecvt_base::<A HREF="#codecvt_base::error">error</A></CODE>if <CODE>state</CODE> represents an invalid state</LI><LI><CODE>codecvt_base::<A HREF="#codecvt_base::noconv">noconv</A></CODE>if the function performs no conversion</LI><LI><CODE>codecvt_base::<A HREF="#codecvt_base::ok">ok</A></CODE>if the conversion succeeds</LI><LI><CODE>codecvt_base::<A HREF="#codecvt_base::partial">partial</A></CODE>if the destination is not large enough for the conversion to succeed</LI></UL><P>The template version always returns <CODE>noconv</CODE>.</P><H3><CODE><A NAME="codecvt::extern_type">codecvt::extern_type</A></CODE></H3><PRE>typedef Byte <B>extern_type</B>;</PRE><P>The type is a synonym for the template parameter <CODE>Byte</CODE>.</P><H3><CODE><A NAME="codecvt::in">codecvt::in</A></CODE></H3><PRE>result <B>in</B>(Statype state&, const Byte *first1, const Byte *last1, const Byte *next1, Elem *first2, Elem *last2, Elem *next2);</PRE><P>The member function returns<CODE><A HREF="#codecvt::do_in">do_in</A>(state, first1, last1,next1, first2, last2, next2)</CODE>.</P><H3><CODE><A NAME="codecvt::intern_type">codecvt::intern_type</A></CODE></H3><PRE>typedef Elem <B>intern_type</B>;</PRE><P>The type is a synonym for the template parameter <CODE>Elem</CODE>.</P><H3><CODE><A NAME="codecvt::length">codecvt::length</A></CODE></H3><PRE>int <B>length</B>(const Statype state&, const Byte *first1, const Byte *last1, size_t len2) const throw();</PRE><P>The member function returns<CODE><A HREF="#codecvt::do_length">do_length</A>(first1,last1, len2)</CODE>.</P><H3><CODE><A NAME="codecvt::encoding">codecvt::encoding</A></CODE></H3><PRE>int <B>encoding</B>() const throw();</PRE><P>The member function returns<CODE><A HREF="#codecvt::do_encoding">do_encoding</A>()</CODE>.</P><H3><CODE><A NAME="codecvt::max_length">codecvt::max_length</A></CODE></H3><PRE>int <B>max_length</B>() const throw();</PRE><P>The member function returns<CODE><A HREF="#codecvt::do_max_length">do_max_length</A>()</CODE>.</P><H3><CODE><A NAME="codecvt::out">codecvt::out</A></CODE></H3><PRE>result <B>out</B>(Statype state&, const Elem *first1, const Elem *last1, const Elem *next1, Byte *first2, Byte *last2, Byte *next2);</PRE><P>The member function returns<CODE><A HREF="#codecvt::do_out">do_out</A>(state, first1, last1,next1, first2, last2, next2)</CODE>.</P><H3><CODE><A NAME="codecvt::state_type">codecvt::state_type</A></CODE></H3><PRE>typedef Statype <B>state_type</B>;</PRE><P>The type is a synonym for the template parameter <CODE>Statype</CODE>.</P><H3><CODE><A NAME="codecvt::unshift">codecvt::unshift</A></CODE></H3><PRE>result <B>unshift</B>(Statype state&, Byte *first2, Byte *last2, Byte *next2);</PRE><P>The member function returns<CODE><A HREF="#codecvt::do_unshift">do_unshift</A>(state,first2, last2, next2)</CODE>.</P><H2><CODE><A NAME="codecvt_base">codecvt_base</A></CODE></H2><PRE>class <B>codecvt_base</B> {public: enum <B>result</B> {<B>ok</B>, <B>partial</B>, <B>error</B>, <B>noconv</B>}; };</PRE><P>The class describes an enumeration common to all specializations oftemplate class <CODE><A HREF="#codecvt">codecvt</A></CODE>. The enumeration<B><CODE><A NAME="codecvt_base::result">result</A></CODE></B>describes the possible return values from<CODE><A HREF="#codecvt::do_in">do_in</A></CODE> or<CODE><A HREF="#codecvt::do_out">do_out</A></CODE>:</P><UL><LI><B><CODE><A NAME="codecvt_base::error">error</A></CODE></B>if the source sequence is ill formed</LI><LI><B><CODE><A NAME="codecvt_base::noconv">noconv</A></CODE></B>if the function performs no conversion</LI><LI><B><CODE><A NAME="codecvt_base::ok">ok</A></CODE></B>if the conversion succeeds</LI><LI><B><CODE><A NAME="codecvt_base::partial">partial</A></CODE></B>if the destination is not large enough for the conversion to succeed</LI></UL><H2><CODE><A NAME="codecvt_byname">codecvt_byname</A></CODE></H2><PRE>template<class Elem, class Byte, class Statype> class <B>codecvt_byname</B> : public codecvt<Elem, Byte, Statype> {public: explicit <B>codecvt_byname</B>(const char *locname, size_t refs = 0);protected: <B>~codecvt_byname</B>(); };</PRE><P>The template class describes an object that can serve as a<A HREF="#locale facet">locale facet</A> of type<CODE><A HREF="#codecvt">codecvt</A><Elem, Byte, Statype></CODE>.Its behavior is determined by the<A HREF="#locale name">named</A> locale <CODE>locname</CODE>.The constructor initializes its base object with<CODE><A HREF="#codecvt::codecvt">codecvt</A><Elem,Byte, Statype>(refs)</CODE>.</P><H2><CODE><A NAME="collate">collate</A></CODE></H2><PRE>template<class Elem> class <B>collate</B> : public locale::facet {public: typedef Elem <B><A HREF="#collate::char_type">char_type</A></B>; typedef basic_string<Elem> <B><A HREF="#collate::string_type">string_type</A></B>; explicit <B><A HREF="#collate::collate">collate</A></B>(size_t refs = 0); int <B><A HREF="#collate::compare">compare</A></B>(const Elem *first1, const Elem *last1, const Elem *first2, const Elem *last2) const; string_type <B><A HREF="#collate::transform">transform</A></B>(const Elem *first, const Elem *last) const; long <B><A HREF="#collate::hash">hash</A></B>(const Elem *first, const Elem *last) const; static locale::id <B><A HREF="#collate::id">id</A></B>;protected: <B>~collate</B>(); virtual int <B><A HREF="#collate::do_compare">do_compare</A></B>(const Elem *first1, const Elem *last1, const Elem *first2, const Elem *last2) const; virtual string_type <B><A HREF="#collate::do_transform">do_transform</A></B>(const Elem *first, const Elem *last) const; virtual long <B><A HREF="#collate::do_hash">do_hash</A></B>(const Elem *first, const Elem *last) const; };</PRE><P>The template class describes an object that can serve as a<A HREF="#locale facet">locale facet</A>, to control comparisonsof sequences of type <CODE>Elem</CODE>.</P><P>As with any locale facet, the static object<B><CODE><A NAME="collate::id">id</A></CODE></B> has an initialstored value of zero. The first attempt to access its stored valuestores a unique positive value in <CODE>id</CODE>.</P><H3><CODE><A NAME="collate::char_type">collate::char_type</A></CODE></H3><PRE>typedef Elem <B>char_type</B>;</PRE><P>The type is a synonym for the template parameter <CODE>Elem</CODE>.</P><H3><CODE><A NAME="collate::collate">collate::collate</A></CODE></H3><PRE>explicit <B>collate</B>(size_t refs = 0);</PRE><P>The constructor initializes its base object with<CODE>locale::<A HREF="#locale::facet">facet</A>(refs)</CODE>.</P><H3><CODE><A NAME="collate::compare">collate::compare</A></CODE></H3><PRE>int <B>compare</B>(const Elem *first1, const Elem *last1, const Elem *first2, const Elem *last2) const;</PRE><P>The member function returns<CODE><A HREF="#collate::do_compare">do_compare</A>(first1, last1,first2, last2)</CODE>.</P><H3><CODE><A NAME="collate::do_compare">collate::do_compare</A></CODE></H3><PRE>virtual int <B>do_compare</B>(const Elem *first1, const Elem *last1, const Elem *first2, const Elem *last2) const;</PRE><P>The protected virtual member function compares the sequence at<CODE>[first1, last1)</CODE> with the sequence at<CODE>[first2, last2)</CODE>. It compares valuesby applying <CODE>operator<</CODE>between pairs of corresponding elements of type <CODE>Elem</CODE>.The first sequence compares less if it has the smaller element inthe earliest unequal pair in the sequences, or if no unequalpairs exist but the first sequence is shorter.</P><P>If the first sequence compares less than the second sequence,the function returns -1. If the second sequence compares less, the functionreturns +1. Otherwise, the function returns zero.</P><H3><CODE><A NAME="collate::do_hash">collate::do_hash</A></CODE></H3><PRE>virtual long <B>do_hash</B>(const Elem *first, const Elem *last) const;</PRE><P>The protected virtual member function returns an integer derivedfrom the values of the elements in the sequence<CODE>[first, last)</CODE>. Such a <B>hash</B> value can be useful,for example, in distributing sequences pseudo randomlyacross an array of lists.</P><H3><CODE><A NAME="collate::do_transform">collate::do_transform</A></CODE></H3><PRE>virtual string_type <B>do_transform</B>(const Elem *first, const Elem *last) const;</PRE><P>The protected virtual member function returns an object of class<CODE><A HREF="#collate::string_type">string_type</A></CODE> whose controlledsequence is a copy of the sequence <CODE>[first, last)</CODE>.If a class derived from <CODE>collate<Elem></CODE> overrides<CODE><A HREF="#collate::do_compare">do_compare</A></CODE>, it shouldalso override <CODE>do_transform</CODE> to match. Put simply, twotransformed strings should yield the same result, when passed to<CODE>collate::compare</CODE>, that you would get from passing theuntransformed strings to <CODE>compare</CODE> in the derived class.</P><H3><CODE><A NAME="collate::hash">collate::hash</A></CODE></H3><PRE>long <B>hash</B>(const Elem *first, const Elem *last) const;</PRE><P>The member function returns<CODE><A HREF="#collate::do_hash">do_hash</A>(first, last)</CODE>.</P><H3><CODE><A NAME="collate::string_type">collate::string_type</A></CODE></H3><PRE>typedef basic_string<Elem> <B>string_type</B>;</PRE><P>The type describes a specialization of template class<CODE><A HREF="string2.html#basic_string">basic_string</A></CODE>whose objects can store copies of the source sequence.</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -