// xlocmes internal header (from <locale>)
#ifndef _XLOCMES_
#define _XLOCMES_
#include <xiosbase>

 #if defined(__ghs)
  #pragma ghs start_cxx_lib_header
  #pragma ghs startdata
  #if defined(__ghs_max_pack_value)
   #pragma pack (push, __ghs_max_pack_value)
  #endif /* defined(__ghs_max_pack_value) */
 #endif /* defined(__ghs) */

_STD_BEGIN
		// STRUCT messages_base

struct messages_base
	: public locale::facet
	{	// base class for messages
	typedef int catalog;

#if defined(__ghs)
	// The standard lists no constructors, so default constructor must not be
	// explicit.
	messages_base()
		: locale::facet(0)
		{
		}

	explicit messages_base(size_t _Refs)
#else
	explicit messages_base(size_t _Refs = 0)
#endif
		: 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
		_BEGIN_LOCINFO(_Lobj)
			_Init(_Lobj);
		_END_LOCINFO()
		}

	messages(const _Locinfo& _Lobj, size_t _Refs = 0)
		: messages_base(_Refs)
		{	// construct from specified locale
		_Init(_Lobj);
		}

	static size_t _Getcat(const locale::facet **_Ppf = 0,
		const locale *_Ploc = 0)
		{	// return locale category mask and construct standard facet
		if (_Ppf != 0 && *_Ppf == 0)
#if defined(__ghs) && !_HAS_EXCEPTIONS
			*_Ppf = (messages<_Elem> *)_CHECK_LIB_ALLOC(new messages<_Elem>(
				_Locinfo(_Ploc->c_str())));
#else  /* defined(__ghs) && !_HAS_EXCEPTIONS */
			*_Ppf = new messages<_Elem>(
				_Locinfo(_Ploc->c_str()));
#endif /* defined(__ghs) && !_HAS_EXCEPTIONS */
		return (_X_MESSAGES);
		}

protected:
	messages(const char *_Locname, size_t _Refs = 0)
		: messages_base(_Refs)
		{	// construct from specified locale
		_BEGIN_LOCINFO(_Lobj(_Locname))
			_Init(_Lobj);
		_END_LOCINFO()
		}

#ifdef __ghs
	__noinline
#endif /* __ghs */
	virtual ~messages() _NOEXCEPT
#if defined(__ghs) && defined(__ghs_shared_object_support)
			;
#else /* !(__ghs && defined(__ghs_shared_object_support)) */
		{	// destroy the object
		}
#endif /* __ghs && defined(__ghs_shared_object_support) */

	void _Init(const _Locinfo&)
		{	// initialize from _Locinfo object (do nothing)
		}

#if defined(__ghs)
	__noinline
#endif /* __ghs */
	virtual catalog do_open(const string&, const locale&) const
		{	// open catalog (do nothing)
		return (-1);
		}

#if defined(__ghs)
	__noinline
#endif /* __ghs */
	virtual string_type do_get(catalog, int, int,
		const string_type& _Dflt) const
		{	// get message from set in catalog (return default)
		return (_Dflt);
		}

#if defined(__ghs)
	__noinline
#endif /* __ghs */
	virtual void do_close(catalog) const
		{	// close catalog (do nothing)
		}
	};

#if defined(__ghs) && defined(__ghs_shared_object_support)
template<class _Elem>
	messages<_Elem>::~messages() _NOEXCEPT
	{	// destroy the object
	}
#endif /* __ghs && defined(__ghs_shared_object_support) */

		// 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>(_Locname, _Refs)
		{	// construct for named locale
		}

	explicit messages_byname(const string& _Str, size_t _Refs = 0)
		: messages<_Elem>(_Str.c_str(), _Refs)
		{	// construct for named locale
		}

protected:
#ifdef __ghs
	__noinline
#endif
	virtual ~messages_byname() _NOEXCEPT
#if defined(__ghs) && defined(__ghs_shared_object_support)
				;
#else /* !(__ghs && defined(__ghs_shared_object_support)) */
		{	// destroy the object
		}
#endif /* !(__ghs && defined(__ghs_shared_object_support)) */
	};

#if defined(__ghs) && defined(__ghs_shared_object_support)
template<class _Elem>
	messages_byname<_Elem>::~messages_byname() _NOEXCEPT
		{	// destroy the object
		}
#endif /* __ghs && defined(__ghs_shared_object_support) */
_STD_END

 #if defined(__ghs)
  #if defined(__ghs_max_pack_value)
   #pragma pack(pop)
  #endif /* defined(__ghs_max_pack_value) */
  #pragma ghs enddata
  #pragma ghs end_cxx_lib_header
 #endif /* defined(__ghs) */

#endif /* _XLOCMES_ */

/*
 * Copyright (c) by P.J. Plauger. All rights reserved.
 * Consult your license regarding permissions and restrictions.
V8.03b/17:0063 */
