/*
 * Copyright (c) 1999 
 * Boris Fomitchev
 *
 * This material is provided "as is", with absolutely no warranty expressed
 * or implied. Any use is at your own risk.
 *
 * Permission to use or copy this software for any purpose is hereby granted 
 * without fee, provided the above notices are retained on all copies.
 * Permission to modify the code and to distribute modified code is granted,
 * provided the above notices are retained, and a notice that the code was
 * modified is included with the above copyright notice.
 *
 */

#ifndef __STLPORT_CWCHAR
# define __STLPORT_CWCHAR

# ifndef __STL_CONFIG_H
#  include <stl_config.h>
# endif

# if ! defined (__STL_WINCE)

#  if defined ( __STL_REDEFINE_STD ) && defined (std) 
#    undef std
#    define __STL_RESUME_STD_FOR_CWCHAR
#    define __STLPORT_NATIVE_PASS
#  endif

# if defined  (__STL_USE_NEW_C_HEADERS)

#  include __STL_NATIVE_CPP_C_HEADER(cwchar)

# elif defined (__MRC__) || defined (__SC__) || defined (__BORLANDC__)

#  include <stddef.h>

# else

#  include <wchar.h>

# endif

// this stuff is varying a lot between platforms
#if defined(__MSL__) && __MSL__ <= 0x5012	// dwa 2/28/99 - not yet implemented by MSL 
#  define __STL_WCHAR_MSL_EXCLUDE 1
#  define __STL_NO_MBSTATE_T 1
#elif defined(__sun) && defined (__SVR4) && !defined (_MBSTATE_T) && !defined (_STD_MBSTATE_T)
# ifndef __STL_NO_NATIVE_MBSTATE_T
#  define __STL_NO_NATIVE_MBSTATE_T 1
# endif
# define __STL_WCHAR_SUNPRO_EXCLUDE 1
# if defined ( __STLPORT_NEW_IOSTREAMS )
#  define _MBSTATE_T
#  define _STD_MBSTATE_T
# else
#  define __STL_NO_MBSTATE_T 1
# endif
#elif defined (__BORLANDC__)
#  define __STL_NO_MBSTATE_T 1
#  define __STL_WCHAR_BORLAND_EXCLUDE 1
#  if (__BORLANDC__ < 0x540 )
#   define __STL_WCHAR_SUNPRO_EXCLUDE
#  endif
#endif

# if defined ( __STLPORT_NEW_IOSTREAMS ) && defined (__STL_NO_NATIVE_MBSTATE_T)&& ! defined (__STL_NO_MBSTATE_T)
#  define __STL_USE_OWN_MBSTATE_T
# endif

# ifdef __STL_USE_OWN_MBSTATE_T

struct __stl_mbstate_t { 
  __stl_mbstate_t( long __st = 0 ) : _M_state(__st) {}
  __stl_mbstate_t& operator=(const long __st) {
    _M_state= __st;              
    return *this;
  } 
  // default ones
  __stl_mbstate_t(const __stl_mbstate_t& __x) : _M_state(__x._M_state) {}         
  __stl_mbstate_t& operator=(const __stl_mbstate_t& __x) {
    _M_state= __x._M_state;              
    return *this;
  }       
  long _M_state;
  //  friend inline bool operator==(const __stl_mbstate_t& __x, const __stl_mbstate_t& __y);
  //  friend inline bool operator!=(const __stl_mbstate_t& __x, const __stl_mbstate_t& __y);    
};          

inline bool operator==(const __stl_mbstate_t& __x, const __stl_mbstate_t& __y) {
  return ( __x._M_state == __y._M_state );
}

inline bool operator!=(const __stl_mbstate_t& __x, const __stl_mbstate_t& __y) {
  return ( __x._M_state == __y._M_state );
}

typedef __stl_mbstate_t mbstate_t;
# endif

// dwa 2/28/99 - Fix an MSL bug. We expect this to be fixed in the next release.
# if defined(__STL_WCHAR_MSL_EXCLUDE)
namespace std
{ 
  extern "C" size_t wcsftime(wchar_t * str, size_t max_size, const wchar_t * format_str, const struct tm * timeptr);
}
# endif


#  if defined (__STL_NO_MBSTATE_T) && !defined (__STL_NO_NATIVE_MBSTATE_T)
#   define __STL_NO_NATIVE_MBSTATE_T 1
#  endif

# if defined ( __STL_RESUME_STD_FOR_CWCHAR )
#    undef __STL_RESUME_STD_FOR_CWCHAR
#    define std __STLPORT_NAMESPACE
#    undef __STLPORT_NATIVE_PASS
# endif


# ifdef __STL_IMPORT_VENDOR_CSTD
__STL_BEGIN_NAMESPACE

