windows-nt/Source/XPSP1/NT/base/crts/crtw32/stdhpp/xlocmes

131 lines
2.9 KiB
Plaintext
Raw Normal View History

2020-09-26 03:20:57 -05:00
// xlocmes internal header (from <locale>)
#pragma once
#ifndef _XLOCMES_
#define _XLOCMES_
#include <xiosbase>
#pragma pack(push,8)
#pragma warning(push,3)
_STD_BEGIN
// STRUCT messages_base
struct _CRTIMP2 messages_base
: public locale::facet
{ // base class for messages
typedef int catalog;
explicit messages_base(size_t _Refs = 0)
: locale::facet(_Refs)
{ // default constructor
}
};
// TEMPLATE CLASS messages
template<class _Elem>
class messages
: public messages_base
{ // facet for obtaining messages from a catalog
public:
typedef _Elem char_type;
typedef basic_string<_Elem, char_traits<_Elem>, allocator<_Elem> >
string_type;
catalog open(const string& _Catname, const locale& _Loc) const
{ // open catalog
return (do_open(_Catname, _Loc));
}
string_type get(catalog _Catval, int _Set, int _Message,
const string_type& _Dflt) const
{ // get message from set in catalog
return (do_get(_Catval, _Set, _Message, _Dflt));
}
void close(catalog _Catval) const
{ // close catalog
do_close(_Catval);
}
static locale::id id; // unique facet id
explicit messages(size_t _Refs = 0)
: messages_base(_Refs)
{ // construct from current locale
_Init(_Locinfo());
}
messages(const _Locinfo& _Lobj, size_t _Refs = 0)
: messages_base(_Refs)
{ // construct from specified locale
_Init(_Lobj);
}
static size_t __cdecl _Getcat(const locale::facet **_Ppf = 0)
{ // return locale category mask and construct standard facet
if (_Ppf != 0 && *_Ppf == 0)
*_Ppf = _NEW_CRT messages<_Elem>;
return (_X_MESSAGE);
}
protected:
void _Init(const _Locinfo&)
{ // initialize from _Locinfo object (do nothing)
}
virtual catalog do_open(const string&, const locale&) const
{ // open catalog (do nothing)
return (0);
}
virtual string_type do_get(catalog, int, int,
const string_type& _Dflt) const
{ // get message from set in catalog (return default)
return (_Dflt);
}
virtual void do_close(catalog) const
{ // close catalog (do nothing)
}
};
// STATIC messages::id OBJECT
template<class _Elem>
locale::id messages<_Elem>::id;
// TEMPLATE CLASS messages_byname
template<class _Elem>
class messages_byname
: public messages<_Elem>
{ // messages for named locale
public:
explicit messages_byname(const char *_Locname, size_t _Refs = 0)
: messages<_Elem>(_Locinfo(_Locname), _Refs)
{ // construct for named locale
}
_PROTECTED:
virtual ~messages_byname()
{ // destroy the object
}
};
#ifdef _DLL_CPPLIB
#ifdef __FORCE_INSTANCE
template class _CRTIMP2 messages<char>;
template class _CRTIMP2 messages<wchar_t>;
#ifdef _CRTBLD_NATIVE_WCHAR_T
template class _CRTIMP2 messages<unsigned short>;
#endif
#endif // __FORCE_INSTANCE
#endif // _DLL_CPPLIB
_STD_END
#pragma warning(pop)
#pragma pack(pop)
#endif /* _XLOCMES_ */
/*
* Copyright (c) 1992-2001 by P.J. Plauger. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
V3.10:0009 */