nsEscCharSetProber Class Reference

#include <nsEscCharsetProber.h>

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

Public Member Functions

 nsEscCharSetProber (void)
virtual ~nsEscCharSetProber (void)
nsProbingState HandleData (const char *aBuf, PRUint32 aLen)
const char * GetCharSetName ()
nsProbingState GetState (void)
void Reset (void)
float GetConfidence (void)
void SetOpion ()

Protected Member Functions

void GetDistribution (PRUint32 aCharLen, const char *aStr)

Protected Attributes

nsCodingStateMachinemCodingSM [NUM_OF_ESC_CHARSETS]
PRUint32 mActiveSM
nsProbingState mState
const char * mDetectedCharset

Detailed Description

Definition at line 46 of file nsEscCharsetProber.h.


Constructor & Destructor Documentation

nsEscCharSetProber::nsEscCharSetProber ( void   ) 
nsEscCharSetProber::~nsEscCharSetProber ( void   )  [virtual]

Definition at line 52 of file nsEscCharsetProber.cpp.

References mCodingSM, and NUM_OF_ESC_CHARSETS.

00053 {
00054   for (PRUint32 i = 0; i < NUM_OF_ESC_CHARSETS; i++)
00055     delete mCodingSM[i];
00056 }


Member Function Documentation

const char* nsEscCharSetProber::GetCharSetName (  )  [inline, virtual]

Implements nsCharSetProber.

Definition at line 51 of file nsEscCharsetProber.h.

References mDetectedCharset.

00051 {return mDetectedCharset;};

float nsEscCharSetProber::GetConfidence ( void   )  [inline, virtual]

Implements nsCharSetProber.

Definition at line 54 of file nsEscCharsetProber.h.

00054 {return (float)0.99;};

void nsEscCharSetProber::GetDistribution ( PRUint32  aCharLen,
const char *  aStr 
) [protected]
nsProbingState nsEscCharSetProber::GetState ( void   )  [inline, virtual]

Implements nsCharSetProber.

Definition at line 52 of file nsEscCharsetProber.h.

References mState.

00052 {return mState;};

nsProbingState nsEscCharSetProber::HandleData ( const char *  aBuf,
PRUint32  aLen 
) [virtual]

Implements nsCharSetProber.

Definition at line 67 of file nsEscCharsetProber.cpp.

References eDetecting, eError, eFoundIt, eItsMe, eNotMe, nsCodingStateMachine::GetCodingStateMachine(), mActiveSM, mCodingSM, mDetectedCharset, mState, and nsCodingStateMachine::NextState().

00068 {
00069   nsSMState codingState;
00070   PRInt32 j;
00071   PRUint32 i;
00072 
00073   for ( i = 0; i < aLen && mState == eDetecting; i++)
00074   {
00075     for (j = mActiveSM-1; j>= 0; j--)
00076     {
00077       //byte is feed to all active state machine 
00078       codingState = mCodingSM[j]->NextState(aBuf[i]);
00079       if (codingState == eError)
00080       {
00081         //got negative answer for this state machine, make it inactive
00082         mActiveSM--;
00083         if (mActiveSM == 0)
00084         {
00085           mState = eNotMe;
00086           return mState;
00087         }
00088         else if (j != (PRInt32)mActiveSM)
00089         {
00090           nsCodingStateMachine* t;
00091           t = mCodingSM[mActiveSM];
00092           mCodingSM[mActiveSM] = mCodingSM[j];
00093           mCodingSM[j] = t;
00094         }
00095       }
00096       else if (codingState == eItsMe)
00097       {
00098         mState = eFoundIt;
00099         mDetectedCharset = mCodingSM[j]->GetCodingStateMachine();
00100         return mState;
00101       }
00102     }
00103   }
00104 
00105   return mState;
00106 }

Here is the call graph for this function:

void nsEscCharSetProber::Reset ( void   )  [virtual]

Implements nsCharSetProber.

Definition at line 58 of file nsEscCharsetProber.cpp.

References eDetecting, mActiveSM, mCodingSM, mDetectedCharset, mState, nsnull, and NUM_OF_ESC_CHARSETS.

00059 {
00060   mState = eDetecting;
00061   for (PRUint32 i = 0; i < NUM_OF_ESC_CHARSETS; i++)
00062     mCodingSM[i]->Reset();
00063   mActiveSM = NUM_OF_ESC_CHARSETS;
00064   mDetectedCharset = nsnull;
00065 }

void nsEscCharSetProber::SetOpion (  )  [inline, virtual]

Implements nsCharSetProber.

Definition at line 55 of file nsEscCharsetProber.h.

00055 {};


Field Documentation

Definition at line 61 of file nsEscCharsetProber.h.

Referenced by HandleData(), nsEscCharSetProber(), and Reset().

nsCodingStateMachine* nsEscCharSetProber::mCodingSM[NUM_OF_ESC_CHARSETS] [protected]

Definition at line 60 of file nsEscCharsetProber.h.

Referenced by HandleData(), nsEscCharSetProber(), Reset(), and ~nsEscCharSetProber().

const char* nsEscCharSetProber::mDetectedCharset [protected]

Definition at line 63 of file nsEscCharsetProber.h.

Referenced by GetCharSetName(), HandleData(), nsEscCharSetProber(), and Reset().

Definition at line 62 of file nsEscCharsetProber.h.

Referenced by GetState(), HandleData(), nsEscCharSetProber(), and Reset().


The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.2-20100208