📄 locale.htm
字号:
<html>
<head>
<title>locale</title>
<head>
<body bgcolor="#FFFFFF">
<a name="here"></a>
<img src="loclban.gif">
<pre>
<font size=5>Class Name</font> locale
<font size=5>Header File</font> <locale>
<font size=5>Classification</font> abstract data type
</pre>
<a href="locale.htm#crd">Class Relationship Diagram</a><br>
<br>
<a href="locale.htm#class-descrip">Class Description</a>
<h1>Member Classes</h1>
<a href="locale.htm#id">locale::id</a><br>
<a href="locale.htm#facet">facet</a>
<h1>Methods</h1>
<pre>
<a href="locale.htm#locale-classic">
static const locale& classic();</a>
<a href="locale.htm#locale-global">
static locale global(const locale&);</a>
<a href="locale.htm#locale1">
locale() throw();</a>
<a href="locale.htm#locale2">
locale(const locale& other) throw();</a>
<a href="locale.htm#locale3">
explicit locale(const char* std_name);</a>
<a href="locale.htm#locale4">
locale(const locale& other, const char* std_name, category cats);</a>
<a href="locale.htm#locale5">
template <class Facet> locale(const locale& other, Facet* f);</a>
<a href="locale.htm#locale6">
template <class Facet> locale(const locale& other, const locale& one);</a>
<a href="locale.htm#locale7">
locale(const locale& other, const locale& one, category cats);</a>
<a href="locale.htm#~locale">
~locale() throw();</a>
<a href="locale.htm#locale-name">
basic_string<char> name() const;</a>
</pre>
<h1>Operators</h1>
<pre>
<a href="locale.htm#operator!=">
bool operator!=(const locale& other) const;</a>
<a href="locale.htm#operator=">
const locale& operator=(const locale& other) throw();</a>
<a href="locale.htm#operator==">
bool operator==(const locale& other) const;</a>
<a href="locale.htm#operator()">
template <class charT, class Traits, class Allocator>
bool operator()(const basic_string<charT,Traits,Allocator>& s1,
const basic_string<charT,Traits,Allocator>& s2) const;</a>
</pre>
<hr>
<a name="class-descrip"><h3>Class Description</h3></a>
<p>
The locale class is used to provide a localization interface and a set of indexed facets
in which each facet covers a particular localization issue. In order to access the facets
of locale, the use_facet<Facet>(loc) and has_facet< > is called. These are not locale
methods but global template functions. Successive calls to a locale facet method during
extraction, insertion, or streambuf method, returns identical results. Named locales can be
compared for equality. Unnamed locales are equal only to copies of itself.
</p>
<hr>
<a name="id"><h3>locale::id</h3></a>
<p>
<em>locale::id</em> is a class used to provide an identification of a locale facet interfaces used as
an index for lookup and to encapsulate initialization.
</p>
<hr>
<a name="facet"><h3>facet</h3></a>
<p>
<em>facet</em> is the base class for any derived facet classes. All classes must derive from this
class directly or indirectly.
</p>
<hr>
<a name="category"><h3>category</h3></a>
<p>
<em>category</em> is an int value that includes bitmask elements:
none, collate, ctype, monetary, numeric, time and messages.
it can also have the value all defined as the expression:
(collate | ctype | monetary | numeric | time | messages | all) == all
is true. The | and & operators can be applied to any two valid values.
</p>
<hr>
<pre>
<a name="locale-classic">
Method classic()</a>
Access Public
Classification Accessor
Syntax static locale global(const locale& loc) const;
Parameters <em>loc</em> is the locale used to set the global locale.
Return This method returns a locale that is the previous
value of locale().
</pre>
<h3>Description</h3>
<p>
The global() method sets the global locale to the argument <em>loc</em>. This will
cause any future calls to the constructor locale() to return a copy of the
argument. The locale returned is the previous value of locale().
</p>
<hr>
<pre>
<a name="locale1">
Method locale()</a>
Access Public
Classification Constructor
Syntax locale() throw();
Parameters None
Returns None
</pre>
<h3>Description</h3>
<p>
The constructor constructs a locale object. This is the default constructor.
It constructs a copy of the last argument passed to the locale::global(locale&).
If it has not been called, it will construct a locale object identical to
locale::classic().
</p>
<hr>
<pre>
<a name="locale2">
Method locale()</a>
Access Public
Classification Constructor
Syntax locale(const locale& other) throw();
Parameters other is the locale in which the newly constructed
locale is a copy.
Returns None
</pre>
<h3>Description</h3>
<p>
The constructor constructs a locale object that is a copy of the argument <em>other</em>.
</p>
<hr>
<pre>
<a name="locale3">
Method locale()</a>
Access Public
Classification Constructor
Syntax explicit locale(const char* std_name);
Parameters <em>std_name</em> is the name that will be associated with
the newly constructed locale object.
Returns None
</pre>
<h3>Description</h3>
<p>
The constructor constructs a named locale object with the argument <em>std_name</em>.
</p>
<hr>
<pre>
<a name="locale4">
Method locale()</a>
Access Public
Classification Constructor
Syntax locale(const locale& other, const char* std_name,
category cats);
Parameters <em>other</em> is the locale in which the newly constructed
locale is a copy.
<em>std_name</em> is the locale object that supplies the
facets identified by the argument cats.
<em>cats</em> is the <a href="locale.htm#category">category</a> object that supplies
the name of a facet or facets. The newly constructed
locale object will not have a copy of the facet or
facets identified by this argument.
Return None
</pre>
<h3>Description</h3>
<p>
The constructor constructs a locale object that is a copy of the
argument locale <em>other</em>. All facets are copied except for the facets
identified by the argument <em>cats</em>. This facet is supplied by the named
locale identified by the argument <em>std_name</em>. The newly constructed locale
object will have a name if <em>other</em> is a named locale. The constructor
will throw a runtime_error exception if the argument <em>std_name</em> is not
valid or null.
</p>
<hr>
<pre>
<a name="locale5">
Method locale()</a>
Access Public
Classification Constructor
Syntax template <class Facet> locale(const locale& other,
Facet* f);
Parameters <em>other</em> is the locale in which the newly constructed
locale is a copy.
<em>f</em> is the facet type not supplied by the locale
facet object other.
Returns None
</pre>
<h3>Description</h3>
<p>
This constructor is a template function. The constructor constructs a locale
object that is a copy of the argument locale <em>other</em>. All facets are
copied except for the facet type identified by the argument <em>f</em>, the facet <em>f</em>
supplies that facet. The newly constructed locale has no name.
</p>
<hr>
<pre>
<a name="locale6">
Method locale()</a>
Access Public
Classification Constructor
Syntax template <class Facet> locale(const locale& other,
const locale& one);
Parameters <em>other</em> is the locale in which the newly constructed
locale is a copy.
<em>one</em> is the locale object that supplies the missing
facet.
Return None
</pre>
<h3>Description</h3>
<p>
This constructor is a template function. The constructor constructs a locale
object that is a copy of the argument locale <em>other</em>. All facets are
copied except for the facet type identified by the template argument <em>Facet</em>.
That facet is supplied from the locale <em>one</em>. The constructor will throw a
runtime_error exception if the has_facet<Facet>(one) is false.
</p>
<hr>
<pre>
<a name="locale7">
Method locale()</a>
Access Public
Classification Constructor
Syntax locale(const locale& other, const locale& one,
category cats);
Parameters <em>other</em> is the locale in which the newly constructed
locale is a copy.
<em>one</em> is the locale object that supplies the facets
identified by the argument cats.
<em>cats</em> is the <a href="locale.htm#category">category</a> object that supplies the
name of a facet or facets. The newly constructed locale
object will not have a copy of the facet or facets
identified by this argument.
Returns None
</pre>
<h3>Description</h3>
<p>
The constructor constructs a locale object that is a copy of the
argument locale <em>other</em>. All facets are copied except for the facets
identified by the argument <em>cats</em>. This facet is supplied by the locale
identified by the argument <em>one</em>. The newly constructed locale
object will have a name if <em>other</em> and <em>one</em> are named locales.
</p>
<hr>
<pre>
<a name="~locale">
Method locale()</a>
Access Public
Classification Destructor
Syntax ~locale() throw();
Parameters None
Returns None
</pre>
<h3>Description</h3>
<p>
The destructor destroys a locale object.
</p>
<hr>
<pre>
<a name="operator=">
Method operator=()</a>
Access Public
Classification Assignment Operator
Syntax const locale& operator=(const locale& other) throw();
Parameters <em>other</em> is the locale in which the newly constructed
locale is a copy.
Return This method returns *this.
</pre>
<h3>Description</h3>
<p>
The operator=() method constructs a copy of the locale argument <em>other</em>. This
will replace the current value.
</p>
<hr>
<pre>
<a name="locale-name">
Method name()</a>
Access Public
Classification Accessor
Syntax basic_string<char> name() const;
Parameters None
Return This method returns a basic_string object which
contains the name of the locale if it has one.
</pre>
<h3>Description</h3>
<p>
The name() method returns the name of the locale object. If the locale
does not have a name the method will return "*".
</p>
<hr>
<pre>
<a name="operator==">
Method operator==()</a>
Access Public
Classification Relational Operator
Syntax bool operator==(const locale& other) const;
Parameters <em>other</em> is the locale used for comparison with the
calling object.
Return This method returns true if both locales are equal.
</pre>
<h3>Description</h3>
<p>
The operator==() method returns true if the calling object and the locale
<em>other</em> are the same locales, one is a copy of the other, or each has a
name or names that are identical.
</p>
<hr>
<pre>
<a name="operator!=">
Method operator!=()</a>
Access Public
Classification Relational Operator
Syntax bool operator!=(const locale& other) const;
Parameters <em>other</em> is the locale used for comparison with the
calling object.
Return This method returns true if the locales are not
equal.
</pre>
<h3>Description</h3>
<p>
The operator==() method returns the results of the expression !(*this == other).
</p>
<hr>
<pre>
<a name="operator()">
Method operator()()</a>
Access Public
Classification Function Operator
Syntax template<class charT, class Traits, class Allocator>
bool operator()(const basic_string<charT,
Traits,
Allocator>& s1,
const basic_string<charT,
Traits,
Allocator>& s2) const;
Parameters <em>s1</em> is used in the comparison.
<em>s2</em> is used in the comparison.
Returns The method returns the results of the expression:
use_facet<collate<charT> >(*this).
compare(s1.data(), s1.data() + s1.size(),
s2.data(),
s2.data() + s2.size()) < 0;
</pre>
<h3>Description</h3>
<p>
The operator()() method compares two strings according to the collate<charT>
facet.
</p>
<hr>
<pre>
<a name="locale-global">
Method global()</a>
Access Public
Classification Modifier
Syntax static locale global(const locale& loc) const;
Parameters <em>loc</em> is the locale used to set the global locale.
Returns This method returns the previous value of locale().
</pre>
<h3>Description</h3>
<p>
The global() method sets the global locale to the argument <em>loc</em>. This will
cause any future calls to the constructor locale() to return a copy of the
argument.
</p>
<hr>
<a name="crd"><h2>The Class Relationship Diagram for locale</h2></a>
<img src="locale.gif">
<hr>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -