home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / wlocale.cpp < prev    next >
C/C++ Source or Header  |  1998-06-16  |  3KB  |  73 lines

  1. // wlocale -- class locale wide member functions
  2. #include <istream>
  3. #include <locale>
  4. _STD_BEGIN
  5.  
  6. typedef char_traits<wchar_t> _Wtraits;
  7. typedef istreambuf_iterator<wchar_t, _Wtraits> _Winiter;
  8. typedef ostreambuf_iterator<wchar_t, _Wtraits> _Woutiter;
  9.  
  10.         // facets associated with C categories
  11. #define ADDFAC(T, cat, pi, pl) \
  12.         if ((_CATMASK(T::_Getcat()) & cat) == 0) \
  13.                 ; \
  14.         else if (pl == 0) \
  15.                 pi->_Addfac(new T(_Lobj), T::id); \
  16.         else \
  17.                 pi->_Addfac((locale::facet *)&_USE(*pl, T), T::id);
  18.  
  19. typedef ctype<wchar_t> _Tw1;
  20. typedef num_get<wchar_t, _Winiter> _Tw2;
  21. typedef num_put<wchar_t, _Woutiter> _Tw3;
  22. typedef numpunct<wchar_t> _Tw4;
  23. typedef collate<wchar_t> _Tw5;
  24. typedef messages<wchar_t> _Tw6;
  25. typedef money_get<wchar_t, _Winiter> _Tw7;
  26. typedef money_put<wchar_t, _Woutiter> _Tw9;
  27. typedef moneypunct<wchar_t, false> _Tw11;
  28. typedef moneypunct<wchar_t, true> _Tw12;
  29. typedef time_get<wchar_t, _Winiter> _Tw13;
  30. typedef time_put<wchar_t, _Woutiter> _Tw14;
  31. typedef codecvt<wchar_t, char, mbstate_t> _Twc1;
  32.  
  33. template<> locale::id ctype<wchar_t>::id;
  34. template<> locale::id codecvt<wchar_t, char, mbstate_t>::id;
  35. template<> locale::id time_put<wchar_t, _Woutiter>::id;
  36. template<> locale::id num_get<wchar_t, _Winiter>::id;
  37. template<> locale::id num_put<wchar_t, _Woutiter>::id;
  38. template<> locale::id numpunct<wchar_t>::id;
  39. template<> locale::id collate<wchar_t>::id;
  40. template<> locale::id messages<wchar_t>::id;
  41. template<> locale::id money_get<wchar_t, _Winiter>::id;
  42. template<> locale::id money_put<wchar_t, _Woutiter>::id;
  43. template<> locale::id moneypunct<wchar_t, false>::id;
  44. template<> locale::id moneypunct<wchar_t, true>::id;
  45. template<> locale::id time_get<wchar_t, _Winiter>::id;
  46.  
  47. void __cdecl locale::_Locimp::_Makewloc(const _Locinfo& _Lobj,
  48.         locale::category _C, _Locimp *_Pi, const locale *_Pl)
  49.         {       // setup wide part of a new locale
  50.         _Lockit lk;
  51.         ADDFAC(_Tw1, _C, _Pi, _Pl);
  52.         ADDFAC(_Tw2, _C, _Pi, _Pl);
  53.         ADDFAC(_Tw3, _C, _Pi, _Pl);
  54.         ADDFAC(_Tw4, _C, _Pi, _Pl);
  55.         ADDFAC(_Tw5, _C, _Pi, _Pl);
  56.         ADDFAC(_Tw6, _C, _Pi, _Pl);
  57.         ADDFAC(_Tw7, _C, _Pi, _Pl);
  58.         ADDFAC(_Tw9, _C, _Pi, _Pl);
  59.         ADDFAC(_Tw11, _C, _Pi, _Pl);
  60.         ADDFAC(_Tw12, _C, _Pi, _Pl);
  61.         ADDFAC(_Tw13, _C, _Pi, _Pl);
  62.         ADDFAC(_Tw14, _C, _Pi, _Pl);
  63.         //...
  64.         ADDFAC(_Twc1, _C, _Pi, _Pl);
  65.         }
  66.  
  67. _STD_END
  68.  
  69. /*
  70.  * Copyright (c) 1995 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  71.  * Consult your license regarding permissions and restrictions.
  72.  */
  73.