Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions
nsUnicodeEncodeHelper Class Reference

The actual implementation of the nsIUnicodeEncodeHelper interface. More...

#include <nsUnicodeEncodeHelper.h>

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

List of all members.

Public Member Functions

 nsUnicodeEncodeHelper ()
 Class constructor.
virtual ~nsUnicodeEncodeHelper ()
 Class destructor.
NS_IMETHOD ConvertByTable (const PRUnichar *aSrc, PRInt32 *aSrcLength, char *aDest, PRInt32 *aDestLength, uShiftTable *aShiftTable, uMappingTable *aMappingTable)
 Converts data using a lookup table.
NS_IMETHOD ConvertByMultiTable (const PRUnichar *aSrc, PRInt32 *aSrcLength, char *aDest, PRInt32 *aDestLength, PRInt32 aTableCount, uShiftTable **aShiftTable, uMappingTable **aMappingTable)
 Converts data using a set of lookup tables.
NS_IMETHOD CreateCache (nsMappingCacheType aType, nsIMappingCache *aResult)
 Create a Mapping Cache.
NS_IMETHOD DestroyCache (nsIMappingCache aCache)
 Destroy a Mapping Cache.
NS_IMETHOD FillInfo (PRUint32 *aInfo, uMappingTable *aMappingTable)
 Create Char Representable Info.
NS_IMETHOD FillInfo (PRUint32 *aInfo, PRInt32 aTableCount, uMappingTable **aMappingTable)

Detailed Description

The actual implementation of the nsIUnicodeEncodeHelper interface.

22/Nov/1998

Author:
Catalin Rotaru [CATA]

Definition at line 52 of file nsUnicodeEncodeHelper.h.


Constructor & Destructor Documentation

Class constructor.

Definition at line 52 of file nsUnicodeEncodeHelper.cpp.

{
}

Class destructor.

Definition at line 56 of file nsUnicodeEncodeHelper.cpp.

{
}

Member Function Documentation

NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByMultiTable ( const PRUnichar aSrc,
PRInt32 aSrcLength,
char *  aDest,
PRInt32 aDestLength,
PRInt32  aTableCount,
uShiftTable **  aShiftTable,
uMappingTable **  aMappingTable 
) [virtual]

Converts data using a set of lookup tables.

Implements nsIUnicodeEncodeHelper.

Definition at line 102 of file nsUnicodeEncodeHelper.cpp.

{
  const PRUnichar * src = aSrc;
  const PRUnichar * srcEnd = aSrc + *aSrcLength;
  char * dest = aDest;
  PRInt32 destLen = *aDestLength;

  PRUnichar med;
  PRInt32 bcw; // byte count for write;
  nsresult res = NS_OK;
  PRInt32 i;

  while (src < srcEnd) {
    for (i=0; i<aTableCount; i++) 
      if (uMapCode((uTable*) aMappingTable[i], NS_STATIC_CAST(PRUint16, *src), NS_REINTERPRET_CAST(PRUint16*, &med))) break;

    src++;
    if (i == aTableCount) {
      res = NS_ERROR_UENC_NOMAPPING;
      break;
    }

    if (!uGenerate(aShiftTable[i], 0, med, (PRUint8 *)dest, destLen, 
      (PRUint32 *)&bcw)) { 
      src--;
      res = NS_OK_UENC_MOREOUTPUT;
      break;
    }

    dest += bcw;
    destLen -= bcw;
  }

  *aSrcLength = src - aSrc;
  *aDestLength  = dest - aDest;
  return res;
}

Here is the call graph for this function:

NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByTable ( const PRUnichar aSrc,
PRInt32 aSrcLength,
char *  aDest,
PRInt32 aDestLength,
uShiftTable aShiftTable,
uMappingTable aMappingTable 
) [virtual]

Converts data using a lookup table.

Implements nsIUnicodeEncodeHelper.

Definition at line 63 of file nsUnicodeEncodeHelper.cpp.

{
  const PRUnichar * src = aSrc;
  const PRUnichar * srcEnd = aSrc + *aSrcLength;
  char * dest = aDest;
  PRInt32 destLen = *aDestLength;

  PRUnichar med;
  PRInt32 bcw; // byte count for write;
  nsresult res = NS_OK;

  while (src < srcEnd) {
    if (!uMapCode((uTable*) aMappingTable, NS_STATIC_CAST(PRUnichar, *(src++)), NS_REINTERPRET_CAST(PRUint16*, &med))) {
      res = NS_ERROR_UENC_NOMAPPING;
      break;
    }

    if (!uGenerate(aShiftTable, 0, med, (PRUint8 *)dest, destLen, 
      (PRUint32 *)&bcw)) { 
      src--;
      res = NS_OK_UENC_MOREOUTPUT;
      break;
    }

    dest += bcw;
    destLen -= bcw;
  }

  *aSrcLength = src - aSrc;
  *aDestLength  = dest - aDest;
  return res;
}

Here is the call graph for this function:

Create a Mapping Cache.

Implements nsIUnicodeEncodeHelper.

Definition at line 148 of file nsUnicodeEncodeHelper.cpp.

Destroy a Mapping Cache.

Implements nsIUnicodeEncodeHelper.

Definition at line 153 of file nsUnicodeEncodeHelper.cpp.

{
   return nsMappingCache::DestroyCache(aCache);
}
NS_IMETHODIMP nsUnicodeEncodeHelper::FillInfo ( PRUint32 aInfo,
uMappingTable aMappingTable 
) [virtual]

Create Char Representable Info.

Implements nsIUnicodeEncodeHelper.

Definition at line 158 of file nsUnicodeEncodeHelper.cpp.

{
   uFillInfo((uTable*) aMappingTable, aInfo);
   return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsUnicodeEncodeHelper::FillInfo ( PRUint32 aInfo,
PRInt32  aTableCount,
uMappingTable **  aMappingTable 
) [virtual]

Implements nsIUnicodeEncodeHelper.

Definition at line 163 of file nsUnicodeEncodeHelper.cpp.

{
   for (PRInt32 i=0; i<aTableCount; i++) 
      uFillInfo((uTable*) aMappingTable[i], aInfo);
   return NS_OK;
}

Here is the call graph for this function:


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