Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
nsLocale Class Reference

#include <nsLocale.h>

Inheritance diagram for nsLocale:
Inheritance graph
[legend]
Collaboration diagram for nsLocale:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsLocale (void)
 nsLocale (const nsStringArray &categoryList, const nsStringArray &valueList)
 nsLocale (nsLocale *other)
virtual ~nsLocale (void)
AString getCategory (in AString category)

Protected Member Functions

NS_IMETHOD AddCategory (const nsAString &category, const nsAString &value)

Static Protected Member Functions

static PLHashNumber PR_CALLBACK Hash_HashFunction (const void *key)
static PRIntn PR_CALLBACK Hash_CompareNSString (const void *s1, const void *s2)
static PRIntn PR_CALLBACK Hash_EnumerateDelete (PLHashEntry *he, PRIntn hashIndex, void *arg)
static PRIntn PR_CALLBACK Hash_EnumerateCopy (PLHashEntry *he, PRIntn hashIndex, void *arg)

Protected Attributes

PLHashTablefHashtable
PRUint32 fCategoryCount

Friends

class nsLocaleDefinition
class nsLocaleService

Detailed Description

Definition at line 61 of file nsLocale.h.


Constructor & Destructor Documentation

Definition at line 57 of file nsLocale.cpp.

Here is the call graph for this function:

nsLocale::nsLocale ( const nsStringArray &  categoryList,
const nsStringArray &  valueList 
)

Definition at line 81 of file nsLocale.cpp.

                  : fHashtable(NULL), fCategoryCount(0)
{
  PRInt32 i;
  PRUnichar* key, *value;

  fHashtable = PL_NewHashTable(LOCALE_HASH_SIZE,&nsLocale::Hash_HashFunction,
                               &nsLocale::Hash_CompareNSString,
                               &nsLocale::Hash_CompareNSString,
                               NULL, NULL);
  NS_ASSERTION(fHashtable, "nsLocale: failed to allocate PR_Hashtable");

  if (fHashtable)
  {
    for(i=0; i < categoryList.Count(); ++i) 
    {
      key = ToNewUnicode(*categoryList.StringAt(i));
      NS_ASSERTION(key, "nsLocale: failed to allocate internal hash key");
      value = ToNewUnicode(*valueList.StringAt(i));
      NS_ASSERTION(value, "nsLocale: failed to allocate internal hash value");
      if (!PL_HashTableAdd(fHashtable,key,value)) {
          nsMemory::Free(key);
          nsMemory::Free(value);
      }
    }
  }
}

Here is the call graph for this function:

Definition at line 66 of file nsLocale.cpp.

Here is the call graph for this function:

nsLocale::~nsLocale ( void  ) [virtual]

Definition at line 110 of file nsLocale.cpp.

{
  // enumerate all the entries with a delete function to
  // safely delete all the keys and values
  PL_HashTableEnumerateEntries(fHashtable, &nsLocale::Hash_EnumerateDelete,
                               NULL);

  PL_HashTableDestroy(fHashtable);
}

Here is the call graph for this function:


Member Function Documentation

NS_IMETHODIMP nsLocale::AddCategory ( const nsAString &  category,
const nsAString &  value 
) [protected]

Definition at line 136 of file nsLocale.cpp.

{
  PRUnichar* newKey = ToNewUnicode(category);
  if (!newKey)
    return NS_ERROR_OUT_OF_MEMORY;

  PRUnichar* newValue = ToNewUnicode(value);
  if (!newValue) {
    nsMemory::Free(newKey);
    return NS_ERROR_OUT_OF_MEMORY;
  }

  if (!PL_HashTableAdd(fHashtable, newKey, newValue)) {
    nsMemory::Free(newKey);
    nsMemory::Free(newValue);
    return NS_ERROR_OUT_OF_MEMORY;
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

AString nsILocale::getCategory ( in AString  category) [inherited]
PRIntn nsLocale::Hash_CompareNSString ( const void s1,
const void s2 
) [static, protected]

Definition at line 174 of file nsLocale.cpp.

{
  return !nsCRT::strcmp((const PRUnichar *) s1, (const PRUnichar *) s2);
}

Here is the caller graph for this function:

PRIntn nsLocale::Hash_EnumerateCopy ( PLHashEntry he,
PRIntn  hashIndex,
void arg 
) [static, protected]

Definition at line 191 of file nsLocale.cpp.

{
  PRUnichar* newKey = ToNewUnicode(nsDependentString((PRUnichar *)he->key));
  if (!newKey) 
    return HT_ENUMERATE_STOP;

  PRUnichar* newValue = ToNewUnicode(nsDependentString((PRUnichar *)he->value));
  if (!newValue) {
    nsMemory::Free(newKey);
    return HT_ENUMERATE_STOP;
  }

  if (!PL_HashTableAdd((PLHashTable*)arg, newKey, newValue)) {
    nsMemory::Free(newKey);
    nsMemory::Free(newValue);
    return HT_ENUMERATE_STOP;
  }

  return (HT_ENUMERATE_NEXT);
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRIntn nsLocale::Hash_EnumerateDelete ( PLHashEntry he,
PRIntn  hashIndex,
void arg 
) [static, protected]

Definition at line 181 of file nsLocale.cpp.

{
  // delete an entry
  nsMemory::Free((PRUnichar *)he->key);
  nsMemory::Free((PRUnichar *)he->value);

  return (HT_ENUMERATE_NEXT | HT_ENUMERATE_REMOVE);
}

Here is the caller graph for this function:

PLHashNumber nsLocale::Hash_HashFunction ( const void key) [static, protected]

Definition at line 159 of file nsLocale.cpp.

{
  const PRUnichar* ptr = (const PRUnichar *) key;
  PLHashNumber hash;

  hash = (PLHashNumber)0;

  while (*ptr)
    hash += (PLHashNumber) *ptr++;

  return hash;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class nsLocaleDefinition [friend]

Definition at line 62 of file nsLocale.h.

friend class nsLocaleService [friend]

Definition at line 63 of file nsLocale.h.


Member Data Documentation

Definition at line 85 of file nsLocale.h.

Definition at line 84 of file nsLocale.h.


The documentation for this class was generated from the following files: