Back to index

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

#include <nsCyrillicDetector.h>

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

List of all members.

Public Member Functions

 nsRUProbDetector ()
NS_IMETHOD Init (nsICharsetDetectionObserver *aObserver)
NS_IMETHOD DoIt (const char *aBuf, PRUint32 aLen, PRBool *oDontFeedMe)
NS_IMETHOD Done ()
virtual void HandleData (const char *aBuf, PRUint32 aLen)
virtual void DataEnd ()

Protected Member Functions

virtual void Report (const char *aCharset)

Protected Attributes

PRBool mDone

Detailed Description

Definition at line 157 of file nsCyrillicDetector.h.


Constructor & Destructor Documentation

Definition at line 160 of file nsCyrillicDetector.h.


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 nsCyrXPCOMDetector::DoIt ( const char *  aBuf,
PRUint32  aLen,
PRBool oDontFeedMe 
) [virtual, inherited]

Implements nsICharsetDetector.

Definition at line 132 of file nsCyrillicDetector.cpp.

{
  NS_ASSERTION(mObserver != nsnull , "have not init yet");

  if((nsnull == aBuf) || (nsnull == oDontFeedMe))
     return NS_ERROR_ILLEGAL_VALUE;

  this->HandleData(aBuf, aLen);
  *oDontFeedMe = PR_FALSE;
  return NS_OK;
}

Here is the call graph for this function:

NS_IMETHODIMP nsCyrXPCOMDetector::Done ( ) [virtual, inherited]

Implements nsICharsetDetector.

Definition at line 146 of file nsCyrillicDetector.cpp.

{
  NS_ASSERTION(mObserver != nsnull , "have not init yet");
  this->DataEnd();
  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:

Implements nsICharsetDetector.

Definition at line 120 of file nsCyrillicDetector.cpp.

{
  NS_ASSERTION(mObserver == nsnull , "Init twice");
  if(nsnull == aObserver)
     return NS_ERROR_ILLEGAL_VALUE;

  mObserver = aObserver;
  return NS_OK;
}
void nsCyrXPCOMDetector::Report ( const char *  aCharset) [protected, virtual, inherited]

Implements nsCyrillicDetector.

Definition at line 154 of file nsCyrillicDetector.cpp.

{
  NS_ASSERTION(mObserver != nsnull , "have not init yet");
  mObserver->Notify(aCharset, eBestAnswer);
}

Member Data Documentation

PRBool nsCyrillicDetector::mDone [protected, inherited]

Definition at line 107 of file nsCyrillicDetector.h.


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