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

📄 locale2.html

📁 ST20 Embedded Toolset R2.0.5用于开发基于ST20芯片机顶盒软件的开发平台,2.0.5版本,国内找不到的.在国外论坛上花了N天才找到!
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<P><B><CODE><A HREF="#locale::category">category</A>&#183; <A HREF="#locale::classic">classic</A>&#183; <A HREF="#locale::combine">combine</A>&#183; <A HREF="#locale::facet">facet</A>&#183; <A HREF="#locale::global">global</A>&#183; <A HREF="#locale::id">id</A>&#183; <A HREF="#locale::locale">locale</A>&#183; <A HREF="#locale::name">name</A>&#183; <A HREF="#locale::operator!=">operator!=</A>&#183; <A HREF="#locale::operator()">operator()</A>&#183; <A HREF="#locale::operator==">operator==</A></CODE></B></P><HR><PRE>class <B>locale</B> {public:    class <B><A HREF="#locale::facet">facet</A></B>;    class <B><A HREF="#locale::id">id</A></B>;    typedef int <B><A HREF="#locale::category">category</A></B>;    static const category <B>none</B>, <B>collate</B>, <B>ctype</B>, <B>monetary</B>,        <B>numeric</B>, <B>time</B>, <B>messages</B>, <B>all</B>;    <B><A HREF="#locale::locale">locale</A></B>();    explicit <B><A HREF="#locale::locale">locale</A></B>(const char *locname);    <B><A HREF="#locale::locale">locale</A></B>(const locale&amp; loc, const locale&amp; other,        category cat);    <B><A HREF="#locale::locale">locale</A></B>(const locale&amp; loc, const char *locname, category cat);    template&lt;class Facet&gt;        <B><A HREF="#locale::locale">locale</A></B>(const locale&amp; loc, Facet *fac);    template&lt;class Facet&gt;        locale <B><A HREF="#locale::combine">combine</A></B>(const locale&amp; loc) const;    template&lt;class Elem, class Tr, class Alloc&gt;        bool <B><A HREF="#locale::operator()">operator()</A></B>(const basic_string&lt;Elem, Tr, Alloc&gt;&amp; left,            const basic_string&lt;Elem, Tr, Alloc&gt;&amp; right) const;    string <B><A HREF="#locale::name">name</A></B>() const;    bool <B><A HREF="#locale::operator==">operator==</A></B>(const locale&amp; right) const;    bool <B><A HREF="#locale::operator!=">operator!=</A></B>(const locale&amp; right) const;    static locale <B><A HREF="#locale::global">global</A></B>(const locale&amp; right);    static const locale&amp; <B><A HREF="#locale::classic">classic</A></B>();    };</PRE><P>The class describes a<B><A NAME="locale object">locale object</A></B> that encapsulates a<A HREF="locale.html#locale">locale</A>. It representsculture-specific information as a list of<B><A NAME="locale facet">facets</A></B>. A facet is apointer to an object of a classderived from class <CODE><A HREF="#locale::facet">facet</A></CODE>that has a public object of the form:<PRE>static locale::id id;</PRE><P>You can define an open-ended set of these facets. You can alsoconstruct a locale object that designates an arbitrary number offacets.</P><P>Predefined groups of these facets represent the<A HREF="locale.html#locale category">locale categories</A>traditionally managed in the Standard C library by the function<CODE><A HREF="locale.html#setlocale">setlocale</A></CODE>.</P><P>Category <B><CODE><A HREF="#locale::collate">collate</A></CODE></B>(<CODE><A HREF="locale.html#LC_COLLATE">LC_COLLATE</A></CODE>)includes the facets:</P><PRE>collate&lt;char&gt;collate&lt;wchar_t&gt;</PRE><P>Category <B><CODE><A HREF="#locale::ctype">ctype</A></CODE></B>(<CODE><A HREF="locale.html#LC_CTYPE">LC_CTYPE</A></CODE>)includes the facets:</P><PRE>ctype&lt;char&gt;ctype&lt;wchar_t&gt;codecvt&lt;char, char, mbstate_t&gt;codecvt&lt;wchar_t, char, mbstate_t&gt;</PRE><P>Category <B><CODE><A HREF="#locale::monetary">monetary</A></CODE></B>(<CODE><A HREF="locale.html#LC_MONETARY">LC_MONETARY</A></CODE>)includes the facets:</P><PRE>moneypunct&lt;char, false&gt;moneypunct&lt;wchar_t, false&gt;moneypunct&lt;char, true&gt;moneypunct&lt;wchar_t, true&gt;money_get&lt;char, istreambuf_iterator&lt;char&gt; &gt;money_get&lt;wchar_t, istreambuf_iterator&lt;wchar_t&gt; &gt;money_put&lt;char, ostreambuf_iterator&lt;char&gt; &gt;money_put&lt;wchar_t, ostreambuf_iterator&lt;wchar_t&gt; &gt;</PRE><P>Category <B><CODE><A HREF="#locale::numeric">numeric</A></CODE></B>(<CODE><A HREF="locale.html#LC_NUMERIC">LC_NUMERIC</A></CODE>)includes the facets:</P><PRE>num_get&lt;char, istreambuf_iterator&lt;char&gt; &gt;num_get&lt;wchar_t, istreambuf_iterator&lt;wchar_t&gt; &gt;num_put&lt;char, ostreambuf_iterator&lt;char&gt; &gt;num_put&lt;wchar_t, ostreambuf_iterator&lt;wchar_t&gt; &gt;numpunct&lt;char&gt;numpunct&lt;wchar_t&gt;</PRE><P>Category <B><CODE><A HREF="#locale::time">time</A></CODE></B>(<CODE><A HREF="locale.html#LC_TIME">LC_TIME</A></CODE>)includes the facets:</P><PRE>time_get&lt;char, istreambuf_iterator&lt;char&gt; &gt;time_get&lt;wchar_t, istreambuf_iterator&lt;wchar_t&gt; &gt;time_put&lt;char, ostreambuf_iterator&lt;char&gt; &gt;time_put&lt;wchar_t, ostreambuf_iterator&lt;wchar_t&gt; &gt;</PRE><P>Category <B><CODE><A HREF="#locale::messages">messages</A></CODE></B>(<CODE>LC_MESSAGES</CODE>) includes the facets:</P><PRE>messages&lt;char&gt;messages&lt;wchar_t&gt;</PRE><P>(The last category is required by Posix, but not the C Standard.)</P><P>Some of these predefined facets are used by the<A HREF="lib_cpp.html#iostreams">iostreams</A> classes,to control the conversion of numeric values to and fromtext sequences.</P><P>An object of class <CODE>locale</CODE> also stores a<B><A NAME="locale name">locale name</A></B> as an object of class<CODE><A HREF="string2.html#string">string</A></CODE>. Using aninvalid locale name to construct a<A HREF="#locale facet">locale facet</A> or a locale objectthrows an object of class<CODE><A HREF="stdexcep.html#runtime_error">runtime_error</A></CODE>.The stored locale name is <CODE>"*"</CODE> if the locale objectcannot be certain that a C-style locale corresponds exactlyto that represented by the object. Otherwise, you can establisha matching locale within the Standard C library,for the locale object <CODE>loc</CODE>, by calling<CODE><A HREF="locale.html#setlocale">setlocale</A>(<A HREF="locale.html#LC_ALL">LC_ALL</A>,loc.<A HREF="#locale::name">name</A>.<A HREF="string2.html#basic_string::c_str">c_str</A>())</CODE>.</P><P>In this<A HREF="index.html#implementation">implementation</A>,you can also call the static member function:</P><PRE>static locale <B><A NAME="locale::empty">empty</A></B>();</PRE><P>to construct a locale object that has no facets. It is also a<B><A NAME="transparent locale">transparent locale</A></B> --if the template functions<CODE><A HREF="#has_facet">has_facet</A></CODE> and<CODE><A HREF="#use_facet">use_facet</A></CODE> cannot findthe requested facet in a transparent locale, they consult first the<A HREF="#global locale">global locale</A> and then,if that is transparent, the<A HREF="#classic locale">classic locale</A>. Thus, you can write:</P><PRE>cout.imbue(locale::empty());</PRE><P>Subsequent insertions to<CODE><A HREF="iostream.html#cout">cout</A></CODE> aremediated by the current state of the global locale.You can even write:</P><PRE>locale loc(locale::empty(), locale::classic(),    locale::numeric);cout.imbue(loc);</PRE><P>Numeric formatting rules for subsequent insertions to<CODE>cout</CODE> remain the same as in the<A HREF="locale.html#C locale">C locale</A>,even as the global locale supplies changing rules for insertingdates and monetary amounts.</P><H3><CODE><A NAME="locale::category">locale::category</A></CODE></H3><PRE>typedef int <B>category</B>;static const category <B>none</B>, <B>collate</B>, <B>ctype</B>, <B>monetary</B>,    <B>numeric</B>, <B>time</B>, <B>messages</B>, <B>all</B>;</PRE><P>The type is a synonym for <I>int</I> so that it can representany of the C <A HREF="locale.html#locale category">locale categories</A>.It can represent a group of distinct elements of a<A HREF="lib_cpp.html#bitmask type">bitmask type</A>(which is anonymous) local to class <CODE>locale</CODE>.The elements are:</P><UL><LI><B><CODE><A NAME="locale::collate">collate</A></CODE></B>,corresponding to the C category<CODE><A HREF="locale.html#LC_COLLATE">LC_COLLATE</A></CODE></LI><LI><B><CODE><A NAME="locale::ctype">ctype</A></CODE></B>,corresponding to the C category<CODE><A HREF="locale.html#LC_CTYPE">LC_CTYPE</A></CODE></LI><LI><B><CODE><A NAME="locale::monetary">monetary</A></CODE></B>,corresponding to the C category<CODE><A HREF="locale.html#LC_MONETARY">LC_MONETARY</A></CODE></LI><LI><B><CODE><A NAME="locale::numeric">numeric</A></CODE></B>,corresponding to the C category<CODE><A HREF="locale.html#LC_NUMERIC">LC_NUMERIC</A></CODE></LI><LI><B><CODE><A NAME="locale::time">time</A></CODE></B>,corresponding to the C category<CODE><A HREF="locale.html#LC_TIME">LC_TIME</A></CODE></LI><LI><B><CODE><A NAME="locale::messages">messages</A></CODE></B>,corresponding to the Posix category<CODE>LC_MESSAGES</CODE></LI></UL><P>In addition, two useful values are:</P><UL><LI><B><CODE><A NAME="locale::none">none</A></CODE></B>, corresponding to none ofthe C categories</LI><LI><B><CODE><A NAME="locale::all">all</A></CODE></B>,corresponding to the C union of all categories<CODE><A HREF="locale.html#LC_ALL">LC_ALL</A></CODE></LI></UL><P>You can represent an arbitrary group of categories by ORingthese constants, as in <CODE>monetary | time</CODE>.</P><H3><CODE><A NAME="locale::classic">locale::classic</A></CODE></H3><PRE>static const locale&amp; <B>classic</B>();</PRE><P>The static member function returns a locale object that represents the<B><A NAME="classic locale">classic locale</A></B>,which behaves the same as the<A HREF="locale.html#C locale">C locale</A> within theStandard C library.</P><H3><CODE><A NAME="locale::combine">locale::combine</A></CODE></H3><PRE>template&lt;class Facet&gt;    locale <B>combine</B>(const locale&amp; loc) const;</PRE><P>The member function returns a locale object thatreplaces in (or adds to) <CODE>*this</CODE> the facet <CODE>Facet</CODE>listed in <CODE>loc</CODE>.</P><H3><CODE><A NAME="locale::facet">locale::facet</A></CODE></H3><PRE>class <B>facet</B> {protected:    explicit <B>facet</B>(size_t refs = 0);    virtual <B>~facet</B>();private:    <B>facet</B>(const facet&amp;)          // not defined    <B>void operator=</B>(const facet&amp;) // not defined    };</PRE><P>The member class serves as the base class for all<A HREF="#locale facet">locale facets</A>. Note that youcan neither copy nor assign an object of class <CODE>facet</CODE>.You can construct and destroy objects derived from class<CODE>locale::facet</CODE>, but not objects of the base class proper.Typically, you construct an object <CODE>myfac</CODE> derivedfrom <CODE>facet</CODE> when you construct a locale, as in:</P><PRE>locale loc(locale::classic(), new myfac);</PRE><P>In such cases, the constructor for the base class <CODE>facet</CODE>should have a zero <CODE>refs</CODE> argument. When the objectis no longer needed, it is deleted. Thus, you supply a nonzero<CODE>refs</CODE> argument only in those rare cases where youtake responsibility for the lifetime of the object.</P><H3><CODE><A NAME="locale::global">locale::global</A></CODE></H3><PRE>static locale <B>global</B>(const locale&amp; loc);</PRE><P>The static member function stores a copy of <CODE>loc</CODE> as the<B><A NAME="global locale">global locale</A></B>. It also calls<CODE><A HREF="locale.html#setlocale">setlocale</A>(<A HREF="locale.html#LC_ALL">LC_ALL</A>,loc.<A HREF="#locale::name">name</A>.<A HREF="string2.html#basic_string::c_str">c_str</A>())</CODE>,to establishing a matching locale within the Standard C library.The function then returns the previous global locale. At<A HREF="lib_over.html#program startup">program startup</A>,the global locale is the same as the<A HREF="#classic locale">classic locale</A>.</P><H3><CODE><A NAME="locale::id">locale::id</A></CODE></H3><PRE>class <B>id</B> {protected:    <B>id</B>();private:    <B>id</B>(const id&amp;)             // not defined    <B>void operator=</B>(const id&amp;) // not defined    };</PRE><P>The member class describes the staticmember object required by each unique<A HREF="#locale facet">locale facet</A>. Note that youcan neither copy nor assign an object of class <CODE>id</CODE>.</P><H3><CODE><A NAME="locale::locale">locale::locale</A></CODE></H3><PRE><B>locale</B>();explicit <B>locale</B>(const char *locname);<B>locale</B>(const locale&amp; loc, const locale&amp; other,    category cat);<B>locale</B>(const locale&amp; loc, const char *locname, category cat);template&lt;class Facet&gt;    <B>locale</B>(const locale&amp; loc, Facet *fac);</PRE><P>The first constructor initializes the object to match the<A HREF="#global locale">global locale</A>. The second constructorinitializes all the<A HREF="locale.html#locale category">locale categories</A> to have behaviorconsistent with the <A HREF="#locale name">locale name</A><CODE>locname</CODE>. The remaining constructors copy <CODE>loc</CODE

⌨️ 快捷键说明

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