1/*
2 * Copyright (c) 1999
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
10 *
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
16 *
17 */
18
19// WARNING: This is an internal header file, included by other C++
20// standard library headers.  You should not attempt to use this header
21// file directly.
22
23
24#ifndef _STLP_INTERNAL_MESSAGES_H
25#define _STLP_INTERNAL_MESSAGES_H
26
27#ifndef _STLP_IOS_BASE_H
28#  include <stl/_ios_base.h>
29#endif
30
31#ifndef _STLP_C_LOCALE_H
32#  include <stl/c_locale.h>
33#endif
34
35#ifndef _STLP_INTERNAL_STRING_H
36#  include <stl/_string.h>
37#endif
38
39_STLP_BEGIN_NAMESPACE
40
41// messages facets
42
43class messages_base {
44  public:
45    typedef int catalog;
46};
47
48template <class _CharT> class messages {};
49
50_STLP_MOVE_TO_PRIV_NAMESPACE
51class _Messages;
52_STLP_MOVE_TO_STD_NAMESPACE
53
54_STLP_TEMPLATE_NULL
55class _STLP_CLASS_DECLSPEC messages<char> : public locale::facet, public messages_base {
56public:
57  typedef messages_base::catalog catalog;
58  typedef char                   char_type;
59  typedef string                 string_type;
60
61  explicit messages(size_t __refs = 0);
62
63  catalog open(const string& __fn, const locale& __loc) const
64  { return do_open(__fn, __loc); }
65  string_type get(catalog __c, int __set, int __msgid,
66                  const string_type& __dfault) const
67  { return do_get(__c, __set, __msgid, __dfault); }
68  inline void close(catalog __c) const
69  { do_close(__c); }
70
71  static _STLP_STATIC_DECLSPEC locale::id id;
72
73protected:
74  ~messages() {}
75
76  virtual catalog     do_open(const string& __fn, const locale& __loc) const
77  { return -1; }
78  virtual string_type do_get(catalog __c, int __set, int __msgid,
79                             const string_type& __dfault) const
80  { return __dfault; }
81  virtual void        do_close(catalog __c) const
82  {}
83};
84
85#if !defined (_STLP_NO_WCHAR_T)
86
87_STLP_TEMPLATE_NULL
88class _STLP_CLASS_DECLSPEC messages<wchar_t> : public locale::facet, public messages_base {
89public:
90  typedef messages_base::catalog catalog;
91  typedef wchar_t                char_type;
92  typedef wstring                string_type;
93
94  explicit messages(size_t __refs = 0);
95
96  inline catalog open(const string& __fn, const locale& __loc) const
97  { return do_open(__fn, __loc); }
98  inline string_type get(catalog __c, int __set, int __msgid,
99                         const string_type& __dfault) const
100  { return do_get(__c, __set, __msgid, __dfault); }
101  inline void close(catalog __c) const
102  { do_close(__c); }
103
104  static _STLP_STATIC_DECLSPEC locale::id id;
105
106protected:
107  ~messages() {}
108
109  virtual catalog     do_open(const string& __fn, const locale& __loc) const
110  { return -1; }
111  virtual string_type do_get(catalog __c, int __set, int __msgid,
112                             const string_type& __dfault) const
113  { return __dfault; }
114  virtual void        do_close(catalog __c) const
115  {}
116};
117
118#endif
119
120template <class _CharT> class messages_byname {};
121
122_STLP_TEMPLATE_NULL
123class _STLP_CLASS_DECLSPEC messages_byname<char> : public messages<char> {
124  friend class _Locale_impl;
125public:
126  typedef messages_base::catalog catalog;
127  typedef string     string_type;
128
129  explicit messages_byname(const char* __name, size_t __refs = 0);
130
131protected:
132  ~messages_byname();
133
134  virtual catalog     do_open(const string& __fn, const locale& __loc) const;
135  virtual string_type do_get(catalog __c, int __set, int __msgid,
136                             const string_type& __dfault) const;
137  virtual void        do_close(catalog __c) const;
138
139private:
140  messages_byname(_Locale_messages*);
141  typedef messages_byname<char> _Self;
142  //explicitely defined as private to avoid warnings:
143  messages_byname(_Self const&);
144  _Self& operator = (_Self const&);
145
146  _STLP_PRIV _Messages* _M_impl;
147};
148
149#if !defined (_STLP_NO_WCHAR_T)
150_STLP_TEMPLATE_NULL
151class _STLP_CLASS_DECLSPEC messages_byname<wchar_t> : public messages<wchar_t> {
152  friend class _Locale_impl;
153public:
154  typedef messages_base::catalog catalog;
155  typedef wstring                string_type;
156
157  explicit messages_byname(const char* __name, size_t __refs = 0);
158
159protected:
160  ~messages_byname();
161
162  virtual catalog     do_open(const string& __fn, const locale& __loc) const;
163  virtual string_type do_get(catalog __c, int __set, int __msgid,
164                             const string_type& __dfault) const;
165  virtual void        do_close(catalog __c) const;
166
167private:
168  messages_byname(_Locale_messages*);
169  typedef messages_byname<wchar_t> _Self;
170  //explicitely defined as private to avoid warnings:
171  messages_byname(_Self const&);
172  _Self& operator = (_Self const&);
173
174  _STLP_PRIV _Messages* _M_impl;
175};
176#endif /* WCHAR_T */
177
178_STLP_END_NAMESPACE
179
180#endif /* _STLP_INTERNAL_MESSAGES_H */
181
182// Local Variables:
183// mode:C++
184// End:
185
186