Esempio n. 1
0
void _Locale_impl::insert_ctype_facets(const char* pname)
{
  ctype<char>*    ct                      = 0;
# ifndef __STL_NO_MBSTATE_T
  codecvt<char, char, mbstate_t>*    cvt  = 0;
# endif
# ifndef __STL_NO_WCHAR_T
  ctype<wchar_t>* wct                     = 0;
  codecvt<wchar_t, char, mbstate_t>* wcvt = 0;
# endif

  char buf[_Locale_MAX_SIMPLE_NAME];
  if (pname == 0 || pname[0] == 0)
    pname = _Locale_ctype_default(buf);

  if (pname == 0 || pname[0] == 0 || strcmp(pname, "C") == 0) {
    this->insert(_Stl_loc_classic_locale->_M_impl, ctype<char>::id);
    this->insert(_Stl_loc_classic_locale->_M_impl,
                 codecvt<char, char, mbstate_t>::id);
# ifndef __STL_NO_WCHAR_T
    this->insert(_Stl_loc_classic_locale->_M_impl, ctype<wchar_t>::id);
    this->insert(_Stl_loc_classic_locale->_M_impl,
                 codecvt<wchar_t, char, mbstate_t>::id);
# endif
  }
  else {
    __STL_TRY {
      ct   = new ctype_byname<char>(pname);
# ifndef __STL_NO_MBSTATE_T
      cvt  = new codecvt_byname<char, char, mbstate_t>(pname);
# endif
# ifndef __STL_NO_WCHAR_T
      wct  = new ctype_byname<wchar_t>(pname); 
      wcvt = new codecvt_byname<wchar_t, char, mbstate_t>(pname);
# endif
    }
    
# ifndef __STL_NO_WCHAR_T
#  ifdef __STL_NO_MBSTATE_T
    __STL_UNWIND(delete ct; delete wct; delete cvt);
#  else
    __STL_UNWIND(delete ct; delete wct; delete cvt; delete wcvt);
#  endif
# else
#  ifdef __STL_NO_MBSTATE_T
    __STL_UNWIND(delete ct);
#  else
    __STL_UNWIND(delete ct; delete cvt);
#  endif
# endif    
    _Locale_impl_insert(this, ct);
#  ifndef __STL_NO_MBSTATE_T
    _Locale_impl_insert(this, cvt);
#  endif
#  ifndef __STL_NO_WCHAR_T
    _Locale_impl_insert(this, wct);
    _Locale_impl_insert(this, wcvt);
#  endif
  }
}
// Create a locale from a name.
                _STLP_EXP_DECLSPEC locale::locale(const char* name)
                    : _M_impl(0)
                {
                    if (!name)
                        _M_throw_runtime_error(0);
                    else if(strcmp(name,"")==0)
                        name = _Locale_ctype_default(NULL);

                    _Locale* impl = 0;

                    _STLP_TRY {
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
impl = new _Locale(get_locale_id_S_max(), name);
# else
impl = new _Locale(locale::id::_S_max, name);
# endif


                        // 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 = impl;
                    }
                    _STLP_UNWIND(delete impl);
                }
 const char* _Loc_ctype_default(char* p)    { return _Locale_ctype_default(p); }
Esempio n. 4
0
/*
 * Six functions, one for each category.  Each of them takes a
 * _Locale* and a name, constructs that appropriate category
 * facets by name, and inserts them into the locale.
 */
