build/stlport/src/facets_byname.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/build/stlport/src/facets_byname.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1057 @@
     1.4 +/*
     1.5 + * Copyright (c) 1999
     1.6 + * Silicon Graphics Computer Systems, Inc.
     1.7 + *
     1.8 + * Copyright (c) 1999
     1.9 + * Boris Fomitchev
    1.10 + *
    1.11 + * This material is provided "as is", with absolutely no warranty expressed
    1.12 + * or implied. Any use is at your own risk.
    1.13 + *
    1.14 + * Permission to use or copy this software for any purpose is hereby granted
    1.15 + * without fee, provided the above notices are retained on all copies.
    1.16 + * Permission to modify the code and to distribute modified code is granted,
    1.17 + * provided the above notices are retained, and a notice that the code was
    1.18 + * modified is included with the above copyright notice.
    1.19 + *
    1.20 + */
    1.21 +#include "stlport_prefix.h"
    1.22 +
    1.23 +#include <hash_map>
    1.24 +#include <vector>
    1.25 +
    1.26 +#include <locale>
    1.27 +#include <istream>
    1.28 +
    1.29 +#include <algorithm>
    1.30 +#include <functional>
    1.31 +
    1.32 +#include "c_locale.h"
    1.33 +#include "locale_impl.h"
    1.34 +#include "acquire_release.h"
    1.35 +
    1.36 +_STLP_BEGIN_NAMESPACE
    1.37 +
    1.38 +//----------------------------------------------------------------------
    1.39 +// ctype_byname<char>
    1.40 +
    1.41 +#if defined (__DMC__)
    1.42 +_STLP_DECLSPEC
    1.43 +#endif
    1.44 +ctype_byname<char>::ctype_byname(const char* name, size_t refs)
    1.45 +    : ctype<char>( 0, false, refs) {
    1.46 +  if (!name)
    1.47 +    locale::_M_throw_on_null_name();
    1.48 +
    1.49 +  int __err_code;
    1.50 +  char buf[_Locale_MAX_SIMPLE_NAME];
    1.51 +  _M_ctype = _STLP_PRIV __acquire_ctype(name, buf, 0, &__err_code);
    1.52 +  if (!_M_ctype)
    1.53 +    locale::_M_throw_on_creation_failure(__err_code, name, "ctype");
    1.54 +
    1.55 +  _M_init();
    1.56 +}
    1.57 +
    1.58 +void ctype_byname<char>::_M_init() {
    1.59 +  _M_ctype_table = _M_byname_table;
    1.60 +
    1.61 +  // We have to do this, instead of just pointer twiddling, because
    1.62 +  // ctype_base::mask isn't the same type as _Locale_mask_t.
    1.63 +  const _Locale_mask_t* p = _Locale_ctype_table(_M_ctype);
    1.64 +  for (size_t i = 0; i != table_size; ++i) {
    1.65 +    _M_byname_table[i] = ctype_base::mask(p[i]);
    1.66 +  }
    1.67 +}
    1.68 +
    1.69 +ctype_byname<char>::~ctype_byname()
    1.70 +{ _STLP_PRIV __release_ctype(_M_ctype); }
    1.71 +
    1.72 +char ctype_byname<char>::do_toupper(char c) const
    1.73 +{ return (char)_Locale_toupper(_M_ctype, c); }
    1.74 +
    1.75 +char ctype_byname<char>::do_tolower(char c) const
    1.76 +{ return (char)_Locale_tolower(_M_ctype, c); }
    1.77 +
    1.78 +const char*
    1.79 +ctype_byname<char>::do_toupper(char* first, const char* last) const {
    1.80 +  for ( ; first != last ; ++first)
    1.81 +    *first = (char)_Locale_toupper(_M_ctype, *first);
    1.82 +  return last;
    1.83 +}
    1.84 +
    1.85 +const char*
    1.86 +ctype_byname<char>::do_tolower(char* first, const char* last) const {
    1.87 +  for ( ; first != last ; ++first)
    1.88 +    *first = (char)_Locale_tolower(_M_ctype, *first);
    1.89 +  return last;
    1.90 +}
    1.91 +
    1.92 +
    1.93 +// Some helper functions used in ctype<>::scan_is and scan_is_not.
    1.94 +#if !defined (_STLP_NO_WCHAR_T)
    1.95 +
    1.96 +_STLP_MOVE_TO_PRIV_NAMESPACE
    1.97 +
    1.98 +// ctype_byname<wchar_t>
    1.99 +
   1.100 +struct _Ctype_byname_w_is_mask : public unary_function<wchar_t, bool> {
   1.101 +  _Locale_mask_t M;
   1.102 +  _Locale_ctype* M_ctp;
   1.103 +
   1.104 +  _Ctype_byname_w_is_mask(_Locale_mask_t m, _Locale_ctype* c)
   1.105 +    : M(m), M_ctp(c) {}
   1.106 +  bool operator()(wchar_t c) const
   1.107 +  { return _WLocale_ctype(M_ctp, c, M) != 0; }
   1.108 +};
   1.109 +
   1.110 +_STLP_MOVE_TO_STD_NAMESPACE
   1.111 +
   1.112 +#if defined (__DMC__)
   1.113 +_STLP_DECLSPEC
   1.114 +#endif
   1.115 +ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
   1.116 +  : ctype<wchar_t>(refs) {
   1.117 +  if (!name)
   1.118 +    locale::_M_throw_on_null_name();
   1.119 +
   1.120 +  int __err_code;
   1.121 +  char buf[_Locale_MAX_SIMPLE_NAME];
   1.122 +  _M_ctype = _STLP_PRIV __acquire_ctype(name, buf, 0, &__err_code);
   1.123 +  if (!_M_ctype)
   1.124 +    locale::_M_throw_on_creation_failure(__err_code, name, "ctype");
   1.125 +}
   1.126 +
   1.127 +ctype_byname<wchar_t>::~ctype_byname()
   1.128 +{ _STLP_PRIV __release_ctype(_M_ctype); }
   1.129 +
   1.130 +bool ctype_byname<wchar_t>::do_is(ctype_base::mask  m, wchar_t c) const
   1.131 +{ return _WLocale_ctype(_M_ctype, c, (_Locale_mask_t)m) != 0; }
   1.132 +
   1.133 +const wchar_t*
   1.134 +ctype_byname<wchar_t>::do_is(const wchar_t* low, const wchar_t* high,
   1.135 +                             ctype_base::mask * m) const {
   1.136 +  _Locale_mask_t all_bits = _Locale_mask_t(ctype_base::space |
   1.137 +                                           ctype_base::print |
   1.138 +                                           ctype_base::cntrl |
   1.139 +                                           ctype_base::upper |
   1.140 +                                           ctype_base::lower |
   1.141 +                                           ctype_base::alpha |
   1.142 +                                           ctype_base::digit |
   1.143 +                                           ctype_base::punct |
   1.144 +                                           ctype_base::xdigit);
   1.145 +
   1.146 +  for ( ; low < high; ++low, ++m)
   1.147 +    *m = ctype_base::mask (_WLocale_ctype(_M_ctype, *low, all_bits));
   1.148 +  return high;
   1.149 +}
   1.150 +
   1.151 +const wchar_t*
   1.152 +ctype_byname<wchar_t>
   1.153 +  ::do_scan_is(ctype_base::mask  m, const wchar_t* low, const wchar_t* high) const
   1.154 +{ return find_if(low, high, _STLP_PRIV _Ctype_byname_w_is_mask(m, _M_ctype)); }
   1.155 +
   1.156 +const wchar_t*
   1.157 +ctype_byname<wchar_t>
   1.158 +  ::do_scan_not(ctype_base::mask  m, const wchar_t* low, const wchar_t* high) const
   1.159 +{ return find_if(low, high, not1(_STLP_PRIV _Ctype_byname_w_is_mask(m, _M_ctype))); }
   1.160 +
   1.161 +wchar_t ctype_byname<wchar_t>::do_toupper(wchar_t c) const
   1.162 +{ return _WLocale_toupper(_M_ctype, c); }
   1.163 +
   1.164 +const wchar_t*
   1.165 +ctype_byname<wchar_t>::do_toupper(wchar_t* low, const wchar_t* high) const {
   1.166 +  for ( ; low < high; ++low)
   1.167 +    *low = _WLocale_toupper(_M_ctype, *low);
   1.168 +  return high;
   1.169 +}
   1.170 +
   1.171 +wchar_t ctype_byname<wchar_t>::do_tolower(wchar_t c) const
   1.172 +{ return _WLocale_tolower(_M_ctype, c); }
   1.173 +
   1.174 +const wchar_t*
   1.175 +ctype_byname<wchar_t>::do_tolower(wchar_t* low, const wchar_t* high) const {
   1.176 +  for ( ; low < high; ++low)
   1.177 +    *low = _WLocale_tolower(_M_ctype, *low);
   1.178 +  return high;
   1.179 +}
   1.180 +
   1.181 +#endif /* WCHAR_T */
   1.182 +
   1.183 +// collate_byname<char>
   1.184 +#if defined (__DMC__)
   1.185 +_STLP_DECLSPEC
   1.186 +#endif
   1.187 +collate_byname<char>::collate_byname(const char* name, size_t refs)
   1.188 +  : collate<char>(refs) {
   1.189 +  if (!name)
   1.190 +    locale::_M_throw_on_null_name();
   1.191 +
   1.192 +  int __err_code;
   1.193 +  char buf[_Locale_MAX_SIMPLE_NAME];
   1.194 +  _M_collate = _STLP_PRIV __acquire_collate(name, buf, 0, &__err_code);
   1.195 +  if (!_M_collate)
   1.196 +    locale::_M_throw_on_creation_failure(__err_code, name, "collate");
   1.197 +}
   1.198 +
   1.199 +collate_byname<char>::~collate_byname()
   1.200 +{ _STLP_PRIV __release_collate(_M_collate); }
   1.201 +
   1.202 +int collate_byname<char>::do_compare(const char* __low1,
   1.203 +                                     const char* __high1,
   1.204 +                                     const char* __low2,
   1.205 +                                     const char* __high2) const {
   1.206 +  return _Locale_strcmp(_M_collate,
   1.207 +                        __low1, __high1 - __low1,
   1.208 +                        __low2, __high2 - __low2);
   1.209 +}
   1.210 +
   1.211 +collate_byname<char>::string_type
   1.212 +collate_byname<char>::do_transform(const char* low, const char* high) const {
   1.213 +  if (low == high)
   1.214 +    return string_type();
   1.215 +
   1.216 +  size_t n = _Locale_strxfrm(_M_collate, NULL, 0, low, high - low);
   1.217 +
   1.218 +  // NOT PORTABLE.  What we're doing relies on internal details of the
   1.219 +  // string implementation.  (Contiguity of string elements and presence
   1.220 +  // of trailing zero.)
   1.221 +  string_type buf(n, 0);
   1.222 +  _Locale_strxfrm(_M_collate, &(*buf.begin()), n + 1, low, high - low);
   1.223 +  return buf;
   1.224 +}
   1.225 +
   1.226 +
   1.227 +#if !defined (_STLP_NO_WCHAR_T)
   1.228 +
   1.229 +// collate_byname<wchar_t>
   1.230 +
   1.231 +#if defined (__DMC__)
   1.232 +_STLP_DECLSPEC
   1.233 +#endif
   1.234 +collate_byname<wchar_t>::collate_byname(const char* name, size_t refs)
   1.235 +  : collate<wchar_t>(refs) {
   1.236 +  if (!name)
   1.237 +    locale::_M_throw_on_null_name();
   1.238 +
   1.239 +  int __err_code;
   1.240 +  char buf[_Locale_MAX_SIMPLE_NAME];
   1.241 +  _M_collate = _STLP_PRIV __acquire_collate(name, buf, 0, &__err_code);
   1.242 +  if (!_M_collate)
   1.243 +    locale::_M_throw_on_creation_failure(__err_code, name, "collate");
   1.244 +}
   1.245 +
   1.246 +collate_byname<wchar_t>::~collate_byname()
   1.247 +{ _STLP_PRIV __release_collate(_M_collate); }
   1.248 +
   1.249 +int collate_byname<wchar_t>::do_compare(const wchar_t* low1,
   1.250 +                                        const wchar_t* high1,
   1.251 +                                        const wchar_t* low2,
   1.252 +                                        const wchar_t* high2) const {
   1.253 +  return _WLocale_strcmp(_M_collate,
   1.254 +                         low1, high1 - low1,
   1.255 +                         low2, high2 - low2);
   1.256 +}
   1.257 +
   1.258 +collate_byname<wchar_t>::string_type
   1.259 +collate_byname<wchar_t>::do_transform(const wchar_t* low,
   1.260 +                                      const wchar_t* high) const {
   1.261 +  if (low == high)
   1.262 +    return string_type();
   1.263 +
   1.264 +  size_t n = _WLocale_strxfrm(_M_collate, NULL, 0, low, high - low);
   1.265 +
   1.266 +  // NOT PORTABLE.  What we're doing relies on internal details of the
   1.267 +  // string implementation.  (Contiguity of string elements and presence
   1.268 +  // of trailing zero.)
   1.269 +  string_type buf(n, 0);
   1.270 +  _WLocale_strxfrm(_M_collate, &(*buf.begin()), n + 1, low, high - low);
   1.271 +  return buf;
   1.272 +}
   1.273 +
   1.274 +#endif /*  _STLP_NO_WCHAR_T */
   1.275 +
   1.276 +//----------------------------------------------------------------------
   1.277 +// codecvt_byname<char>
   1.278 +
   1.279 +codecvt_byname<char, char, mbstate_t>
   1.280 +  ::codecvt_byname(const char* name, size_t refs)
   1.281 +    : codecvt<char, char, mbstate_t>(refs) {
   1.282 +  if (!name)
   1.283 +    locale::_M_throw_on_null_name();
   1.284 +}
   1.285 +
   1.286 +codecvt_byname<char, char, mbstate_t>::~codecvt_byname() {}
   1.287 +
   1.288 +
   1.289 +#if !defined (_STLP_NO_WCHAR_T)
   1.290 +
   1.291 +//----------------------------------------------------------------------
   1.292 +// codecvt_byname<wchar_t>
   1.293 +codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname(const char* name, size_t refs)
   1.294 +  : codecvt<wchar_t, char, mbstate_t>(refs) {
   1.295 +  if (!name)
   1.296 +    locale::_M_throw_on_null_name();
   1.297 +
   1.298 +  int __err_code;
   1.299 +  char buf[_Locale_MAX_SIMPLE_NAME];
   1.300 +  _M_codecvt = _STLP_PRIV __acquire_codecvt(name, buf, 0, &__err_code);
   1.301 +  if (!_M_codecvt)
   1.302 +    locale::_M_throw_on_creation_failure(__err_code, name, "ctype");
   1.303 +}
   1.304 +
   1.305 +codecvt_byname<wchar_t, char, mbstate_t>::~codecvt_byname()
   1.306 +{ _STLP_PRIV __release_codecvt(_M_codecvt); }
   1.307 +
   1.308 +codecvt<wchar_t, char, mbstate_t>::result
   1.309 +codecvt_byname<wchar_t, char, mbstate_t>::do_out(state_type&         state,
   1.310 +                                                 const intern_type*  from,
   1.311 +                                                 const intern_type*  from_end,
   1.312 +                                                 const intern_type*& from_next,
   1.313 +                                                 extern_type*        to,
   1.314 +                                                 extern_type*        to_limit,
   1.315 +                                                 extern_type*&       to_next) const {
   1.316 +  while (from != from_end && to != to_limit) {
   1.317 +    size_t chars_stored = _WLocale_wctomb(_M_codecvt,
   1.318 +                                          to, to_limit - to, *from,
   1.319 +                                          &state);
   1.320 +    if (chars_stored == (size_t) -1) {
   1.321 +      from_next = from;
   1.322 +      to_next   = to;
   1.323 +      return error;
   1.324 +    }
   1.325 +    else if (chars_stored == (size_t) -2) {
   1.326 +      from_next = from;
   1.327 +      to_next   = to;
   1.328 +      return partial;
   1.329 +    }
   1.330 +
   1.331 +    ++from;
   1.332 +    to += chars_stored;
   1.333 +  }
   1.334 +
   1.335 +  from_next = from;
   1.336 +  to_next   = to;
   1.337 +  return ok;
   1.338 +}
   1.339 +
   1.340 +codecvt<wchar_t, char, mbstate_t>::result
   1.341 +codecvt_byname<wchar_t, char, mbstate_t>::do_in(state_type&         state,
   1.342 +                                                const extern_type*  from,
   1.343 +                                                const extern_type*  from_end,
   1.344 +                                                const extern_type*& from_next,
   1.345 +                                                intern_type*        to,
   1.346 +                                                intern_type*        to_end,
   1.347 +                                                intern_type*&       to_next) const {
   1.348 +  while (from != from_end && to != to_end) {
   1.349 +    size_t chars_read = _WLocale_mbtowc(_M_codecvt,
   1.350 +                                        to, from, from_end - from,
   1.351 +                                        &state);
   1.352 +    if (chars_read == (size_t) -1) {
   1.353 +      from_next = from;
   1.354 +      to_next   = to;
   1.355 +      return error;
   1.356 +    }
   1.357 +
   1.358 +    if (chars_read == (size_t) -2) {
   1.359 +      from_next = from;
   1.360 +      to_next   = to;
   1.361 +      return partial;
   1.362 +    }
   1.363 +
   1.364 +    from += chars_read;
   1.365 +    to++;
   1.366 +  }
   1.367 +
   1.368 +  from_next = from;
   1.369 +  to_next   = to;
   1.370 +  return ok;
   1.371 +}
   1.372 +
   1.373 +codecvt<wchar_t, char, mbstate_t>::result
   1.374 +codecvt_byname<wchar_t, char, mbstate_t>::do_unshift(state_type&   state,
   1.375 +                                                     extern_type*  to,
   1.376 +                                                     extern_type*  to_limit,
   1.377 +                                                     extern_type*& to_next) const {
   1.378 +  to_next = to;
   1.379 +  size_t result = _WLocale_unshift(_M_codecvt, &state,
   1.380 +                                   to, to_limit - to, &to_next);
   1.381 +  if (result == (size_t) -1)
   1.382 +    return error;
   1.383 +  else if (result == (size_t) -2)
   1.384 +    return partial;
   1.385 +  else
   1.386 +#    if defined (__ISCPP__)
   1.387 +    return /*to_next == to ? noconv :*/ ok;
   1.388 +#    else
   1.389 +    return to_next == to ? noconv : ok;
   1.390 +#    endif
   1.391 +}
   1.392 +
   1.393 +int
   1.394 +codecvt_byname<wchar_t, char, mbstate_t>::do_encoding() const _STLP_NOTHROW {
   1.395 +  if (_WLocale_is_stateless(_M_codecvt)) {
   1.396 +    int max_width = _WLocale_mb_cur_max(_M_codecvt);
   1.397 +    int min_width = _WLocale_mb_cur_min(_M_codecvt);
   1.398 +    return min_width == max_width ? min_width : 0;
   1.399 +  }
   1.400 +  else
   1.401 +    return -1;
   1.402 +}
   1.403 +
   1.404 +bool
   1.405 +codecvt_byname<wchar_t, char, mbstate_t>::do_always_noconv() const _STLP_NOTHROW
   1.406 +{ return false; }
   1.407 +
   1.408 +int
   1.409 +codecvt_byname<wchar_t, char, mbstate_t>::do_length(state_type&         state,
   1.410 +                                                    const  extern_type* from,
   1.411 +                                                    const  extern_type* end,
   1.412 +                                                    size_t              mx) const {
   1.413 +  size_t __count = 0;
   1.414 +  while (from != end && mx--) {
   1.415 +    intern_type __dummy;
   1.416 +    size_t chars_read = _WLocale_mbtowc(_M_codecvt,
   1.417 +                                        &__dummy, from, end - from,
   1.418 +                                        &state);
   1.419 +    if ((chars_read == (size_t) -1) || (chars_read == (size_t) -2)) // error or partial
   1.420 +      break;
   1.421 +    __count += chars_read;
   1.422 +    from += chars_read;
   1.423 +  }
   1.424 +  return int(__count); 
   1.425 +}
   1.426 +
   1.427 +int
   1.428 +codecvt_byname<wchar_t, char, mbstate_t>::do_max_length() const _STLP_NOTHROW
   1.429 +{ return _WLocale_mb_cur_max(_M_codecvt); }
   1.430 +#endif
   1.431 +
   1.432 +// numpunct_byname<char>
   1.433 +numpunct_byname<char>::numpunct_byname(const char* name, size_t refs)
   1.434 +: numpunct<char>(refs) {
   1.435 +  if (!name)
   1.436 +    locale::_M_throw_on_null_name();
   1.437 +
   1.438 +  int __err_code;
   1.439 +  char buf[_Locale_MAX_SIMPLE_NAME];
   1.440 +  _M_numeric = _STLP_PRIV __acquire_numeric(name, buf, 0, &__err_code);
   1.441 +  if (!_M_numeric)
   1.442 +    locale::_M_throw_on_creation_failure(__err_code, name, "numpunct");
   1.443 +}
   1.444 +
   1.445 +numpunct_byname<char>::~numpunct_byname()
   1.446 +{ _STLP_PRIV __release_numeric(_M_numeric); }
   1.447 +
   1.448 +char numpunct_byname<char>::do_decimal_point() const
   1.449 +{ return _Locale_decimal_point(_M_numeric); }
   1.450 +
   1.451 +char numpunct_byname<char>::do_thousands_sep() const
   1.452 +{ return _Locale_thousands_sep(_M_numeric); }
   1.453 +
   1.454 +string numpunct_byname<char>::do_grouping() const {
   1.455 +  const char * __grouping = _Locale_grouping(_M_numeric);
   1.456 +  if (__grouping != NULL && __grouping[0] == CHAR_MAX)
   1.457 +    __grouping = "";
   1.458 +  return __grouping;
   1.459 +}
   1.460 +
   1.461 +string numpunct_byname<char>::do_truename() const
   1.462 +{ return _Locale_true(_M_numeric); }
   1.463 +
   1.464 +string numpunct_byname<char>::do_falsename() const
   1.465 +{ return _Locale_false(_M_numeric); }
   1.466 +
   1.467 +//----------------------------------------------------------------------
   1.468 +// numpunct<wchar_t>
   1.469 +
   1.470 +#if !defined (_STLP_NO_WCHAR_T)
   1.471 +
   1.472 +// numpunct_byname<wchar_t>
   1.473 +
   1.474 +numpunct_byname<wchar_t>::numpunct_byname(const char* name, size_t refs)
   1.475 +: numpunct<wchar_t>(refs) {
   1.476 +  if (!name)
   1.477 +    locale::_M_throw_on_null_name();
   1.478 +
   1.479 +  int __err_code;
   1.480 +  char buf[_Locale_MAX_SIMPLE_NAME];
   1.481 +  _M_numeric = _STLP_PRIV __acquire_numeric(name, buf, 0, &__err_code);
   1.482 +  if (!_M_numeric)
   1.483 +    locale::_M_throw_on_creation_failure(__err_code, name, "numpunct");
   1.484 +}
   1.485 +
   1.486 +numpunct_byname<wchar_t>::~numpunct_byname()
   1.487 +{ _STLP_PRIV __release_numeric(_M_numeric); }
   1.488 +
   1.489 +wchar_t numpunct_byname<wchar_t>::do_decimal_point() const
   1.490 +{ return _WLocale_decimal_point(_M_numeric); }
   1.491 +
   1.492 +wchar_t numpunct_byname<wchar_t>::do_thousands_sep() const
   1.493 +{ return _WLocale_thousands_sep(_M_numeric); }
   1.494 +
   1.495 +string numpunct_byname<wchar_t>::do_grouping() const {
   1.496 +  const char * __grouping = _Locale_grouping(_M_numeric);
   1.497 +  if (__grouping != NULL && __grouping[0] == CHAR_MAX)
   1.498 +    __grouping = "";
   1.499 +  return __grouping;
   1.500 +}
   1.501 +
   1.502 +wstring numpunct_byname<wchar_t>::do_truename() const {
   1.503 +  wchar_t buf[16];
   1.504 +  return _WLocale_true(_M_numeric, _STLP_ARRAY_AND_SIZE(buf));
   1.505 +}
   1.506 +
   1.507 +wstring numpunct_byname<wchar_t>::do_falsename() const {
   1.508 +  wchar_t buf[16];
   1.509 +  return _WLocale_false(_M_numeric, _STLP_ARRAY_AND_SIZE(buf));
   1.510 +}
   1.511 +
   1.512 +#endif
   1.513 +
   1.514 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.515 +
   1.516 +static void _Init_monetary_formats(money_base::pattern& pos_format,
   1.517 +                                   money_base::pattern& neg_format,
   1.518 +                                   _Locale_monetary * monetary) {
   1.519 +  switch (_Locale_p_sign_posn(monetary)) {
   1.520 +    case 0: // Parentheses surround the quantity and currency symbol
   1.521 +    case 1: // The sign string precedes the quantity and currency symbol
   1.522 +      pos_format.field[0] = (char) money_base::sign;
   1.523 +      if (_Locale_p_cs_precedes(monetary)) {
   1.524 +        // 1 if currency symbol precedes a positive value
   1.525 +        pos_format.field[1] = (char) money_base::symbol;
   1.526 +        if (_Locale_p_sep_by_space(monetary)) {
   1.527 +          // a space separates currency symbol from a positive value.
   1.528 +          pos_format.field[2] = (char) money_base::space;
   1.529 +          pos_format.field[3] = (char) money_base::value;
   1.530 +        } else {
   1.531 +          // a space not separates currency symbol from a positive value.
   1.532 +          pos_format.field[2] = (char) money_base::value;
   1.533 +          pos_format.field[3] = (char) money_base::none;
   1.534 +        }
   1.535 +      } else {
   1.536 +        // 0 if currency symbol succeeds a positive value
   1.537 +        pos_format.field[1] = (char) money_base::value;
   1.538 +        if (_Locale_p_sep_by_space(monetary)) {
   1.539 +          // a space separates currency symbol from a positive value.
   1.540 +          pos_format.field[2] = (char) money_base::space;
   1.541 +          pos_format.field[3] = (char) money_base::symbol;
   1.542 +        } else {
   1.543 +          // a space not separates currency symbol from a positive value.
   1.544 +          pos_format.field[2] = (char) money_base::symbol;
   1.545 +          pos_format.field[3] = (char) money_base::none;
   1.546 +        }
   1.547 +      }
   1.548 +      break;
   1.549 +    case 2: // The sign string succeeds the quantity and currency symbol.
   1.550 +      if (_Locale_p_cs_precedes(monetary)) {
   1.551 +        // 1 if currency symbol precedes a positive value
   1.552 +        pos_format.field[0] = (char) money_base::symbol;
   1.553 +        if (_Locale_p_sep_by_space(monetary)) {
   1.554 +          // a space separates currency symbol from a positive value.
   1.555 +          pos_format.field[1] = (char) money_base::space;
   1.556 +          pos_format.field[2] = (char) money_base::value;
   1.557 +          pos_format.field[3] = (char) money_base::sign;
   1.558 +        } else {
   1.559 +          // a space not separates currency symbol from a positive value.
   1.560 +          pos_format.field[1] = (char) money_base::value;
   1.561 +          pos_format.field[2] = (char) money_base::sign;
   1.562 +          pos_format.field[3] = (char) money_base::none;
   1.563 +        }
   1.564 +      } else {
   1.565 +        // 0 if currency symbol succeeds a positive value
   1.566 +        pos_format.field[0] = (char) money_base::value;
   1.567 +        if (_Locale_p_sep_by_space(monetary)) {
   1.568 +          // a space separates currency symbol from a positive value.
   1.569 +          pos_format.field[1] = (char) money_base::space;
   1.570 +          pos_format.field[2] = (char) money_base::symbol;
   1.571 +          pos_format.field[3] = (char) money_base::sign;
   1.572 +        } else {
   1.573 +          // a space not separates currency symbol from a positive value.
   1.574 +          pos_format.field[1] = (char) money_base::symbol;
   1.575 +          pos_format.field[2] = (char) money_base::sign;
   1.576 +          pos_format.field[3] = (char) money_base::none;
   1.577 +        }
   1.578 +      }
   1.579 +      break;
   1.580 +    case 3: // The sign string immediately precedes the currency symbol.
   1.581 +      if (_Locale_p_cs_precedes(monetary)) {
   1.582 +        // 1 if currency symbol precedes a positive value
   1.583 +        pos_format.field[0] = (char) money_base::sign;
   1.584 +        pos_format.field[1] = (char) money_base::symbol;
   1.585 +        if (_Locale_p_sep_by_space(monetary)) {
   1.586 +          // a space separates currency symbol from a positive value.
   1.587 +          pos_format.field[2] = (char) money_base::space;
   1.588 +          pos_format.field[3] = (char) money_base::value;
   1.589 +        } else {
   1.590 +          // a space not separates currency symbol from a positive value.
   1.591 +          pos_format.field[2] = (char) money_base::value;
   1.592 +          pos_format.field[3] = (char) money_base::none;
   1.593 +        }
   1.594 +      } else {
   1.595 +        // 0 if currency symbol succeeds a positive value
   1.596 +        pos_format.field[0] = (char) money_base::value;
   1.597 +        pos_format.field[1] = (char) money_base::sign;
   1.598 +        pos_format.field[2] = (char) money_base::symbol;
   1.599 +        pos_format.field[3] = (char) money_base::none;
   1.600 +      }
   1.601 +      break;
   1.602 +    case 4: // The sign string immediately succeeds the currency symbol.
   1.603 +      if (_Locale_p_cs_precedes(monetary)) {
   1.604 +        // 1 if currency symbol precedes a positive value
   1.605 +        pos_format.field[0] = (char) money_base::symbol;
   1.606 +        pos_format.field[1] = (char) money_base::sign;
   1.607 +        pos_format.field[2] = (char) money_base::value;
   1.608 +        pos_format.field[3] = (char) money_base::none;
   1.609 +      } else {
   1.610 +        // 0 if currency symbol succeeds a positive value
   1.611 +        pos_format.field[0] = (char) money_base::value;
   1.612 +        if (_Locale_p_sep_by_space(monetary)) {
   1.613 +          // a space separates currency symbol from a positive value.
   1.614 +          pos_format.field[1] = (char) money_base::space;
   1.615 +          pos_format.field[2] = (char) money_base::symbol;
   1.616 +          pos_format.field[3] = (char) money_base::sign;
   1.617 +        } else {
   1.618 +          // a space not separates currency symbol from a positive value.
   1.619 +          pos_format.field[1] = (char) money_base::symbol;
   1.620 +          pos_format.field[2] = (char) money_base::sign;
   1.621 +          pos_format.field[3] = (char) money_base::none;
   1.622 +        }
   1.623 +      }
   1.624 +      break;
   1.625 +    default: // Default C++ Standard format
   1.626 +      pos_format.field[0] = (char) money_base::symbol;
   1.627 +      pos_format.field[1] = (char) money_base::sign;
   1.628 +      pos_format.field[2] = (char) money_base::none;
   1.629 +      pos_format.field[3] = (char) money_base::value;
   1.630 +      break;
   1.631 +  }
   1.632 +
   1.633 +  switch (_Locale_n_sign_posn(monetary)) {
   1.634 +    case 0: // Parentheses surround the quantity and currency symbol
   1.635 +    case 1: // The sign string precedes the quantity and currency symbol
   1.636 +      neg_format.field[0] = (char) money_base::sign;
   1.637 +      if (_Locale_n_cs_precedes(monetary)) {
   1.638 +        // 1 if currency symbol precedes a negative value
   1.639 +        neg_format.field[1] = (char) money_base::symbol;
   1.640 +        if (_Locale_n_sep_by_space(monetary)) {
   1.641 +          // a space separates currency symbol from a negative value.
   1.642 +          neg_format.field[2] = (char) money_base::space;
   1.643 +          neg_format.field[3] = (char) money_base::value;
   1.644 +        } else {
   1.645 +          // a space not separates currency symbol from a negative value.
   1.646 +          neg_format.field[2] = (char) money_base::value;
   1.647 +          neg_format.field[3] = (char) money_base::none;
   1.648 +        }
   1.649 +      } else {
   1.650 +        // 0 if currency symbol succeeds a negative value
   1.651 +        neg_format.field[1] = (char) money_base::value;
   1.652 +        if (_Locale_n_sep_by_space(monetary)) {
   1.653 +          // a space separates currency symbol from a negative value.
   1.654 +          neg_format.field[2] = (char) money_base::space;
   1.655 +          neg_format.field[3] = (char) money_base::symbol;
   1.656 +        } else {
   1.657 +          // a space not separates currency symbol from a negative value.
   1.658 +          neg_format.field[2] = (char) money_base::symbol;
   1.659 +          neg_format.field[3] = (char) money_base::none;
   1.660 +        }
   1.661 +      }
   1.662 +      break;
   1.663 +    case 2: // The sign string succeeds the quantity and currency symbol.
   1.664 +      if (_Locale_n_cs_precedes(monetary)) {
   1.665 +        // 1 if currency symbol precedes a negative value
   1.666 +        neg_format.field[0] = (char) money_base::symbol;
   1.667 +        if (_Locale_n_sep_by_space(monetary)) {
   1.668 +          // a space separates currency symbol from a negative value.
   1.669 +          neg_format.field[1] = (char) money_base::space;
   1.670 +          neg_format.field[2] = (char) money_base::value;
   1.671 +          neg_format.field[3] = (char) money_base::sign;
   1.672 +        } else {
   1.673 +          // a space not separates currency symbol from a negative value.
   1.674 +          neg_format.field[1] = (char) money_base::value;
   1.675 +          neg_format.field[2] = (char) money_base::sign;
   1.676 +          neg_format.field[3] = (char) money_base::none;
   1.677 +        }
   1.678 +      } else {
   1.679 +        // 0 if currency symbol succeeds a negative value
   1.680 +        neg_format.field[0] = (char) money_base::value;
   1.681 +        if (_Locale_n_sep_by_space(monetary)) {
   1.682 +          // a space separates currency symbol from a negative value.
   1.683 +          neg_format.field[1] = (char) money_base::space;
   1.684 +          neg_format.field[2] = (char) money_base::symbol;
   1.685 +          neg_format.field[3] = (char) money_base::sign;
   1.686 +        } else {
   1.687 +          // a space not separates currency symbol from a negative value.
   1.688 +          neg_format.field[1] = (char) money_base::symbol;
   1.689 +          neg_format.field[2] = (char) money_base::sign;
   1.690 +          neg_format.field[3] = (char) money_base::none;
   1.691 +        }
   1.692 +      }
   1.693 +      break;
   1.694 +    case 3: // The sign string immediately precedes the currency symbol.
   1.695 +      if (_Locale_n_cs_precedes(monetary)) {
   1.696 +        // 1 if currency symbol precedes a negative value
   1.697 +        neg_format.field[0] = (char) money_base::sign;
   1.698 +        neg_format.field[1] = (char) money_base::symbol;
   1.699 +        if (_Locale_n_sep_by_space(monetary)) {
   1.700 +          // a space separates currency symbol from a negative value.
   1.701 +          neg_format.field[2] = (char) money_base::space;
   1.702 +          neg_format.field[3] = (char) money_base::value;
   1.703 +        } else {
   1.704 +          // a space not separates currency symbol from a negative value.
   1.705 +          neg_format.field[2] = (char) money_base::value;
   1.706 +          neg_format.field[3] = (char) money_base::none;
   1.707 +        }
   1.708 +      } else {
   1.709 +        // 0 if currency symbol succeeds a negative value
   1.710 +        neg_format.field[0] = (char) money_base::value;
   1.711 +        neg_format.field[1] = (char) money_base::sign;
   1.712 +        neg_format.field[2] = (char) money_base::symbol;
   1.713 +        neg_format.field[3] = (char) money_base::none;
   1.714 +      }
   1.715 +      break;
   1.716 +    case 4: // The sign string immediately succeeds the currency symbol.
   1.717 +      if (_Locale_n_cs_precedes(monetary)) {
   1.718 +        // 1 if currency symbol precedes a negative value
   1.719 +        neg_format.field[0] = (char) money_base::symbol;
   1.720 +        neg_format.field[1] = (char) money_base::sign;
   1.721 +        neg_format.field[2] = (char) money_base::none;
   1.722 +        neg_format.field[3] = (char) money_base::value;
   1.723 +      } else {
   1.724 +        // 0 if currency symbol succeeds a negative value
   1.725 +        neg_format.field[0] = (char) money_base::value;
   1.726 +        if (_Locale_n_sep_by_space(monetary)) {
   1.727 +          // a space separates currency symbol from a negative value.
   1.728 +          neg_format.field[1] = (char) money_base::space;
   1.729 +          neg_format.field[2] = (char) money_base::symbol;
   1.730 +          neg_format.field[3] = (char) money_base::sign;
   1.731 +        } else {
   1.732 +          // a space not separates currency symbol from a negative value.
   1.733 +          neg_format.field[1] = (char) money_base::symbol;
   1.734 +          neg_format.field[2] = (char) money_base::sign;
   1.735 +          neg_format.field[3] = (char) money_base::none;
   1.736 +        }
   1.737 +      }
   1.738 +      break;
   1.739 +    default: // Default C++ Standard format
   1.740 +      neg_format.field[0] = (char) money_base::symbol;
   1.741 +      neg_format.field[1] = (char) money_base::sign;
   1.742 +      neg_format.field[2] = (char) money_base::none;
   1.743 +      neg_format.field[3] = (char) money_base::value;
   1.744 +      break;
   1.745 +  }
   1.746 +}
   1.747 +
   1.748 +// international variant of monetary
   1.749 +
   1.750 +/*
   1.751 + * int_curr_symbol
   1.752 + *
   1.753 + *   The international currency symbol. The operand is a four-character
   1.754 + *   string, with the first three characters containing the alphabetic
   1.755 + *   international currency symbol in accordance with those specified
   1.756 + *   in the ISO 4217 specification. The fourth character is the character used
   1.757 + *   to separate the international currency symbol from the monetary quantity.
   1.758 + *
   1.759 + * (http://www.opengroup.org/onlinepubs/7990989775/xbd/locale.html)
   1.760 + */
   1.761 +
   1.762 +/*
   1.763 + * Standards are unclear in the usage of international currency
   1.764 + * and monetary formats.
   1.765 + * But I am expect that international currency symbol should be the first
   1.766 + * (not depends upon where currency symbol situated in the national
   1.767 + * format).
   1.768 + *
   1.769 + * If this isn't so, let's see:
   1.770 + *       1 234.56 RUR
   1.771 + *       GBP 1,234.56
   1.772 + *       USD 1,234.56
   1.773 + * The situation really is worse than you see above:
   1.774 + * RUR typed wrong here---it prints '1 234.56 RUR ' (see space after RUR).
   1.775 + * This is due to intl_fmp.curr_symbol() == "RUR ". (see reference in comments
   1.776 + * above).
   1.777 + *
   1.778 + */
   1.779 +
   1.780 +static void _Init_monetary_formats_int(money_base::pattern& pos_format,
   1.781 +                                       money_base::pattern& neg_format,
   1.782 +                                       _Locale_monetary * monetary)
   1.783 +{
   1.784 +
   1.785 +  switch (_Locale_p_sign_posn(monetary)) {
   1.786 +    case 0: // Parentheses surround the quantity and currency symbol
   1.787 +    case 1: // The sign string precedes the quantity and currency symbol
   1.788 +      pos_format.field[0] = (char) money_base::symbol;
   1.789 +      pos_format.field[1] = (char) money_base::sign;
   1.790 +      pos_format.field[2] = (char) money_base::value;
   1.791 +      pos_format.field[3] = (char) money_base::none;
   1.792 +      break;
   1.793 +    case 2: // The sign string succeeds the quantity and currency symbol.
   1.794 +      pos_format.field[0] = (char) money_base::symbol;
   1.795 +      pos_format.field[1] = (char) money_base::value;
   1.796 +      pos_format.field[2] = (char) money_base::sign;
   1.797 +      pos_format.field[3] = (char) money_base::none;
   1.798 +      break;
   1.799 +    case 3: // The sign string immediately precedes the currency symbol.
   1.800 +    case 4: // The sign string immediately succeeds the currency symbol.
   1.801 +      pos_format.field[0] = (char) money_base::symbol;
   1.802 +      if (_Locale_p_cs_precedes(monetary)) {
   1.803 +        // 1 if currency symbol precedes a positive value
   1.804 +        pos_format.field[1] = (char) money_base::sign;
   1.805 +        pos_format.field[2] = (char) money_base::value;
   1.806 +      } else {
   1.807 +        // 0 if currency symbol succeeds a positive value
   1.808 +        pos_format.field[1] = (char) money_base::value;
   1.809 +        pos_format.field[2] = (char) money_base::sign;
   1.810 +      }
   1.811 +      pos_format.field[3] = (char) money_base::none;
   1.812 +      break;
   1.813 +    default: // Default C++ Standard format
   1.814 +      pos_format.field[0] = (char) money_base::symbol;
   1.815 +      pos_format.field[1] = (char) money_base::sign;
   1.816 +      pos_format.field[2] = (char) money_base::none;
   1.817 +      pos_format.field[3] = (char) money_base::value;
   1.818 +      break;
   1.819 +  }
   1.820 +
   1.821 +
   1.822 +  switch (_Locale_n_sign_posn(monetary)) {
   1.823 +    case 0: // Parentheses surround the quantity and currency symbol
   1.824 +    case 1: // The sign string precedes the quantity and currency symbol
   1.825 +      neg_format.field[0] = (char) money_base::symbol;
   1.826 +      neg_format.field[1] = (char) money_base::sign;
   1.827 +      neg_format.field[2] = (char) money_base::value;
   1.828 +      neg_format.field[3] = (char) money_base::none;
   1.829 +      break;
   1.830 +    case 2: // The sign string succeeds the quantity and currency symbol.
   1.831 +      neg_format.field[0] = (char) money_base::symbol;
   1.832 +      neg_format.field[1] = (char) money_base::value;
   1.833 +      neg_format.field[2] = (char) money_base::sign;
   1.834 +      neg_format.field[3] = (char) money_base::none;
   1.835 +      break;
   1.836 +    case 3: // The sign string immediately precedes the currency symbol.
   1.837 +    case 4: // The sign string immediately succeeds the currency symbol.
   1.838 +      neg_format.field[0] = (char) money_base::symbol;
   1.839 +      if (_Locale_n_cs_precedes(monetary)) {
   1.840 +        // 1 if currency symbol precedes a negative value
   1.841 +        neg_format.field[1] = (char) money_base::sign;
   1.842 +        neg_format.field[2] = (char) money_base::value;
   1.843 +      } else {
   1.844 +        // 0 if currency symbol succeeds a negative value
   1.845 +        neg_format.field[1] = (char) money_base::value;
   1.846 +        neg_format.field[2] = (char) money_base::sign;
   1.847 +      }
   1.848 +      neg_format.field[3] = (char) money_base::none;
   1.849 +      break;
   1.850 +    default: // Default C++ Standard format
   1.851 +      neg_format.field[0] = (char) money_base::symbol;
   1.852 +      neg_format.field[1] = (char) money_base::sign;
   1.853 +      neg_format.field[2] = (char) money_base::none;
   1.854 +      neg_format.field[3] = (char) money_base::value;
   1.855 +      break;
   1.856 +  }
   1.857 +}
   1.858 +
   1.859 +_STLP_MOVE_TO_STD_NAMESPACE
   1.860 +
   1.861 +//
   1.862 +// moneypunct_byname<>
   1.863 +//
   1.864 +moneypunct_byname<char, true>::moneypunct_byname(const char * name,
   1.865 +                                                 size_t refs)
   1.866 +    : moneypunct<char, true>(refs) {
   1.867 +  if (!name)
   1.868 +    locale::_M_throw_on_null_name();
   1.869 +
   1.870 +  int __err_code;
   1.871 +  char buf[_Locale_MAX_SIMPLE_NAME];
   1.872 +  _M_monetary = _STLP_PRIV __acquire_monetary(name, buf, 0, &__err_code);
   1.873 +  if (!_M_monetary)
   1.874 +    locale::_M_throw_on_creation_failure(__err_code, name, "moneypunct");
   1.875 +
   1.876 +  _STLP_PRIV _Init_monetary_formats_int(_M_pos_format, _M_neg_format, _M_monetary);
   1.877 +}
   1.878 +
   1.879 +moneypunct_byname<char, true>::moneypunct_byname(_Locale_monetary *__mon)
   1.880 +  : _M_monetary(__mon) {
   1.881 +  _STLP_PRIV _Init_monetary_formats_int(_M_pos_format, _M_neg_format, _M_monetary);
   1.882 +}
   1.883 +
   1.884 +moneypunct_byname<char, true>::~moneypunct_byname()
   1.885 +{ _STLP_PRIV __release_monetary(_M_monetary); }
   1.886 +
   1.887 +char moneypunct_byname<char, true>::do_decimal_point() const
   1.888 +{ return _Locale_mon_decimal_point(_M_monetary); }
   1.889 +
   1.890 +char moneypunct_byname<char, true>::do_thousands_sep() const
   1.891 +{ return _Locale_mon_thousands_sep(_M_monetary); }
   1.892 +
   1.893 +string moneypunct_byname<char, true>::do_grouping() const
   1.894 +{ return _Locale_mon_grouping(_M_monetary); }
   1.895 +
   1.896 +string moneypunct_byname<char, true>::do_curr_symbol() const
   1.897 +{ return _Locale_int_curr_symbol(_M_monetary); }
   1.898 +
   1.899 +string moneypunct_byname<char, true>::do_positive_sign() const
   1.900 +{ return _Locale_positive_sign(_M_monetary); }
   1.901 +
   1.902 +string moneypunct_byname<char, true>::do_negative_sign() const
   1.903 +{ return _Locale_negative_sign(_M_monetary); }
   1.904 +
   1.905 +int moneypunct_byname<char, true>::do_frac_digits() const
   1.906 +{ return _Locale_int_frac_digits(_M_monetary); }
   1.907 +
   1.908 +moneypunct_byname<char, false>::moneypunct_byname(const char * name,
   1.909 +                                                  size_t refs)
   1.910 +    : moneypunct<char, false>(refs) {
   1.911 +  if (!name)
   1.912 +    locale::_M_throw_on_null_name();
   1.913 +
   1.914 +  int __err_code;
   1.915 +  char buf[_Locale_MAX_SIMPLE_NAME];
   1.916 +  _M_monetary = _STLP_PRIV __acquire_monetary(name, buf, 0, &__err_code);
   1.917 +  if (!_M_monetary)
   1.918 +    locale::_M_throw_on_creation_failure(__err_code, name, "moneypunct");
   1.919 +
   1.920 +  _STLP_PRIV _Init_monetary_formats(_M_pos_format, _M_neg_format, _M_monetary);
   1.921 +}
   1.922 +
   1.923 +moneypunct_byname<char, false>::moneypunct_byname(_Locale_monetary *__mon)
   1.924 +  : _M_monetary(__mon) {
   1.925 +  _STLP_PRIV _Init_monetary_formats(_M_pos_format, _M_neg_format, _M_monetary);
   1.926 +}
   1.927 +
   1.928 +moneypunct_byname<char, false>::~moneypunct_byname()
   1.929 +{ _STLP_PRIV __release_monetary(_M_monetary); }
   1.930 +
   1.931 +char moneypunct_byname<char, false>::do_decimal_point() const
   1.932 +{ return _Locale_mon_decimal_point(_M_monetary); }
   1.933 +
   1.934 +char moneypunct_byname<char, false>::do_thousands_sep() const
   1.935 +{ return _Locale_mon_thousands_sep(_M_monetary); }
   1.936 +
   1.937 +string moneypunct_byname<char, false>::do_grouping() const
   1.938 +{ return _Locale_mon_grouping(_M_monetary); }
   1.939 +
   1.940 +string moneypunct_byname<char, false>::do_curr_symbol() const
   1.941 +{ return _Locale_currency_symbol(_M_monetary); }
   1.942 +
   1.943 +string moneypunct_byname<char, false>::do_positive_sign() const
   1.944 +{ return _Locale_positive_sign(_M_monetary); }
   1.945 +
   1.946 +string moneypunct_byname<char, false>::do_negative_sign() const
   1.947 +{ return _Locale_negative_sign(_M_monetary); }
   1.948 +
   1.949 +int moneypunct_byname<char, false>::do_frac_digits() const
   1.950 +{ return _Locale_frac_digits(_M_monetary); }
   1.951 +
   1.952 +//
   1.953 +// moneypunct_byname<wchar_t>
   1.954 +//
   1.955 +#if !defined (_STLP_NO_WCHAR_T)
   1.956 +
   1.957 +moneypunct_byname<wchar_t, true>::moneypunct_byname(const char * name,
   1.958 +                                                    size_t refs)
   1.959 +    : moneypunct<wchar_t, true>(refs) {
   1.960 +  if (!name)
   1.961 +    locale::_M_throw_on_null_name();
   1.962 +
   1.963 +  int __err_code;
   1.964 +  char buf[_Locale_MAX_SIMPLE_NAME];
   1.965 +  _M_monetary = _STLP_PRIV __acquire_monetary(name, buf, 0, &__err_code);
   1.966 +  if (!_M_monetary)
   1.967 +    locale::_M_throw_on_creation_failure(__err_code, name, "moneypunct");
   1.968 +
   1.969 +  _STLP_PRIV _Init_monetary_formats_int(_M_pos_format, _M_neg_format, _M_monetary);
   1.970 +}
   1.971 +
   1.972 +moneypunct_byname<wchar_t, true>::moneypunct_byname(_Locale_monetary *__mon)
   1.973 +  : _M_monetary(__mon) {
   1.974 +  _STLP_PRIV _Init_monetary_formats_int(_M_pos_format, _M_neg_format, _M_monetary);
   1.975 +}
   1.976 +
   1.977 +moneypunct_byname<wchar_t, true>::~moneypunct_byname()
   1.978 +{ _STLP_PRIV __release_monetary(_M_monetary); }
   1.979 +
   1.980 +wchar_t moneypunct_byname<wchar_t, true>::do_decimal_point() const
   1.981 +{ return _Locale_mon_decimal_point(_M_monetary); }
   1.982 +
   1.983 +wchar_t moneypunct_byname<wchar_t, true>::do_thousands_sep() const
   1.984 +{ return _Locale_mon_thousands_sep(_M_monetary); }
   1.985 +
   1.986 +string moneypunct_byname<wchar_t, true>::do_grouping() const
   1.987 +{ return _Locale_mon_grouping(_M_monetary); }
   1.988 +
   1.989 +inline wstring __do_widen (string const& str) {
   1.990 +#if defined (_STLP_NO_MEMBER_TEMPLATES) || defined (_STLP_MSVC)
   1.991 +  wstring::_Reserve_t __Reserve;
   1.992 +  size_t __size = str.size();
   1.993 +  wstring result(__Reserve, __size);
   1.994 +  copy(str.begin(), str.end(), result.begin());
   1.995 +#else
   1.996 +  wstring result(str.begin(), str.end());
   1.997 +#endif
   1.998 +  return result;
   1.999 +}
  1.1000 +
  1.1001 +wstring moneypunct_byname<wchar_t, true>::do_curr_symbol() const
  1.1002 +{ wchar_t buf[16]; return _WLocale_int_curr_symbol(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); }
  1.1003 +
  1.1004 +wstring moneypunct_byname<wchar_t, true>::do_positive_sign() const
  1.1005 +{ wchar_t buf[16]; return _WLocale_positive_sign(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); }
  1.1006 +
  1.1007 +wstring moneypunct_byname<wchar_t, true>::do_negative_sign() const
  1.1008 +{ wchar_t buf[16]; return _WLocale_negative_sign(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); }
  1.1009 +
  1.1010 +int moneypunct_byname<wchar_t, true>::do_frac_digits() const
  1.1011 +{ return _Locale_int_frac_digits(_M_monetary); }
  1.1012 +
  1.1013 +moneypunct_byname<wchar_t, false>::moneypunct_byname(const char * name,
  1.1014 +                                                     size_t refs)
  1.1015 +    : moneypunct<wchar_t, false>(refs) {
  1.1016 +  if (!name)
  1.1017 +    locale::_M_throw_on_null_name() ;
  1.1018 +
  1.1019 +  int __err_code;
  1.1020 +  char buf[_Locale_MAX_SIMPLE_NAME];
  1.1021 +  _M_monetary = _STLP_PRIV __acquire_monetary(name, buf, 0, &__err_code);
  1.1022 +  if (!_M_monetary)
  1.1023 +    locale::_M_throw_on_creation_failure(__err_code, name, "moneypunct");
  1.1024 +
  1.1025 +  _STLP_PRIV _Init_monetary_formats(_M_pos_format, _M_neg_format, _M_monetary);
  1.1026 +}
  1.1027 +
  1.1028 +moneypunct_byname<wchar_t, false>::moneypunct_byname(_Locale_monetary *__mon)
  1.1029 +  : _M_monetary(__mon) {
  1.1030 +  _STLP_PRIV _Init_monetary_formats(_M_pos_format, _M_neg_format, _M_monetary);
  1.1031 +}
  1.1032 +
  1.1033 +moneypunct_byname<wchar_t, false>::~moneypunct_byname()
  1.1034 +{ _STLP_PRIV __release_monetary(_M_monetary); }
  1.1035 +
  1.1036 +wchar_t moneypunct_byname<wchar_t, false>::do_decimal_point() const
  1.1037 +{ return _Locale_mon_decimal_point(_M_monetary); }
  1.1038 +
  1.1039 +wchar_t moneypunct_byname<wchar_t, false>::do_thousands_sep() const
  1.1040 +{ return _Locale_mon_thousands_sep(_M_monetary); }
  1.1041 +
  1.1042 +string moneypunct_byname<wchar_t, false>::do_grouping() const
  1.1043 +{ return _Locale_mon_grouping(_M_monetary); }
  1.1044 +
  1.1045 +wstring moneypunct_byname<wchar_t, false>::do_curr_symbol() const
  1.1046 +{ wchar_t buf[16]; return _WLocale_currency_symbol(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); }
  1.1047 +
  1.1048 +wstring moneypunct_byname<wchar_t, false>::do_positive_sign() const
  1.1049 +{ wchar_t buf[16]; return _WLocale_positive_sign(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); }
  1.1050 +
  1.1051 +wstring moneypunct_byname<wchar_t, false>::do_negative_sign() const
  1.1052 +{ wchar_t buf[16]; return _WLocale_negative_sign(_M_monetary, _STLP_ARRAY_AND_SIZE(buf)); }
  1.1053 +
  1.1054 +int moneypunct_byname<wchar_t, false>::do_frac_digits() const
  1.1055 +{ return _Locale_frac_digits(_M_monetary); }
  1.1056 +
  1.1057 +#endif
  1.1058 +
  1.1059 +_STLP_END_NAMESPACE
  1.1060 +

mercurial