Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.8 KiB

  1. // xlocinfo internal header
  2. #ifndef _XLOCINFO_
  3. #define _XLOCINFO_
  4. #include <xlocinfo.h>
  5. #include <cstdlib>
  6. #include <xstddef>
  7. #ifdef _MSC_VER
  8. #pragma pack(push,8)
  9. #endif /* _MSC_VER */
  10. _STD_BEGIN
  11. // CLASS _Timevec
  12. class _CRTIMP2 _Timevec {
  13. public:
  14. _Timevec(void *_P = 0)
  15. : _Ptr(_P) {}
  16. _Timevec(const _Timevec& _Rhs)
  17. {*this = _Rhs; }
  18. ~_Timevec()
  19. {free(_Ptr); }
  20. _Timevec& operator=(const _Timevec& _Rhs)
  21. {_Ptr = _Rhs._Ptr;
  22. ((_Timevec *)&_Rhs)->_Ptr = 0;
  23. return (*this); }
  24. void *_Getptr() const
  25. {return (_Ptr); }
  26. private:
  27. void *_Ptr;
  28. };
  29. // CLASS _Locinfo
  30. class _CRTIMP2 _Locinfo {
  31. public:
  32. typedef ::_Collvec _Collvec;
  33. typedef ::_Ctypevec _Ctypevec;
  34. typedef ::_Cvtvec _Cvtvec;
  35. typedef std::_Timevec _Timevec;
  36. _Locinfo(const char * = "C");
  37. _Locinfo(int, const char *);
  38. ~_Locinfo();
  39. _Locinfo& _Addcats(int, const char *);
  40. string _Getname() const
  41. {return (_Nname); }
  42. _Collvec _Getcoll() const
  43. {return (::_Getcoll()); }
  44. _Ctypevec _Getctype() const
  45. {return (::_Getctype()); }
  46. _Cvtvec _Getcvt() const
  47. {return (::_Getcvt()); }
  48. const lconv *_Getlconv() const
  49. {return (localeconv()); }
  50. _Timevec _Gettnames() const
  51. {return (_Timevec(::_Gettnames())); }
  52. const char *_Getdays() const
  53. {char *_S = ::_Getdays();
  54. if (_S != 0)
  55. {((_Locinfo *)this)->_Days = _S, free(_S); }
  56. return (_Days.size() != 0 ? _Days.c_str()
  57. : ":Sun:Sunday:Mon:Monday:Tue:Tuesday"
  58. ":Wed:Wednesday:Thu:Thursday:Fri:Friday"
  59. ":Sat:Saturday"); }
  60. const char *_Getmonths() const
  61. {char *_S = ::_Getmonths();
  62. if (_S != 0)
  63. {((_Locinfo *)this)->_Months = _S, free(_S); }
  64. return (_Months.size() != 0 ? _Months.c_str()
  65. : ":Jan:January:Feb:February:Mar:March"
  66. ":Apr:April:May:May:Jun:June"
  67. ":Jul:July:Aug:August:Sep:September"
  68. ":Oct:October:Nov:November:Dec:December"); }
  69. const char *_Getfalse() const
  70. {return ("false"); }
  71. const char *_Gettrue() const
  72. {return ("true"); }
  73. const char *_Getno() const
  74. {return ("no"); }
  75. const char *_Getyes() const
  76. {return ("yes"); }
  77. private:
  78. string _Days, _Months, _Oname, _Nname;
  79. };
  80. // TEMPLATE FUNCTIONS
  81. template<class _E> inline
  82. int __cdecl _Strcoll(const _E *_F1, const _E *_L1,
  83. const _E *_F2, const _E *_L2, const _Locinfo::_Collvec *)
  84. {for (; _F1 != _L1 && _F2 != _L2; ++_F1, ++_F2)
  85. if (*_F1 < *_F2)
  86. return (-1);
  87. else if (*_F2 < *_F1)
  88. return (+1);
  89. return (_F2 != _L2 ? -1 : _F1 != _L1 ? +1 : 0); }
  90. template<class _E> inline
  91. size_t __cdecl _Strxfrm(_E *_F1, _E *_L1,
  92. const _E *_F2, const _E *_L2, const _Locinfo::_Collvec *)
  93. {size_t _N = _L2 - _F2;
  94. if (_N <= _L1 - _F1)
  95. memcpy(_F1, _F2, _N * sizeof (_E));
  96. return (_N); }
  97. _STD_END
  98. #ifdef _MSC_VER
  99. #pragma pack(pop)
  100. #endif /* _MSC_VER */
  101. #endif /* _XLOCINFO_ */
  102. /*
  103. * Copyright (c) 1996 by P.J. Plauger. ALL RIGHTS RESERVED.
  104. * Consult your license regarding permissions and restrictions.
  105. */