_Locale_name_hint* _Locale_impl::insert_ctype_facets(const char* pname, _Locale_name_hint* hint) {
  char buf[_Locale_MAX_SIMPLE_NAME];
  _Locale_impl* i2 = locale::classic()._M_impl;

  if (pname == 0 || pname[0] == 0)
    pname = _Locale_ctype_default(buf);

  if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) {
    this->insert(i2, ctype<char>::id);
#ifndef _STLP_NO_MBSTATE_T
    this->insert(i2, codecvt<char, char, mbstate_t>::id);
#endif
#ifndef _STLP_NO_WCHAR_T
    this->insert(i2, ctype<wchar_t>::id);
#  ifndef _STLP_NO_MBSTATE_T
    this->insert(i2, codecvt<wchar_t, char, mbstate_t>::id);
#  endif
#endif
  } else {
    ctype<char>*    ct                      = 0;
#ifndef _STLP_NO_MBSTATE_T
    codecvt<char, char, mbstate_t>*    cvt  = 0;
#endif
#ifndef _STLP_NO_WCHAR_T
    ctype<wchar_t>* wct                     = 0;
    codecvt<wchar_t, char, mbstate_t>* wcvt = 0;
#endif
    _STLP_TRY {
      ctype_byname<char> *ctbn = _CHECK_PTR(new ctype_byname<char>(pname, 0, hint));
      ct   = ctbn;
#if !defined (__DMC__)
      if (hint == 0) hint = _Locale_extract_hint(ctbn);
#endif
#ifndef _STLP_NO_MBSTATE_T
      cvt  = _CHECK_PTR(new codecvt_byname<char, char, mbstate_t>(pname));
#endif
#ifndef _STLP_NO_WCHAR_T
      wct  = _CHECK_PTR(new ctype_byname<wchar_t>(pname, 0, hint));
      wcvt = _CHECK_PTR(new codecvt_byname<wchar_t, char, mbstate_t>(pname, 0, hint));
#endif
    }

#ifndef _STLP_NO_WCHAR_T
#  ifdef _STLP_NO_MBSTATE_T
    _STLP_UNWIND(delete ct; delete wct; delete wcvt);
#  else
    _STLP_UNWIND(delete ct; delete wct; delete cvt; delete wcvt);
#  endif
#else
#  ifdef _STLP_NO_MBSTATE_T
    _STLP_UNWIND(delete ct);
#  else
    _STLP_UNWIND(delete ct; delete cvt);
#  endif
#endif
    _Locale_insert(this, ct);
#ifndef _STLP_NO_MBSTATE_T
    _Locale_insert(this, cvt);
#endif
#ifndef _STLP_NO_WCHAR_T
    _Locale_insert(this, wct);
    _Locale_insert(this, wcvt);
#endif
  }
  return hint;
}
                        void _Locale::insert_ctype_facets(const char* pname)
                        {
                            char buf[_Locale_MAX_SIMPLE_NAME];
                            _Locale_impl* i2 = locale::classic()._M_impl;

                            if (pname == 0 || pname[0] == 0)
                                pname = _Locale_ctype_default(buf);

                            if (pname == 0 || pname[0] == 0 || strcmp(pname, "C") == 0) {
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
this->insert(i2, ctype<char>::GetFacetLocaleId());
#else
this->insert(i2, ctype<char>::id);
#endif
# ifndef _STLP_NO_MBSTATE_T
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
this->insert(i2, codecvt<char, char, mbstate_t>::GetFacetLocaleId());
#else
this->insert(i2, codecvt<char, char, mbstate_t>::id);
#endif //__LIBSTD_CPP_SYMBIAN32_WSD__
# endif //!_STLP_NO_MBSTATE_T
# ifndef _STLP_NO_WCHAR_T
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
this->insert(i2, ctype<wchar_t>::GetFacetLocaleId());
#else
this->insert(i2, ctype<wchar_t>::id);
#endif //__LIBSTD_CPP_SYMBIAN32_WSD__   
# ifndef _STLP_NO_MBSTATE_T
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
this->insert(i2, codecvt<wchar_t, char, mbstate_t>::GetFacetLocaleId());
#else
this->insert(i2, codecvt<wchar_t, char, mbstate_t>::id);
#endif //__LIBSTD_CPP_SYMBIAN32_WSD__   
# endif //!_STLP_NO_MBSTATE_T
# endif //!_STLP_NO_WCHAR_T
} 
else {
ctype<char>*    ct                      = 0;
# ifndef _STLP_NO_MBSTATE_T
codecvt<char, char, mbstate_t>*    cvt  = 0;
# endif
# ifndef _STLP_NO_WCHAR_T
ctype<wchar_t>* wct                     = 0;
codecvt<wchar_t, char, mbstate_t>* wcvt = 0;
# endif
_STLP_TRY {
ct   = new ctype_byname<char>(pname);
# ifndef _STLP_NO_MBSTATE_T
cvt  = new codecvt_byname<char, char, mbstate_t>(pname);
# endif
# ifndef _STLP_NO_WCHAR_T
wct  = new ctype_byname<wchar_t>(pname);
wcvt = new codecvt_byname<wchar_t, char, mbstate_t>(pname);
# endif
}

# ifndef _STLP_NO_WCHAR_T
#  ifdef _STLP_NO_MBSTATE_T
_STLP_UNWIND(delete ct; delete wct; delete wcvt);
#  else
_STLP_UNWIND(delete ct; delete wct; delete cvt; delete wcvt);
#  endif
# else
#  ifdef _STLP_NO_MBSTATE_T
_STLP_UNWIND(delete ct);
#  else
_STLP_UNWIND(delete ct; delete cvt);
#  endif
# endif
_Locale_insert(this, ct);
#  ifndef _STLP_NO_MBSTATE_T
_Locale_insert(this, cvt);
#  endif
#  ifndef _STLP_NO_WCHAR_T
_Locale_insert(this, wct);
_Locale_insert(this, wcvt);
#  endif
}
}
Esempio n. 6
0
/*
 * Six functions, one for each category.  Each of them takes a
 * _Locale* and a name, constructs that appropriate category
 * facets by name, and inserts them into the locale.
 */
