#include <nsBig5Prober.h>
Public Member Functions | |
nsBig5Prober (void) | |
virtual | ~nsBig5Prober (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 | |
nsCodingStateMachine * | mCodingSM |
nsProbingState | mState |
Big5DistributionAnalysis | mDistributionAnalyser |
char | mLastChar [2] |
Definition at line 45 of file nsBig5Prober.h.
nsBig5Prober::nsBig5Prober | ( | void | ) | [inline] |
Definition at line 46 of file nsBig5Prober.h.
References Big5SMModel, and mCodingSM.
00047 : nsBig5Prober(void){mCodingSM = new nsCodingStateMachine(&Big5SMModel);
virtual nsBig5Prober::~nsBig5Prober | ( | void | ) | [inline, virtual] |
Definition at line 48 of file nsBig5Prober.h.
00049 {delete mCodingSM;};
const char* nsBig5Prober::GetCharSetName | ( | ) | [inline, virtual] |
float nsBig5Prober::GetConfidence | ( | void | ) | [virtual] |
Implements nsCharSetProber.
Definition at line 87 of file nsBig5Prober.cpp.
References CharDistributionAnalysis::GetConfidence(), and mDistributionAnalyser.
Referenced by HandleData().
00088 { 00089 float distribCf = mDistributionAnalyser.GetConfidence(); 00090 00091 return (float)distribCf; 00092 }
void nsBig5Prober::GetDistribution | ( | PRUint32 | aCharLen, | |
const char * | aStr | |||
) | [protected] |
nsProbingState nsBig5Prober::GetState | ( | void | ) | [inline, virtual] |
nsProbingState nsBig5Prober::HandleData | ( | const char * | aBuf, | |
PRUint32 | aLen | |||
) | [virtual] |
Implements nsCharSetProber.
Definition at line 47 of file nsBig5Prober.cpp.
References eDetecting, eError, eFoundIt, eItsMe, eNotMe, eStart, GetConfidence(), nsCodingStateMachine::GetCurrentCharLen(), CharDistributionAnalysis::GotEnoughData(), CharDistributionAnalysis::HandleOneChar(), mCodingSM, mDistributionAnalyser, mLastChar, 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 PRUint32 charLen = mCodingSM->GetCurrentCharLen(); 00067 00068 if (i == 0) 00069 { 00070 mLastChar[1] = aBuf[0]; 00071 mDistributionAnalyser.HandleOneChar(mLastChar, charLen); 00072 } 00073 else 00074 mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen); 00075 } 00076 } 00077 00078 mLastChar[0] = aBuf[aLen-1]; 00079 00080 if (mState == eDetecting) 00081 if (mDistributionAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) 00082 mState = eFoundIt; 00083 00084 return mState; 00085 }
void nsBig5Prober::Reset | ( | void | ) | [virtual] |
Implements nsCharSetProber.
Definition at line 40 of file nsBig5Prober.cpp.
References eDetecting, mCodingSM, mDistributionAnalyser, mState, CharDistributionAnalysis::Reset(), and nsCodingStateMachine::Reset().
00041 { 00042 mCodingSM->Reset(); 00043 mState = eDetecting; 00044 mDistributionAnalyser.Reset(); 00045 }
void nsBig5Prober::SetOpion | ( | ) | [inline, virtual] |
nsCodingStateMachine* nsBig5Prober::mCodingSM [protected] |
Definition at line 59 of file nsBig5Prober.h.
Referenced by HandleData(), nsBig5Prober(), and Reset().
Definition at line 63 of file nsBig5Prober.h.
Referenced by GetConfidence(), HandleData(), and Reset().
char nsBig5Prober::mLastChar[2] [protected] |
Definition at line 64 of file nsBig5Prober.h.
Referenced by HandleData().
nsProbingState nsBig5Prober::mState [protected] |
Definition at line 60 of file nsBig5Prober.h.
Referenced by HandleData(), and Reset().