monetary.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * Copyright (c) 1999
  3. * Silicon Graphics Computer Systems, Inc.
  4. *
  5. * Copyright (c) 1999
  6. * Boris Fomitchev
  7. *
  8. * This material is provided "as is", with absolutely no warranty expressed
  9. * or implied. Any use is at your own risk.
  10. *
  11. * Permission to use or copy this software for any purpose is hereby granted
  12. * without fee, provided the above notices are retained on all copies.
  13. * Permission to modify the code and to distribute modified code is granted,
  14. * provided the above notices are retained, and a notice that the code was
  15. * modified is included with the above copyright notice.
  16. *
  17. */
  18. #include "stlport_prefix.h"
  19. #include <locale>
  20. #include <istream>
  21. _STLP_BEGIN_NAMESPACE
  22. static void _Init_monetary_formats(money_base::pattern& pos_format,
  23. money_base::pattern& neg_format) {
  24. pos_format.field[0] = (char) money_base::symbol;
  25. pos_format.field[1] = (char) money_base::sign;
  26. pos_format.field[2] = (char) money_base::none;
  27. pos_format.field[3] = (char) money_base::value;
  28. neg_format.field[0] = (char) money_base::symbol;
  29. neg_format.field[1] = (char) money_base::sign;
  30. neg_format.field[2] = (char) money_base::none;
  31. neg_format.field[3] = (char) money_base::value;
  32. }
  33. // This is being used throughout the library
  34. static const string _S_empty_string;
  35. #ifndef _STLP_NO_WCHAR_T
  36. static const wstring _S_empty_wstring;
  37. #endif
  38. //
  39. // moneypunct<>
  40. //
  41. moneypunct<char, true>::moneypunct(size_t __refs) : locale::facet(__refs)
  42. { _Init_monetary_formats(_M_pos_format, _M_neg_format); }
  43. moneypunct<char, true>::~moneypunct() {}
  44. char moneypunct<char, true>::do_decimal_point() const {return ' ';}
  45. char moneypunct<char, true>::do_thousands_sep() const {return ' ';}
  46. string moneypunct<char, true>::do_grouping() const { return _S_empty_string; }
  47. string moneypunct<char, true>::do_curr_symbol() const { return _S_empty_string; }
  48. string moneypunct<char, true>::do_positive_sign() const { return _S_empty_string; }
  49. string moneypunct<char, true>::do_negative_sign() const { return _S_empty_string; }
  50. money_base::pattern moneypunct<char, true>::do_pos_format() const {return _M_pos_format;}
  51. money_base::pattern moneypunct<char, true>::do_neg_format() const {return _M_neg_format;}
  52. int moneypunct<char, true>::do_frac_digits() const {return 0;}
  53. moneypunct<char, false>::moneypunct(size_t __refs) : locale::facet(__refs)
  54. { _Init_monetary_formats(_M_pos_format, _M_neg_format); }
  55. moneypunct<char, false>::~moneypunct() {}
  56. char moneypunct<char, false>::do_decimal_point() const {return ' ';}
  57. char moneypunct<char, false>::do_thousands_sep() const {return ' ';}
  58. string moneypunct<char, false>::do_grouping() const { return _S_empty_string; }
  59. string moneypunct<char, false>::do_curr_symbol() const { return _S_empty_string; }
  60. string moneypunct<char, false>::do_positive_sign() const { return _S_empty_string; }
  61. string moneypunct<char, false>::do_negative_sign() const { return _S_empty_string; }
  62. money_base::pattern moneypunct<char, false>::do_pos_format() const {return _M_pos_format;}
  63. money_base::pattern moneypunct<char, false>::do_neg_format() const {return _M_neg_format;}
  64. int moneypunct<char, false>::do_frac_digits() const {return 0;}
  65. #ifndef _STLP_NO_WCHAR_T
  66. moneypunct<wchar_t, true>::moneypunct(size_t __refs) : locale::facet(__refs)
  67. { _Init_monetary_formats(_M_pos_format, _M_neg_format); }
  68. moneypunct<wchar_t, true>::~moneypunct() {}
  69. wchar_t moneypunct<wchar_t, true>::do_decimal_point() const {return L' ';}
  70. wchar_t moneypunct<wchar_t, true>::do_thousands_sep() const {return L' ';}
  71. string moneypunct<wchar_t, true>::do_grouping() const {return _S_empty_string;}
  72. wstring moneypunct<wchar_t, true>::do_curr_symbol() const
  73. {return _S_empty_wstring;}
  74. wstring moneypunct<wchar_t, true>::do_positive_sign() const
  75. {return _S_empty_wstring;}
  76. wstring moneypunct<wchar_t, true>::do_negative_sign() const
  77. {return _S_empty_wstring;}
  78. int moneypunct<wchar_t, true>::do_frac_digits() const {return 0;}
  79. money_base::pattern moneypunct<wchar_t, true>::do_pos_format() const
  80. {return _M_pos_format;}
  81. money_base::pattern moneypunct<wchar_t, true>::do_neg_format() const
  82. {return _M_neg_format;}
  83. moneypunct<wchar_t, false>::moneypunct(size_t __refs) : locale::facet(__refs)
  84. { _Init_monetary_formats(_M_pos_format, _M_neg_format); }
  85. moneypunct<wchar_t, false>::~moneypunct() {}
  86. wchar_t moneypunct<wchar_t, false>::do_decimal_point() const {return L' ';}
  87. wchar_t moneypunct<wchar_t, false>::do_thousands_sep() const {return L' ';}
  88. string moneypunct<wchar_t, false>::do_grouping() const { return _S_empty_string;}
  89. wstring moneypunct<wchar_t, false>::do_curr_symbol() const
  90. {return _S_empty_wstring;}
  91. wstring moneypunct<wchar_t, false>::do_positive_sign() const
  92. {return _S_empty_wstring;}
  93. wstring moneypunct<wchar_t, false>::do_negative_sign() const
  94. {return _S_empty_wstring;}
  95. int moneypunct<wchar_t, false>::do_frac_digits() const {return 0;}
  96. money_base::pattern moneypunct<wchar_t, false>::do_pos_format() const
  97. {return _M_pos_format;}
  98. money_base::pattern moneypunct<wchar_t, false>::do_neg_format() const
  99. {return _M_neg_format;}
  100. #endif /* WCHAR_T */
  101. //
  102. // Instantiations
  103. //
  104. #if !defined (_STLP_NO_FORCE_INSTANTIATE)
  105. template class _STLP_CLASS_DECLSPEC money_get<char, istreambuf_iterator<char, char_traits<char> > >;
  106. template class _STLP_CLASS_DECLSPEC money_put<char, ostreambuf_iterator<char, char_traits<char> > >;
  107. // template class money_put<char, char*>;
  108. # ifndef _STLP_NO_WCHAR_T
  109. template class _STLP_CLASS_DECLSPEC money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
  110. template class _STLP_CLASS_DECLSPEC money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >;
  111. // template class money_put<wchar_t, wchar_t*>;
  112. // template class money_get<wchar_t, const wchar_t*>;
  113. # endif
  114. #endif
  115. #if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION)
  116. const bool moneypunct<char, true>::intl;
  117. const bool moneypunct<char, false>::intl;
  118. # ifndef _STLP_NO_WCHAR_T
  119. const bool moneypunct<wchar_t, true>::intl;
  120. const bool moneypunct<wchar_t, false>::intl;
  121. # endif
  122. #endif
  123. _STLP_END_NAMESPACE
  124. // Local Variables:
  125. // mode:C++
  126. // End: