nsUTF8Prober Class Reference

#include <nsUTF8Prober.h>

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

Public Member Functions

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

Protected Attributes

nsCodingStateMachinemCodingSM
nsProbingState mState
PRUint32 mNumOfMBChar

Detailed Description

Definition at line 44 of file nsUTF8Prober.h.


Constructor & Destructor Documentation

nsUTF8Prober::nsUTF8Prober (  )  [inline]

Definition at line 46 of file nsUTF8Prober.h.

References mCodingSM, mNumOfMBChar, Reset(), and UTF8SMModel.

00046                 {mNumOfMBChar = 0; 
00047                 mCodingSM = new nsCodingStateMachine(&UTF8SMModel);
00048                 Reset(); };

Here is the call graph for this function:

virtual nsUTF8Prober::~nsUTF8Prober (  )  [inline, virtual]

Definition at line 49 of file nsUTF8Prober.h.

References mCodingSM.

00049 {delete mCodingSM;};


Member Function Documentation

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

Implements nsCharSetProber.

Definition at line 51 of file nsUTF8Prober.h.

00051 {return "UTF-8";};

float nsUTF8Prober::GetConfidence ( void   )  [virtual]

Implements nsCharSetProber.

Definition at line 79 of file nsUTF8Prober.cpp.

References mNumOfMBChar, and ONE_CHAR_PROB.

Referenced by HandleData().

00080 {
00081   float unlike = (float)0.99;
00082 
00083   if (mNumOfMBChar < 6)
00084   {
00085     for (PRUint32 i = 0; i < mNumOfMBChar; i++)
00086       unlike *= ONE_CHAR_PROB;
00087     return (float)1.0 - unlike;
00088   }
00089   else
00090     return (float)0.99;
00091 }

Here is the caller graph for this function:

nsProbingState nsUTF8Prober::GetState ( void   )  [inline, virtual]

Implements nsCharSetProber.

Definition at line 52 of file nsUTF8Prober.h.

References mState.

00052 {return mState;};

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

Implements nsCharSetProber.

Definition at line 47 of file nsUTF8Prober.cpp.

References eDetecting, eError, eFoundIt, eItsMe, eNotMe, eStart, GetConfidence(), nsCodingStateMachine::GetCurrentCharLen(), mCodingSM, mNumOfMBChar, mState, nsCodingStateMachine::NextState(), and SHORTCUT_THRESHOLD.

00048 {
00049   nsSMState codingState;
00050 
00051   for (PRUint32 i = 0; i < aLen; i++)
00052   {
00053     codingState = mCodingSM->NextState(aBuf[i]);
00054     if (codingState == eError)
00055     {
00056       mState = eNotMe;
00057       break;
00058     }
00059     if (codingState == eItsMe)
00060     {
00061       mState = eFoundIt;
00062       break;
00063     }
00064     if (codingState == eStart)
00065     {
00066       if (mCodingSM->GetCurrentCharLen() >= 2)
00067         mNumOfMBChar++;
00068     }
00069   }
00070 
00071   if (mState == eDetecting)
00072     if (GetConfidence() > SHORTCUT_THRESHOLD)
00073       mState = eFoundIt;
00074   return mState;
00075 }

Here is the call graph for this function:

void nsUTF8Prober::Reset ( void   )  [virtual]

Implements nsCharSetProber.

Definition at line 40 of file nsUTF8Prober.cpp.

References eDetecting, mCodingSM, mNumOfMBChar, mState, and nsCodingStateMachine::Reset().

Referenced by nsUTF8Prober().

00041 {
00042   mCodingSM->Reset(); 
00043   mNumOfMBChar = 0;
00044   mState = eDetecting;
00045 }

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements nsCharSetProber.

Definition at line 55 of file nsUTF8Prober.h.

00055 {};


Field Documentation

Definition at line 55 of file nsUTF8Prober.h.

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

Definition at line 60 of file nsUTF8Prober.h.

Referenced by GetConfidence(), HandleData(), nsUTF8Prober(), and Reset().

Definition at line 59 of file nsUTF8Prober.h.

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


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