Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

125 lines
2.8 KiB

  1. // xlocmes internal header (from <locale>)
  2. #pragma once
  3. #ifndef _XLOCMES_
  4. #define _XLOCMES_
  5. #include <xiosbase>
  6. #pragma pack(push,8)
  7. #pragma warning(push,3)
  8. _STD_BEGIN
  9. // STRUCT messages_base
  10. struct _CRTIMP2 messages_base
  11. : public locale::facet
  12. { // base class for messages
  13. typedef int catalog;
  14. explicit messages_base(size_t _Refs = 0)
  15. : locale::facet(_Refs)
  16. { // default constructor
  17. }
  18. };
  19. // TEMPLATE CLASS messages
  20. template<class _Elem>
  21. class messages
  22. : public messages_base
  23. { // facet for obtaining messages from a catalog
  24. public:
  25. typedef _Elem char_type;
  26. typedef basic_string<_Elem, char_traits<_Elem>, allocator<_Elem> >
  27. string_type;
  28. catalog open(const string& _Catname, const locale& _Loc) const
  29. { // open catalog
  30. return (do_open(_Catname, _Loc));
  31. }
  32. string_type get(catalog _Catval, int _Set, int _Message,
  33. const string_type& _Dflt) const
  34. { // get message from set in catalog
  35. return (do_get(_Catval, _Set, _Message, _Dflt));
  36. }
  37. void close(catalog _Catval) const
  38. { // close catalog
  39. do_close(_Catval);
  40. }
  41. static locale::id id; // unique facet id
  42. explicit messages(size_t _Refs = 0)
  43. : messages_base(_Refs)
  44. { // construct from current locale
  45. _Init(_Locinfo());
  46. }
  47. messages(const _Locinfo& _Lobj, size_t _Refs = 0)
  48. : messages_base(_Refs)
  49. { // construct from specified locale
  50. _Init(_Lobj);
  51. }
  52. static size_t __cdecl _Getcat(const locale::facet **_Ppf = 0)
  53. { // return locale category mask and construct standard facet
  54. if (_Ppf != 0 && *_Ppf == 0)
  55. *_Ppf = _NEW_CRT messages<_Elem>;
  56. return (_X_MESSAGE);
  57. }
  58. protected:
  59. void _Init(const _Locinfo&)
  60. { // initialize from _Locinfo object (do nothing)
  61. }
  62. virtual catalog do_open(const string&, const locale&) const
  63. { // open catalog (do nothing)
  64. return (0);
  65. }
  66. virtual string_type do_get(catalog, int, int,
  67. const string_type& _Dflt) const
  68. { // get message from set in catalog (return default)
  69. return (_Dflt);
  70. }
  71. virtual void do_close(catalog) const
  72. { // close catalog (do nothing)
  73. }
  74. };
  75. // STATIC messages::id OBJECT
  76. template<class _Elem>
  77. locale::id messages<_Elem>::id;
  78. // TEMPLATE CLASS messages_byname
  79. template<class _Elem>
  80. class messages_byname
  81. : public messages<_Elem>
  82. { // messages for named locale
  83. public:
  84. explicit messages_byname(const char *_Locname, size_t _Refs = 0)
  85. : messages<_Elem>(_Locinfo(_Locname), _Refs)
  86. { // construct for named locale
  87. }
  88. _PROTECTED:
  89. virtual ~messages_byname()
  90. { // destroy the object
  91. }
  92. };
  93. #ifdef _DLL_CPPLIB
  94. template class _CRTIMP2 messages<char>;
  95. template class _CRTIMP2 messages<wchar_t>;
  96. #endif // _DLL_CPPLIB
  97. _STD_END
  98. #pragma warning(pop)
  99. #pragma pack(pop)
  100. #endif /* _XLOCMES_ */
  101. /*
  102. * Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
  103. * Consult your license regarding permissions and restrictions.
  104. V3.10:0009 */