using __STL_VENDOR_CSTD::wint_t;
using __STL_VENDOR_CSTD::size_t;

#  if !defined (__STL_NO_NATIVE_MBSTATE_T)
using __STL_VENDOR_MB_NAMESPACE::mbstate_t;
using __STL_VENDOR_MB_NAMESPACE::btowc;
using __STL_VENDOR_MB_NAMESPACE::mbrlen;
using __STL_VENDOR_MB_NAMESPACE::mbrtowc;
using __STL_VENDOR_MB_NAMESPACE::mbsinit;
using __STL_VENDOR_MB_NAMESPACE::mbsrtowcs;
using __STL_VENDOR_MB_NAMESPACE::wcrtomb;
using __STL_VENDOR_MB_NAMESPACE::wcsrtombs;
#  endif

# ifndef __STL_NO_NATIVE_WIDE_FUNCTIONS

# ifndef __STL_WCHAR_BORLAND_EXCLUDE
using __STL_VENDOR_CSTD::fgetwc;
using __STL_VENDOR_CSTD::fgetws;
using __STL_VENDOR_CSTD::fputwc;
using __STL_VENDOR_CSTD::fputws;
# endif

#  if !( defined (__STL_WCHAR_SUNPRO_EXCLUDE) || defined (__STL_WCHAR_BORLAND_EXCLUDE)) 
# ifndef __DECCXX
using __STL_VENDOR_CSTD::fwide;
# endif
using __STL_VENDOR_CSTD::fwprintf;
using __STL_VENDOR_CSTD::fwscanf;
using __STL_VENDOR_CSTD::getwchar;
#  endif

# ifndef __STL_WCHAR_BORLAND_EXCLUDE
using __STL_VENDOR_CSTD::getwc;
using __STL_VENDOR_CSTD::ungetwc;

using __STL_VENDOR_CSTD::putwc;
using __STL_VENDOR_CSTD::putwchar;
# endif

#  if !( defined (__STL_WCHAR_SUNPRO_EXCLUDE) || defined (__STL_WCHAR_BORLAND_EXCLUDE)) 
using __STL_VENDOR_CSTD::swprintf;
using __STL_VENDOR_CSTD::swscanf;
using __STL_VENDOR_CSTD::vfwprintf;
using __STL_VENDOR_CSTD::vwprintf;
using __STL_VENDOR_CSTD::vswprintf;

using __STL_VENDOR_CSTD::wcsftime;
using __STL_VENDOR_CSTD::wcstok;

#  endif

using __STL_VENDOR_CSTD::wcscat;
using __STL_VENDOR_CSTD::wcsrchr;
using __STL_VENDOR_CSTD::wcscmp;
using __STL_VENDOR_CSTD::wcscoll;

using __STL_VENDOR_CSTD::wcscpy;
using __STL_VENDOR_CSTD::wcscspn;

using __STL_VENDOR_CSTD::wcslen;
using __STL_VENDOR_CSTD::wcsncat;
using __STL_VENDOR_CSTD::wcsncmp;
using __STL_VENDOR_CSTD::wcsncpy;
using __STL_VENDOR_CSTD::wcspbrk;
using __STL_VENDOR_CSTD::wcschr;

using __STL_VENDOR_CSTD::wcsspn;
using __STL_VENDOR_CSTD::wcsxfrm;

#  if !defined (__STL_WCHAR_BORLAND_EXCLUDE)

using __STL_VENDOR_CSTD::wcstod;
using __STL_VENDOR_CSTD::wcstol;

# endif

#  ifndef __STL_WCHAR_SUNPRO_EXCLUDE

using __STL_VENDOR_CSTD::wcsstr;
using __STL_VENDOR_CSTD::wmemchr;

#  if !defined (__STL_WCHAR_BORLAND_EXCLUDE)

using __STL_VENDOR_CSTD::wctob;
using __STL_VENDOR_CSTD::wmemcmp;
using __STL_VENDOR_CSTD::wmemmove;
using __STL_VENDOR_CSTD::wprintf;
using __STL_VENDOR_CSTD::wscanf;

#  endif

using __STL_VENDOR_CSTD::wmemcpy;
using __STL_VENDOR_CSTD::wmemset;
#  endif

# endif /* __STL_NO_NATIVE_WIDE_FUNCTIONS */

__STL_END_NAMESPACE

# endif /* __STL_IMPORT_VENDOR_CSTD */

# undef __STL_WCHAR_SUNPRO_EXCLUDE
# undef __STL_WCHAR_MSL_EXCLUDE

# endif /* CWCHAR */

#endif /* __STLPORT_CWCHAR */

// Local Variables:
// mode:C++
// End:
