|
|
|
| 1 |
|
// xlocmes internal header (from <locale>) |
| 2 |
|
#pragma once |
| 3 |
|
#ifndef _XLOCMES_ |
| 4 |
|
#define _XLOCMES_ |
| 5 |
|
#ifndef RC_INVOKED |
| 6 |
|
#include <xiosbase> |
| 7 |
|
|
| 8 |
|
#ifdef _MSC_VER |
| 9 |
|
#pragma pack(push,_CRT_PACKING) |
| 10 |
|
#pragma warning(push,3) |
| 11 |
|
#endif /* _MSC_VER */ |
| 12 |
|
_STD_BEGIN |
| 13 |
|
|
| 14 |
|
#pragma warning(push) |
| 15 |
|
#pragma warning(disable:4275) |
| 16 |
|
// STRUCT messages_base |
| 17 |
|
struct _CRTIMP2_PURE messages_base |
| 18 |
|
: public locale::facet |
| 19 |
|
{ // base class for messages |
| 20 |
|
typedef int catalog; |
| 21 |
|
|
| 22 |
|
explicit __CLR_OR_THIS_CALL messages_base(size_t _Refs = 0) |
| 23 |
|
: locale::facet(_Refs) |
| 24 |
|
{ // default constructor |
| 25 |
|
} |
| 26 |
|
|
| 27 |
|
__CLR_OR_THIS_CALL ~messages_base() |
| 28 |
|
{ |
| 29 |
|
} |
| 30 |
|
}; |
| 31 |
|
#pragma warning(pop) |
| 32 |
|
|
| 33 |
|
// TEMPLATE CLASS messages |
| 34 |
|
template<class _Elem> |
| 35 |
|
class messages |
| 36 |
|
: public messages_base |
| 37 |
|
{ // facet for obtaining messages from a catalog |
| 38 |
|
public: |
| 39 |
|
typedef _Elem char_type; |
| 40 |
|
typedef basic_string<_Elem, char_traits<_Elem>, allocator<_Elem> > |
| 41 |
|
string_type; |
| 42 |
|
|
| 43 |
|
catalog __CLR_OR_THIS_CALL open(const string& _Catname, const locale& _Loc) const |
| 44 |
|
{ // open catalog |
| 45 |
|
return (do_open(_Catname, _Loc)); |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
string_type __CLR_OR_THIS_CALL get(catalog _Catval, int _Set, int _Message, |
| 49 |
|
const string_type& _Dflt) const |
| 50 |
|
{ // get message from set in catalog |
| 51 |
|
return (do_get(_Catval, _Set, _Message, _Dflt)); |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
void __CLR_OR_THIS_CALL close(catalog _Catval) const |
| 55 |
|
{ // close catalog |
| 56 |
|
do_close(_Catval); |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
__PURE_APPDOMAIN_GLOBAL static locale::id id; // unique facet id |
| 60 |
|
|
| 61 |
|
explicit __CLR_OR_THIS_CALL messages(size_t _Refs = 0) |
| 62 |
|
: messages_base(_Refs) |
| 63 |
|
{ // construct from current locale |
| 64 |
|
_BEGIN_LOCINFO(_Lobj) |
| 65 |
|
_Init(_Lobj); |
| 66 |
|
_END_LOCINFO() |
| 67 |
|
} |
| 68 |
|
|
| 79 |
|
*_Ppf = _NEW_CRT messages<_Elem>( |
| 80 |
|
_Locinfo(_Ploc->name())); |
| 81 |
|
return (_X_MESSAGES); |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
_PROTECTED: |
| 85 |
|
__CLR_OR_THIS_CALL messages(const char *_Locname, size_t _Refs = 0) |
| 86 |
|
: messages_base(_Refs) |
| 87 |
|
{ // construct from specified locale |
| 88 |
|
_BEGIN_LOCINFO(_Lobj(_Locname)) |
| 89 |
|
_Init(_Lobj); |
| 90 |
|
_END_LOCINFO() |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
virtual __CLR_OR_THIS_CALL ~messages() |
| 94 |
|
{ // destroy the object |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
protected: |
| 98 |
|
void __CLR_OR_THIS_CALL _Init(const _Locinfo&) |
| 99 |
|
{ // initialize from _Locinfo object (do nothing) |
| 100 |
|
} |
| 101 |
|
|
| 102 |
|
virtual catalog __CLR_OR_THIS_CALL do_open(const string&, const locale&) const |
| 103 |
|
{ // open catalog (do nothing) |
| 104 |
|
return (-1); |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
virtual string_type __CLR_OR_THIS_CALL do_get(catalog, int, int, |
| 108 |
|
const string_type& _Dflt) const |
| 109 |
|
{ // get message from set in catalog (return default) |
| 110 |
|
return (_Dflt); |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
virtual void __CLR_OR_THIS_CALL do_close(catalog) const |
| 114 |
|
{ // close catalog (do nothing) |
| 115 |
|
} |
| 116 |
|
}; |
| 117 |
|
|
| 118 |
|
// STATIC messages::id OBJECT |
| 119 |
|
template<class _Elem> |
| 120 |
|
__PURE_APPDOMAIN_GLOBAL locale::id messages<_Elem>::id; |
| 121 |
|
|
| 122 |
|
// TEMPLATE CLASS messages_byname |
| 123 |
|
template<class _Elem> |
| 124 |
|
class messages_byname |
| 125 |
|
: public messages<_Elem> |
| 126 |
|
{ // messages for named locale |
| 127 |
|
public: |
| 128 |
|
explicit messages_byname(const char *_Locname, size_t _Refs = 0) |
| 129 |
|
: messages<_Elem>(_Locname, _Refs) |
| 130 |
|
{ // construct for named locale |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
_PROTECTED: |
| 134 |
|
virtual __CLR_OR_THIS_CALL ~messages_byname() |
| 135 |
|
{ // destroy the object |
| 136 |
|
} |
| 137 |
|
}; |
| 138 |
|
|
| 139 |
|
#if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE) |
| 140 |
|
|
| 141 |
|
template class _CRTIMP2_PURE messages<char>; |
| 142 |
|
template class _CRTIMP2_PURE messages<wchar_t>; |
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
#endif /* _DLL_CPPLIB */ |
| 147 |
|
_STD_END |
| 148 |
|
#ifdef _MSC_VER |
| 149 |
|
#pragma warning(pop) |
| 150 |
|
#pragma pack(pop) |
| 151 |
|
#endif /* _MSC_VER */ |
| 152 |
|
|
| 153 |
|
#endif /* RC_INVOKED */ |
| 154 |
|
#endif /* _XLOCMES_ */ |
| 155 |
|
|
| 156 |
|
/* |
| 157 |
|
* Copyright (c) 1992-2007 by P.J. Plauger. ALL RIGHTS RESERVED. |
| 158 |
|
* Consult your license regarding permissions and restrictions. |
| 159 |
|
V5.03:0009 */ |
| 160 |
|
|
|
|
|