// Create a locale that's a copy of L, except that all of the facets
// in category c are instead constructed by name.
                _STLP_EXP_DECLSPEC locale::locale(const locale& L, const char* name, locale::category c)
                    : _M_impl(0)
                {
                    if (name == 0 || strcmp(name, "*") == 0)
                        _M_throw_runtime_error(name);

                    _Locale* impl = 0;

                    _STLP_TRY {
                        impl = new _Locale(*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 = impl;
                    }
                    _STLP_UNWIND(delete impl)

                }
Example #2
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)
    _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)
}
Example #3
0
// 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 );
}
// 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.
                _STLP_EXP_DECLSPEC locale::locale(const locale& L1, const locale& L2, category c)
                    : _M_impl(0)
                {
                    _Locale* impl = new _Locale(*L1._M_impl);

                    _Locale_impl* i2 = L2._M_impl;

#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
const string nameless("*");
# else
static string nameless("*");
# endif

                    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 = "*";
                    }

                    if (c & collate) {
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
impl->insert( i2, _STLP_STD::collate<char>::GetFacetLocaleId());
#else
impl->insert( i2, _STLP_STD::collate<char>::id);
#endif
# ifndef _STLP_NO_WCHAR_T
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
impl->insert( i2, _STLP_STD::collate<wchar_t>::GetFacetLocaleId());
#else
impl->insert( i2, _STLP_STD::collate<wchar_t>::id);
#endif //__LIBSTD_CPP_SYMBIAN32_WSD__    
# endif //!_STLP_NO_WCHAR_T
}
if (c & ctype) {
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
impl->insert( i2, _STLP_STD::codecvt<char, char, mbstate_t>::GetFacetLocaleId());
impl->insert( i2, _STLP_STD::ctype<char>::GetFacetLocaleId());
#else
impl->insert( i2, _STLP_STD::codecvt<char, char, mbstate_t>::id);
impl->insert( i2, _STLP_STD::ctype<char>::id);
#endif //__LIBSTD_CPP_SYMBIAN32_WSD__

# ifndef _STLP_NO_WCHAR_T
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
impl->insert( i2, _STLP_STD::ctype<wchar_t>::GetFacetLocaleId());
impl->insert( i2, _STLP_STD::codecvt<wchar_t, char, mbstate_t>::GetFacetLocaleId());
#else
impl->insert( i2, _STLP_STD::ctype<wchar_t>::id);
impl->insert( i2, _STLP_STD::codecvt<wchar_t, char, mbstate_t>::id);
#endif //__LIBSTD_CPP_SYMBIAN32_WSD__   
# endif //!_STLP_NO_WCHAR_T
}
if (c & monetary) {
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
impl->insert( i2, _STLP_STD::moneypunct<char, true>::GetFacetLocaleId());
impl->insert( i2, _STLP_STD::moneypunct<char, false>::GetFacetLocaleId());
impl->insert( i2, _STLP_STD::money_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
impl->insert( i2, _STLP_STD::money_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
#else
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);
#endif //__LIBSTD_CPP_SYMBIAN32_WSD__       

# ifndef _STLP_NO_WCHAR_T
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
impl->insert( i2, _STLP_STD::moneypunct<wchar_t, true>::GetFacetLocaleId());
impl->insert( i2, _STLP_STD::moneypunct<wchar_t, false>::GetFacetLocaleId());
impl->insert( i2, _STLP_STD::money_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
impl->insert( i2, _STLP_STD::money_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
#else
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  //__LIBSTD_CPP_SYMBIAN32_WSD__         
# endif //!_STLP_NO_WCHAR_T
}
if (c & numeric) {
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
impl->insert( i2, _STLP_STD::numpunct<char>::GetFacetLocaleId());
impl->insert( i2, _STLP_STD::num_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
impl->insert( i2, _STLP_STD::num_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
#else
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);
#endif

# ifndef _STLP_NO_WCHAR_T
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
impl->insert(i2, _STLP_STD::numpunct<wchar_t>::GetFacetLocaleId());
impl->insert( i2, num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
impl->insert( i2, num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
#else
impl->insert( i2, _STLP_STD::numpunct<wchar_t>::id);
impl->insert( i2, num_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
impl->insert( i2, num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::id);
#endif    //__LIBSTD_CPP_SYMBIAN32_WSD__    
# endif //!_STLP_NO_WCHAR_T
}
if (c & time) {
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
impl->insert( i2, _STLP_STD::time_get<char, istreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
impl->insert( i2, _STLP_STD::time_put<char, ostreambuf_iterator<char, char_traits<char> > >::GetFacetLocaleId());
#else
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);
#endif //__LIBSTD_CPP_SYMBIAN32_WSD__    
# ifndef _STLP_NO_WCHAR_T
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
impl->insert( i2, _STLP_STD::time_get<wchar_t, istreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
impl->insert( i2, _STLP_STD::time_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > >::GetFacetLocaleId());
#else
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 //__LIBSTD_CPP_SYMBIAN32_WSD__    
# endif //!_STLP_NO_WCHAR_T
}
if (c & messages) {
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
impl->insert( i2, _STLP_STD::messages<char>::GetFacetLocaleId());
#else
impl->insert( i2, _STLP_STD::messages<char>::id);
#endif
# ifndef _STLP_NO_WCHAR_T
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
impl->insert( i2, _STLP_STD::messages<wchar_t>::GetFacetLocaleId());
#else
impl->insert( i2, _STLP_STD::messages<wchar_t>::id);
#endif //__LIBSTD_CPP_SYMBIAN32_WSD__    
# endif //_STLP_NO_WCHAR_T
}
_M_impl = impl;
}