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

  1. // xlocale -- class locale exotic char member functions
  2. #include <istream>
  3. #include <locale>
  4. _STD_BEGIN
  5.  
  6. typedef char_traits<char> _Traits;
  7. typedef istreambuf_iterator<char, _Traits> _Initer;
  8. typedef ostreambuf_iterator<char, _Traits> _Outiter;
  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 collate<char> _T5;
  20. typedef messages<char> _T6;
  21. typedef money_get<char, _Initer> _T7;
  22. typedef money_put<char, _Outiter> _T9;
  23. typedef moneypunct<char, false> _T11;
  24. typedef moneypunct<char, true> _T12;
  25. typedef time_get<char, _Initer> _T13;
  26. typedef time_put<char, _Outiter> _T14;
  27.  
  28. template<> locale::id collate<char>::id;
  29. template<> locale::id messages<char>::id;
  30. template<> locale::id money_get<char, _Initer>::id;
  31. template<> locale::id money_put<char, _Outiter>::id;
  32. template<> locale::id moneypunct<char, false>::id;
  33. template<> locale::id moneypunct<char, true>::id;
  34. template<> locale::id time_get<char, _Initer>::id;
  35. template<> locale::id time_put<char, _Outiter>::id;
  36.  
  37. void __cdecl locale::_Locimp::_Makexloc(const _Locinfo& _Lobj,
  38.         locale::category _C, _Locimp *_Pi, const locale *_Pl)
  39.         {       // setup exotic char part of a new locale
  40.         _Lockit _Lk;
  41.         ADDFAC(_T5, _C, _Pi, _Pl);
  42.         ADDFAC(_T6, _C, _Pi, _Pl);
  43.         ADDFAC(_T7, _C, _Pi, _Pl);
  44.         ADDFAC(_T9, _C, _Pi, _Pl);
  45.         ADDFAC(_T11, _C, _Pi, _Pl);
  46.         ADDFAC(_T12, _C, _Pi, _Pl);
  47.         ADDFAC(_T13, _C, _Pi, _Pl);
  48.         ADDFAC(_T14, _C, _Pi, _Pl);
  49.         }
  50.  
  51. _STD_END
  52.  
  53. /*
  54.  * Copyright (c) 1995 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  55.  * Consult your license regarding permissions and restrictions.
  56.  */
  57.