void _STLP_CALL locale::_M_throw_on_creation_failure(int __err_code, const char* name, const char* facet) { string what; switch (__err_code) { case _STLP_LOC_UNSUPPORTED_FACET_CATEGORY: what = "No platform localization support for "; what += facet; what += " facet category, unable to create facet for "; what += name[0] == 0 ? "system" : name; what += " locale"; break; case _STLP_LOC_NO_PLATFORM_SUPPORT: what = "No platform localization support, unable to create "; what += name[0] == 0 ? "system" : name; what += " locale"; break; default: case _STLP_LOC_UNKNOWN_NAME: what = "Unable to create facet "; what += facet; what += " from name '"; what += name; what += "'"; break; case _STLP_LOC_NO_MEMORY: _STLP_THROW_BAD_ALLOC; break; } _STLP_THROW(runtime_error(what.c_str())); }
void _STLP_CALL locale::_M_throw_on_combine_error(const string& name) { string what = "Unable to find facet"; what += " in "; what += name.empty() ? "system" : name.c_str(); what += " locale"; _STLP_THROW(runtime_error(what.c_str())); }
void _STLP_CALL locale::_M_throw_runtime_error(const char* name) { char buf[256]; if (name) { const char* prefix = "bad locale name: "; strcpy(buf, prefix); strncat(buf, name, 256 - strlen(prefix)); buf[255] = '\0'; } else { strcpy(buf, "locale error"); } _STLP_THROW(runtime_error(buf)); }
// 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) }
void _STLP_CALL locale::_M_throw_on_null_name() { _STLP_THROW(runtime_error("Invalid null locale name")); }
// _Locale_impl non-inline member functions. void _STLP_CALL _Locale_impl::_M_throw_bad_cast() { _STLP_THROW(bad_cast()); }