コード例 #1
0
// Create a locale from a name.
locale::locale(const char* name)
  : _M_impl(0) {
  if (!name)
    _M_throw_runtime_error(0);

  if (is_C_locale_name(name)) {
    _M_impl = _get_Locale_impl( locale::classic()._M_impl );
    return;
  }

  _Locale_impl* impl = 0;
  _STLP_TRY {
    impl = new _Locale_impl(locale::id::_S_max, name);

    // Insert categories one at a time.
    impl->insert_ctype_facets(name);
    impl->insert_numeric_facets(name);
    impl->insert_time_facets(name);
    impl->insert_collate_facets(name);
    impl->insert_monetary_facets(name);
    impl->insert_messages_facets(name);
    // reassign impl
    _M_impl = _get_Locale_impl( impl );
  }
  _STLP_UNWIND(delete impl);
}
コード例 #2
0
ファイル: locale.cpp プロジェクト: 0-T-0/linux-sgx
// Create a locale from a name.
locale::locale(const char* name)
  : _M_impl(0) {
  if (!name)
    _M_throw_on_null_name();

  if (is_C_locale_name(name)) {
    _M_impl = _get_Locale_impl( locale::classic()._M_impl );
    return;
  }

  _Locale_impl* impl = 0;
  _STLP_TRY {
    impl = new _Locale_impl(locale::id::_S_max, name);

    // Insert categories one at a time.
    _Locale_name_hint *hint = 0;
    const char* ctype_name = name;
    char ctype_buf[_Locale_MAX_SIMPLE_NAME];
    const char* numeric_name = name;
    char numeric_buf[_Locale_MAX_SIMPLE_NAME];
    const char* time_name = name;
    char time_buf[_Locale_MAX_SIMPLE_NAME];
    const char* collate_name = name;
    char collate_buf[_Locale_MAX_SIMPLE_NAME];
    const char* monetary_name = name;
    char monetary_buf[_Locale_MAX_SIMPLE_NAME];
    const char* messages_name = name;
    char messages_buf[_Locale_MAX_SIMPLE_NAME];
    hint = impl->insert_ctype_facets(ctype_name, ctype_buf, hint);
    hint = impl->insert_numeric_facets(numeric_name, numeric_buf, hint);
    hint = impl->insert_time_facets(time_name, time_buf, hint);
    hint = impl->insert_collate_facets(collate_name, collate_buf, hint);
    hint = impl->insert_monetary_facets(monetary_name, monetary_buf, hint);
    impl->insert_messages_facets(messages_name, messages_buf, hint);

    // Try to use a normalize locale name in order to have the == operator
    // to behave correctly:
    if (strcmp(ctype_name, numeric_name) == 0 &&
        strcmp(ctype_name, time_name) == 0 &&
        strcmp(ctype_name, collate_name) == 0 &&
        strcmp(ctype_name, monetary_name) == 0 &&
        strcmp(ctype_name, messages_name) == 0) {
      impl->name = ctype_name;
    }
    // else we keep current name.

    // reassign impl
    _M_impl = _get_Locale_impl( impl );
  }
  _STLP_UNWIND(delete impl);
}
コード例 #3
0
// Create a locale that's a copy of L, except that all of the facets
// in category c are instead constructed by name.
locale::locale(const locale& L, const char* name, locale::category c)
  : _M_impl(0) {
  if (name == 0 || (_Nameless == name))
    _M_throw_runtime_error(name);

  _Locale_impl* impl = 0;

  _STLP_TRY {
    impl = new _Locale_impl(*L._M_impl);
    _Stl_loc_combine_names(impl, L._M_impl->name.c_str(), name, c);

    if (c & locale::ctype)
      impl->insert_ctype_facets(name);
    if (c & locale::numeric)
      impl->insert_numeric_facets(name);
    if (c & locale::time)
      impl->insert_time_facets(name);
    if (c & locale::collate)
      impl->insert_collate_facets(name);
    if (c & locale::monetary)
      impl->insert_monetary_facets(name);
    if (c & locale::messages)
      impl->insert_messages_facets(name);
    _M_impl = _get_Locale_impl( impl );
  }
  _STLP_UNWIND(delete impl)
}
コード例 #4
0
locale _STLP_CALL locale::global(const locale& L) {
  locale old(_Stl_get_global_locale()->_M_impl);
  if (_Stl_get_global_locale()->_M_impl != L._M_impl) {
    _release_Locale_impl(_Stl_get_global_locale()->_M_impl);
    // this assign should be atomic, should be fixed here:
    _Stl_get_global_locale()->_M_impl = _get_Locale_impl(L._M_impl);

    // Set the global C locale, if appropriate.
#if !defined(_STLP_NO_LOCALE_SUPPORT) && !defined(_STLP_WINCE) && !defined(_STLP_WCE_NET)
    if (L.name() != _Nameless)
      setlocale(LC_ALL, L.name().c_str());
#endif
  }

  return old;
}
コード例 #5
0
ファイル: locale.cpp プロジェクト: 0-T-0/linux-sgx
// Create a locale that's a copy of L, except that all of the facets
// in category c are instead constructed by name.
locale::locale(const locale& L, const char* name, locale::category c)
  : _M_impl(0) {
  if (!name)
    _M_throw_on_null_name();

  if (_Nameless == name)
    _STLP_THROW(runtime_error((string("Invalid locale name '") + _Nameless + "'").c_str()));

  _Locale_impl* impl = 0;

  _STLP_TRY {
    impl = new _Locale_impl(*L._M_impl);

    _Locale_name_hint *hint = 0;
    const char* ctype_name = name;
    char ctype_buf[_Locale_MAX_SIMPLE_NAME];
    const char* numeric_name = name;
    char numeric_buf[_Locale_MAX_SIMPLE_NAME];
    const char* time_name = name;
    char time_buf[_Locale_MAX_SIMPLE_NAME];
    const char* collate_name = name;
    char collate_buf[_Locale_MAX_SIMPLE_NAME];
    const char* monetary_name = name;
    char monetary_buf[_Locale_MAX_SIMPLE_NAME];
    const char* messages_name = name;
    char messages_buf[_Locale_MAX_SIMPLE_NAME];
    if (c & locale::ctype)
      hint = impl->insert_ctype_facets(ctype_name, ctype_buf, hint);
    if (c & locale::numeric)
      hint = impl->insert_numeric_facets(numeric_name, numeric_buf, hint);
    if (c & locale::time)
      hint = impl->insert_time_facets(time_name, time_buf, hint);
    if (c & locale::collate)
      hint = impl->insert_collate_facets(collate_name, collate_buf, hint);
    if (c & locale::monetary)
      hint = impl->insert_monetary_facets(monetary_name, monetary_buf,hint);
    if (c & locale::messages)
      impl->insert_messages_facets(messages_name, messages_buf, hint);

    _Stl_loc_combine_names(impl, L._M_impl->name.c_str(),
                           ctype_name, time_name, numeric_name,
                           collate_name, monetary_name, messages_name, c);
    _M_impl = _get_Locale_impl( impl );
  }
  _STLP_UNWIND(delete impl)
}
コード例 #6
0
ファイル: locale.cpp プロジェクト: ChunHungLiu/stlport
_Locale_impl* _STLP_CALL locale::global(const locale& L) {
#endif
  locale old(_Stl_get_global_locale()->_M_impl);
  if (_Stl_get_global_locale()->_M_impl != L._M_impl) {
    _release_Locale_impl(_Stl_get_global_locale()->_M_impl);
    // this assign should be atomic, should be fixed here:
    _Stl_get_global_locale()->_M_impl = _get_Locale_impl(L._M_impl);

    // Set the global C locale, if appropriate.
#if !defined(_STLP_NO_LOCALE_SUPPORT)
    if (L.name() != _Nameless)
      setlocale(LC_ALL, L.name().c_str());
#endif
  }

#if !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
  return old;
#else
  return old._M_impl;
#endif
}
コード例 #7
0
ファイル: locale.cpp プロジェクト: ChunHungLiu/stlport
// Contruct a new locale where all facets that aren't in category c
// come from L1, and all those that are in category c come from L2.
locale::locale(const locale& L1, const locale& L2, category c)
  : _M_impl(0) {
  _Locale_impl* impl = new _Locale_impl(*L1._M_impl);

  _Locale_impl* i2 = L2._M_impl;

  if (L1.name() != _Nameless && L2.name() != _Nameless)
    _Stl_loc_combine_names(impl, L1._M_impl->name.c_str(), L2._M_impl->name.c_str(), c);
  else {
    impl->name = _Nameless;
  }

  if (c & collate) {
    impl->insert( i2, _STLP_STD::collate<char>::id);
# ifndef _STLP_NO_WCHAR_T
    impl->insert( i2, _STLP_STD::collate<wchar_t>::id);
# endif
  }
  if (c & ctype) {
    impl->insert( i2, _STLP_STD::ctype<char>::id);
    impl->insert( i2, _STLP_STD::codecvt<char, char, mbstate_t>::id);
# ifndef _STLP_NO_WCHAR_T
    impl->insert( i2, _STLP_STD::ctype<wchar_t>::id);
    impl->insert( i2, _STLP_STD::codecvt<wchar_t, char, mbstate_t>::id);
# endif
  }
  if (c & monetary) {
    impl->insert( i2, _STLP_STD::moneypunct<char, true>::id);
    impl->insert( i2, _STLP_STD::moneypunct<char, false>::id);
    impl->insert( i2, _STLP_STD::money_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
    impl->insert( i2, _STLP_STD::money_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
# ifndef _STLP_NO_WCHAR_T
    impl->insert( i2, _STLP_STD::moneypunct<wchar_t, true>::id);
    impl->insert( i2, _STLP_STD::moneypunct<wchar_t, false>::id);
    impl->insert( i2, _STLP_STD::money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
    impl->insert( i2, _STLP_STD::money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
# endif
  }
  if (c & numeric) {
    impl->insert( i2, _STLP_STD::numpunct<char>::id);
    impl->insert( i2, _STLP_STD::num_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
    impl->insert( i2, _STLP_STD::num_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
# ifndef _STLP_NO_WCHAR_T
    impl->insert( i2, _STLP_STD::numpunct<wchar_t>::id);
    impl->insert( i2, _STLP_STD::num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
    impl->insert( i2, _STLP_STD::num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
# endif
  }
  if (c & time) {
    impl->insert( i2, _STLP_STD::time_get<char, istreambuf_iterator<char, char_traits<char> > >::id);
    impl->insert( i2, _STLP_STD::time_put<char, ostreambuf_iterator<char, char_traits<char> > >::id);
# ifndef _STLP_NO_WCHAR_T
    impl->insert( i2, _STLP_STD::time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
    impl->insert( i2, _STLP_STD::time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
# endif
  }
  if (c & messages) {
    impl->insert( i2, _STLP_STD::messages<char>::id);
# ifndef _STLP_NO_WCHAR_T
    impl->insert( i2, _STLP_STD::messages<wchar_t>::id);
# endif
  }
  _M_impl = _get_Locale_impl( impl );
}
コード例 #8
0
ファイル: locale.cpp プロジェクト: ChunHungLiu/stlport
locale::locale( _Locale_impl* impl ) :
  _M_impl( _get_Locale_impl( impl ) )
{}
コード例 #9
0
// Default constructor: create a copy of the global locale.
locale::locale() : _M_impl(_get_Locale_impl(_Stl_get_global_locale()->_M_impl))
{}