OSDN Git Service

999e82ed0bd72620bd9d452fe0eee0b2ba534dad
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / docs / html / 22_locale / locale.html
1 <html>
2 <head>
3    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
4    <meta name="AUTHOR" content="bkoz@redhat.com (Benjamin Kosnik)" />
5    <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL" />
6    <meta name="DESCRIPTION" content="Notes on the locale implementation." />
7    <title>Notes on the locale implementation.</title>
8 <link rel="StyleSheet" href="../lib3styles.css" />
9 </head>
10 <body>
11   <h1>
12   Notes on the locale implementation.
13   </h1>
14 <em>
15 prepared by Benjamin Kosnik (bkoz@redhat.com) on August 8, 2001
16 </em>
17
18 <h2>
19 1. Abstract Describes the basic locale object, including nested
20 classes id, facet, and the reference-counted implementation object,
21 class _Impl.
22 </h2>
23 <p>
24 </p>
25
26 <h2>
27 2. What the standard says
28 </h2>
29 See Chapter 22 of the standard.
30
31
32 <h2>
33 3. Problems with &quot;C&quot; locales : global locales, termination.
34 </h2>
35
36 <p>
37 The major problem is fitting an object-orientated and non-global locale
38 design ontop of POSIX and other relevant stanards, which include the
39 Single Unix (nee X/Open.)
40
41 Because POSIX falls down so completely, portibility is an issue.
42 </p>
43
44 <h2>
45 4. Design
46 </h2>
47 Class locale in non-templatized and has three distinct types nested
48 inside of it:
49
50 class facet
51 22.1.1.1.2 Class locale::facet
52
53 Facets actually implement locale functionality. For instance, a facet
54 called numpunct is the data objects that can be used to query for the
55 thousands separator is in the German locale.
56
57 Literally, a facet is strictly defined:
58  - containing 
59 public:
60   static locale::id id;
61
62 - or derived from another facet
63
64 The only other thing of interest in this class is the memory
65 management of facets. Each constructor of a facet class takes a
66 std::size_t __refs argument: if __refs == 0, the facet is deleted when
67 no longer used. if __refs == 1, the facet is not destroyed, even when
68 it is no longer reference.
69
70
71 class id
72 Provides an index for looking up specific facets.
73
74 class _Impl
75
76 <h2>
77 5.  Examples
78 </h2>
79
80 <pre>
81   typedef __locale_t locale;
82 </pre>
83
84 More information can be found in the following testcases:
85 <ul>
86 <li> testsuite/22_locale/ctype_char_members.cc    </li>
87 <li> testsuite/22_locale/ctype_wchar_t_members.cc </li>
88 </ul>
89
90 <h2>
91 6.  Unresolved Issues
92 </h2>
93
94 <ul>
95    <li> locale -a displays available locales on linux </li>
96
97    <li> locale initialization: at what point does _S_classic,
98    _S_global get initialized? Can named locales assume this
99    initialization has already taken place? </li>
100
101    <li> document how named locales error check when filling data
102    members. Ie, a fr_FR locale that doesn't have
103    numpunct::truename(): does it use "true"? Or is it a blank
104    string? What's the convention? </li>
105
106    <li> explain how locale aliasing happens. When does "de_DE"
107    use "de" information? What is the rule for locales composed of
108    just an ISO language code (say, "de") and locales with both an
109    ISO language code and ISO country code (say, "de_DE"). </li>
110
111    <li> what should non-required facet instantiations do?  If the
112    generic implemenation is provided, then how to end-users
113    provide specializations? </li>
114 </ul>
115
116 <h2>
117 7. Acknowledgments
118 </h2>
119
120 <h2>
121 8. Bibliography / Referenced Documents
122 </h2>
123
124 Drepper, Ulrich, GNU libc (glibc) 2.2 manual. In particular, Chapters &quot;6. Character Set Handling&quot; and &quot;7 Locales and Internationalization&quot;
125
126 <p>
127 Drepper, Ulrich, Numerous, late-night email correspondence
128 </p>
129
130 <p>
131 ISO/IEC 14882:1998 Programming languages - C++
132 </p>
133
134 <p>
135 ISO/IEC 9899:1999 Programming languages - C
136 </p>
137
138 <p>
139 Langer, Angelika and Klaus Kreft, Standard C++ IOStreams and Locales, Advanced Programmer's Guide and Reference, Addison Wesley Longman, Inc. 2000
140 </p>
141
142 <p>
143 Stroustrup, Bjarne, Appendix D, The C++ Programming Language, Special Edition, Addison Wesley, Inc. 2000
144 </p>
145
146 <p>
147 System Interface Definitions, Issue 6 (IEEE Std. 1003.1-200x)
148 The Open Group/The Institute of Electrical and Electronics Engineers, Inc.
149 http://www.opennc.org/austin/docreg.html
150 </p>
151
152 </body>
153 </html>
154
155