_messages_facets.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. // WARNING: This is an internal header file, included by other C++
  19. // standard library headers. You should not attempt to use this header
  20. // file directly.
  21. #ifndef _STLP_INTERNAL_MESSAGES_H
  22. #define _STLP_INTERNAL_MESSAGES_H
  23. #ifndef _STLP_IOS_BASE_H
  24. # include <stl/_ios_base.h>
  25. #endif
  26. #ifndef _STLP_C_LOCALE_H
  27. # include <stl/c_locale.h>
  28. #endif
  29. #ifndef _STLP_INTERNAL_STRING_H
  30. # include <stl/_string.h>
  31. #endif
  32. _STLP_BEGIN_NAMESPACE
  33. // messages facets
  34. class messages_base {
  35. public:
  36. typedef int catalog;
  37. };
  38. template <class _CharT> class messages {};
  39. _STLP_MOVE_TO_PRIV_NAMESPACE
  40. class _Messages;
  41. _STLP_MOVE_TO_STD_NAMESPACE
  42. _STLP_TEMPLATE_NULL
  43. class _STLP_CLASS_DECLSPEC messages<char> : public locale::facet, public messages_base {
  44. public:
  45. typedef messages_base::catalog catalog;
  46. typedef char char_type;
  47. typedef string string_type;
  48. explicit messages(size_t __refs = 0);
  49. catalog open(const string& __fn, const locale& __loc) const
  50. { return do_open(__fn, __loc); }
  51. string_type get(catalog __c, int __set, int __msgid,
  52. const string_type& __dfault) const
  53. { return do_get(__c, __set, __msgid, __dfault); }
  54. inline void close(catalog __c) const
  55. { do_close(__c); }
  56. static _STLP_STATIC_DECLSPEC locale::id id;
  57. protected:
  58. ~messages() {}
  59. virtual catalog do_open(const string& __fn, const locale& __loc) const
  60. { return -1; }
  61. virtual string_type do_get(catalog __c, int __set, int __msgid,
  62. const string_type& __dfault) const
  63. { return __dfault; }
  64. virtual void do_close(catalog __c) const
  65. {}
  66. };
  67. #if !defined (_STLP_NO_WCHAR_T)
  68. _STLP_TEMPLATE_NULL
  69. class _STLP_CLASS_DECLSPEC messages<wchar_t> : public locale::facet, public messages_base {
  70. public:
  71. typedef messages_base::catalog catalog;
  72. typedef wchar_t char_type;
  73. typedef wstring string_type;
  74. explicit messages(size_t __refs = 0);
  75. inline catalog open(const string& __fn, const locale& __loc) const
  76. { return do_open(__fn, __loc); }
  77. inline string_type get(catalog __c, int __set, int __msgid,
  78. const string_type& __dfault) const
  79. { return do_get(__c, __set, __msgid, __dfault); }
  80. inline void close(catalog __c) const
  81. { do_close(__c); }
  82. static _STLP_STATIC_DECLSPEC locale::id id;
  83. protected:
  84. ~messages() {}
  85. virtual catalog do_open(const string& __fn, const locale& __loc) const
  86. { return -1; }
  87. virtual string_type do_get(catalog __c, int __set, int __msgid,
  88. const string_type& __dfault) const
  89. { return __dfault; }
  90. virtual void do_close(catalog __c) const
  91. {}
  92. };
  93. #endif
  94. template <class _CharT> class messages_byname {};
  95. _STLP_TEMPLATE_NULL
  96. class _STLP_CLASS_DECLSPEC messages_byname<char> : public messages<char> {
  97. friend class _Locale_impl;
  98. public:
  99. typedef messages_base::catalog catalog;
  100. typedef string string_type;
  101. explicit messages_byname(const char* __name, size_t __refs = 0);
  102. protected:
  103. ~messages_byname();
  104. virtual catalog do_open(const string& __fn, const locale& __loc) const;
  105. virtual string_type do_get(catalog __c, int __set, int __msgid,
  106. const string_type& __dfault) const;
  107. virtual void do_close(catalog __c) const;
  108. private:
  109. messages_byname(_Locale_messages*);
  110. typedef messages_byname<char> _Self;
  111. //explicitely defined as private to avoid warnings:
  112. messages_byname(_Self const&);
  113. _Self& operator = (_Self const&);
  114. _STLP_PRIV _Messages* _M_impl;
  115. };
  116. #if !defined (_STLP_NO_WCHAR_T)
  117. _STLP_TEMPLATE_NULL
  118. class _STLP_CLASS_DECLSPEC messages_byname<wchar_t> : public messages<wchar_t> {
  119. friend class _Locale_impl;
  120. public:
  121. typedef messages_base::catalog catalog;
  122. typedef wstring string_type;
  123. explicit messages_byname(const char* __name, size_t __refs = 0);
  124. protected:
  125. ~messages_byname();
  126. virtual catalog do_open(const string& __fn, const locale& __loc) const;
  127. virtual string_type do_get(catalog __c, int __set, int __msgid,
  128. const string_type& __dfault) const;
  129. virtual void do_close(catalog __c) const;
  130. private:
  131. messages_byname(_Locale_messages*);
  132. typedef messages_byname<wchar_t> _Self;
  133. //explicitely defined as private to avoid warnings:
  134. messages_byname(_Self const&);
  135. _Self& operator = (_Self const&);
  136. _STLP_PRIV _Messages* _M_impl;
  137. };
  138. #endif /* WCHAR_T */
  139. _STLP_END_NAMESPACE
  140. #endif /* _STLP_INTERNAL_MESSAGES_H */
  141. // Local Variables:
  142. // mode:C++
  143. // End: