Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
nsCyrXPCOMStringDetector Class Reference

#include <nsCyrillicDetector.h>

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

List of all members.

Public Member Functions

NS_DECL_ISUPPORTS nsCyrXPCOMStringDetector (PRUint8 aItems, const PRUint8 **aCyrillicClass, const char **aCharsets)
virtual ~nsCyrXPCOMStringDetector ()
NS_IMETHOD DoIt (const char *aBuf, PRUint32 aLen, const char **oCharset, nsDetectionConfident &oConf)
virtual void HandleData (const char *aBuf, PRUint32 aLen)
virtual void DataEnd ()

Protected Member Functions

virtual void Report (const char *aCharset)

Protected Attributes

PRBool mDone

Private Attributes

nsCOMPtr
< nsICharsetDetectionObserver
mObserver
const char * mResult

Detailed Description

Definition at line 137 of file nsCyrillicDetector.h.


Constructor & Destructor Documentation

nsCyrXPCOMStringDetector::nsCyrXPCOMStringDetector ( PRUint8  aItems,
const PRUint8 **  aCyrillicClass,
const char **  aCharsets 
)

Definition at line 161 of file nsCyrillicDetector.cpp.

            : nsCyrillicDetector(aItems, aCyrillicClass, aCharsets)
{
}

Definition at line 169 of file nsCyrillicDetector.cpp.

{
}

Member Function Documentation

void nsCyrillicDetector::DataEnd ( void  ) [virtual, inherited]

Definition at line 79 of file nsCyrillicDetector.cpp.

{
   PRUint32 max=0;
   PRUint8  maxIdx=0;
   PRUint8 j;
   if(mDone) 
      return;
   for(j=0;j<mItems;j++) {
      if(mProb[j] > max)
      {
           max = mProb[j];
           maxIdx= j;
      }
   }

   if( 0 == max ) // if we didn't get any 8 bits data 
     return;

#ifdef DEBUG
   for(j=0;j<mItems;j++) 
      printf("Charset %s->\t%d\n", mCharsets[j], mProb[j]);
#endif
   this->Report(mCharsets[maxIdx]);
   mDone = PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHODIMP nsCyrXPCOMStringDetector::DoIt ( const char *  aBuf,
PRUint32  aLen,
const char **  oCharset,
nsDetectionConfident oConf 
) [virtual]

Implements nsIStringCharsetDetector.

Definition at line 180 of file nsCyrillicDetector.cpp.

{
   mResult = nsnull;
   mDone = PR_FALSE;
   this->HandleData(aBuf, aLen); 
   this->DataEnd();
   *oCharset=mResult;
   oConf = eBestAnswer;
   return NS_OK;
}

Here is the call graph for this function:

void nsCyrillicDetector::HandleData ( const char *  aBuf,
PRUint32  aLen 
) [virtual, inherited]

Definition at line 53 of file nsCyrillicDetector.cpp.

{
   PRUint8 cls;
   const char* b;
   PRUint32 i;
   if(mDone) 
      return;
   for(i=0, b=aBuf;i<aLen;i++,b++)
   {
     for(PRUintn j=0;j<mItems;j++)
     {
        if( 0x80 & *b)
           cls = mCyrillicClass[j][(*b) & 0x7F];
        else 
           cls = 0;
        NS_ASSERTION( cls <= 32 , "illegal character class");
        mProb[j] += gCyrillicProb[mLastCls[j]][cls];
        mLastCls[j] = cls;
     } 
   }
   // We now only based on the first block we receive
   DataEnd();
}

Here is the caller graph for this function:

void nsCyrXPCOMStringDetector::Report ( const char *  aCharset) [protected, virtual]

Implements nsCyrillicDetector.

Definition at line 174 of file nsCyrillicDetector.cpp.

{
   mResult = aCharset;
}

Member Data Documentation

PRBool nsCyrillicDetector::mDone [protected, inherited]

Definition at line 107 of file nsCyrillicDetector.h.

Definition at line 153 of file nsCyrillicDetector.h.

Definition at line 154 of file nsCyrillicDetector.h.


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