Beispiel #1
0
static void*
__acquire_category(const char* name, _Locale_name_hint* hint,
                   loc_extract_name_func_t extract_name,
                   loc_create_func_t create_obj, loc_default_name_func_t default_obj,
                   Category_Map ** M) {
#if !defined (__BORLANDC__) || (__BORLANDC__ >= 0x564)
  typedef Category_Map::iterator Category_iterator;
  pair<Category_iterator, bool> result;
#else
#  if !defined(_STLP_DEBUG)
  pair<_Ht_iterator<_Slist_iterator<pair<const string,pair<void *,unsigned int> >,_Nonconst_traits<pair<const string,pair<void *,unsigned int> > > >,_NonLocalHashMapTraitsT<pair<const string,pair<void *,unsigned int> > > >, bool> result;
#  else
  pair<_DBG_iter<_NonDbg_hashtable<pair<const string,pair<void *,unsigned int> >,string,hash<string>,_HashMapTraitsT<pair<const string,pair<void *,unsigned int> > >,_Select1st<pair<const string,pair<void *,unsigned int> > >,_DbgEqual<string,equal_to<string> >,allocator<pair<const string,pair<void *,unsigned int> > > >,_DbgTraits<_NonLocalHashMapTraitsT<pair<const string,pair<void *,unsigned int> > > > >, bool> result;
#  endif
#endif

  // Find what name to look for. Be careful if user requests the default.
  const char *cname;
  char buf[_Locale_MAX_SIMPLE_NAME];
  if (name == 0 || name[0] == 0) {
    cname = default_obj(buf);
    if (cname == 0 || cname[0] == 0)
      cname = "C";
  }
  else {
    cname = extract_name(name, buf, hint);
    if (cname == 0) {
      return 0;
    }
  }

  Category_Map::value_type __e(cname, pair<void*,size_t>((void*)0,size_t(0)));

  _STLP_auto_lock sentry(__category_hash_lock);

  if (!*M)
    *M = new Category_Map();

  // Look for an existing entry with that name.
  result = (*M)->insert_noresize(__e);

  // There was no entry in the map already.  Create the category.
  if (result.second)
    (*result.first).second.first = create_obj(cname, hint);

  // Increment the reference count.
  ++((*result.first).second.second);

  return (*result.first).second.first;
}
static void*
__acquire_category(const char* name, loc_extract_name_func_t extract_name,
                   loc_create_func_t create_obj, loc_default_name_func_t default_obj, 
                   Category_Map ** M) {
  typedef Category_Map::iterator Category_iterator;
  pair<Category_iterator, bool> result;
  
  // Find what name to look for. Be careful if user requests the default.
  const char *cname;
  char buf[_Locale_MAX_SIMPLE_NAME];
  if (name == 0 || name[0] == 0) {
    cname = default_obj(buf);
    if (cname == 0 || cname[0] == 0)
      cname = "C";
  }
  else {
    cname = extract_name(name, buf);
    if (cname == 0) {
      return 0;
    }
  }

  Category_Map::value_type __e(cname, pair<void*,size_t>((void*)0,size_t(0)));

  _STLP_auto_lock sentry(__category_hash_lock);

  if (!*M)
    *M = new Category_Map();

#if defined(__SC__)    //*TY 06/01/2000 - added workaround for SCpp
  if(!*M) delete *M;  //*TY 06/01/2000 - it forgets to generate dtor for Category_Map class. This fake code forces to generate one.
#endif          //*TY 06/01/2000 - 

  // Look for an existing entry with that name.
  result = (*M)->insert_noresize(__e);

  // There was no entry in the map already.  Create the category.
  if (result.second) 
    (*result.first).second.first = create_obj(cname);

  // Increment the reference count.
  ++((*result.first).second.second);

  return (*result.first).second.first;
}
static void*
__acquire_category(const char* name, loc_create_func_t create_obj,
                   loc_default_name_func_t default_obj, Category_Map ** M)
{
    typedef Category_Map::iterator Category_iterator;
    pair<Category_iterator, bool> result;
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
    _STLP_auto_lock sentry(get_locale_catalog_category_hash_lock());
# else
    _STLP_auto_lock sentry(__category_hash_lock);
# endif

    typedef const char* key_type;


    if (!*M)
        *M = new Category_Map();

#if defined(__SC__)		//*TY 06/01/2000 - added workaround for SCpp
if(!*M) delete *M;	//*TY 06/01/2000 - it forgets to generate dtor for Category_Map class. This fake code forces to generate one.
#endif					//*TY 06/01/2000 - 

    // Find what name to look for.  Be careful if user requests the default.
    char buf[_Locale_MAX_SIMPLE_NAME];
    if (name == 0 || name[0] == 0)
        name = default_obj(buf);
    if (name == 0 || name[0] == 0)
        name = "C";

    pair<const key_type, pair<void*,size_t> > __e(name, pair<void*,size_t>((void*)0,size_t(0)));

    // Look for an existing entry with that name.

    result = (*M)->insert_noresize(__e);

    // There was no entry in the map already.  Create the category.
    if (result.second)
        (*result.first).second.first = create_obj(name);

    // Increment the reference count.
    ++((*result.first).second.second);

    return (*result.first).second.first;
}