void _Locale_impl::insert_ctype_facets(const char* pname) {
  char buf[_Locale_MAX_SIMPLE_NAME];
  _Locale_impl* i2 = locale::classic()._M_impl;

  if (pname == 0 || pname[0] == 0)
    pname = _Locale_ctype_default(buf);

  if (pname == 0 || pname[0] == 0 || is_C_locale_name(pname)) {
    this->insert(i2, ctype<char>::id);
#ifndef _STLP_NO_MBSTATE_T
    this->insert(i2, codecvt<char, char, mbstate_t>::id);
#endif
#ifndef _STLP_NO_WCHAR_T
    this->insert(i2, ctype<wchar_t>::id);
#  ifndef _STLP_NO_MBSTATE_T
    this->insert(i2, codecvt<wchar_t, char, mbstate_t>::id);
#  endif
#endif
  } else {
    ctype<char>*    ct                      = 0;
#ifndef _STLP_NO_MBSTATE_T
    codecvt<char, char, mbstate_t>*    cvt  = 0;
#endif
#ifndef _STLP_NO_WCHAR_T
    ctype<wchar_t>* wct                     = 0;
    codecvt<wchar_t, char, mbstate_t>* wcvt = 0;
#endif
    _STLP_TRY {
      ct   = new ctype_byname<char>(pname);
#ifndef _STLP_NO_MBSTATE_T
      cvt  = new codecvt_byname<char, char, mbstate_t>(pname);
#endif
#ifndef _STLP_NO_WCHAR_T
      wct  = new ctype_byname<wchar_t>(pname);
      wcvt = new codecvt_byname<wchar_t, char, mbstate_t>(pname);
#endif
    }

#ifndef _STLP_NO_WCHAR_T
#  ifdef _STLP_NO_MBSTATE_T
    _STLP_UNWIND(delete ct; delete wct; delete wcvt);
#  else
    _STLP_UNWIND(delete ct; delete wct; delete cvt; delete wcvt);
#  endif
#else
#  ifdef _STLP_NO_MBSTATE_T
    _STLP_UNWIND(delete ct);
#  else
    _STLP_UNWIND(delete ct; delete cvt);
#  endif
#endif
    _Locale_insert(this, ct);
#ifndef _STLP_NO_MBSTATE_T
    _Locale_insert(this, cvt);
#endif
#ifndef _STLP_NO_WCHAR_T
    _Locale_insert(this, wct);
    _Locale_insert(this, wcvt);
#endif
  }
}