#include <nsEUCTWProber.h>
Public Member Functions | |
nsEUCTWProber (void) | |
virtual | ~nsEUCTWProber (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 |
EUCTWDistributionAnalysis | mDistributionAnalyser |
char | mLastChar [2] |
Definition at line 45 of file nsEUCTWProber.h.
nsEUCTWProber::nsEUCTWProber | ( | void | ) | [inline] |
Definition at line 47 of file nsEUCTWProber.h.
References EUCTWSMModel, mCodingSM, and Reset().
00047 {mCodingSM = new nsCodingStateMachine(&EUCTWSMModel); 00048 Reset();};
virtual nsEUCTWProber::~nsEUCTWProber | ( | void | ) | [inline, virtual] |
const char* nsEUCTWProber::GetCharSetName | ( | ) | [inline, virtual] |
Implements nsCharSetProber.
Definition at line 51 of file nsEUCTWProber.h.
float nsEUCTWProber::GetConfidence | ( | void | ) | [virtual] |
Implements nsCharSetProber.
Definition at line 90 of file nsEUCTWProber.cpp.
References CharDistributionAnalysis::GetConfidence(), and mDistributionAnalyser.
Referenced by HandleData().
00091 { 00092 float distribCf = mDistributionAnalyser.GetConfidence(); 00093 00094 return (float)distribCf; 00095 }
void nsEUCTWProber::GetDistribution | ( | PRUint32 | aCharLen, | |
const char * | aStr | |||
) | [protected] |
nsProbingState nsEUCTWProber::GetState | ( | void | ) | [inline, virtual] |
Implements nsCharSetProber.
Definition at line 52 of file nsEUCTWProber.h.
References mState.
00052 {return mState;};
nsProbingState nsEUCTWProber::HandleData | ( | const char * | aBuf, | |
PRUint32 | aLen | |||
) | [virtual] |
Implements nsCharSetProber.
Definition at line 48 of file nsEUCTWProber.cpp.
References eDetecting, eError, eFoundIt, eItsMe, eNotMe, eStart, GetConfidence(), nsCodingStateMachine::GetCurrentCharLen(), CharDistributionAnalysis::GotEnoughData(), CharDistributionAnalysis::HandleOneChar(), mCodingSM, mDistributionAnalyser, mLastChar, mState, nsCodingStateMachine::NextState(), and SHORTCUT_THRESHOLD.
00049 { 00050 nsSMState codingState; 00051 00052 for (PRUint32 i = 0; i < aLen; i++) 00053 { 00054 codingState = mCodingSM->NextState(aBuf[i]); 00055 if (codingState == eError) 00056 { 00057 mState = eNotMe; 00058 break; 00059 } 00060 if (codingState == eItsMe) 00061 { 00062 mState = eFoundIt; 00063 break; 00064 } 00065 if (codingState == eStart) 00066 { 00067 PRUint32 charLen = mCodingSM->GetCurrentCharLen(); 00068 00069 if (i == 0) 00070 { 00071 mLastChar[1] = aBuf[0]; 00072 mDistributionAnalyser.HandleOneChar(mLastChar, charLen); 00073 } 00074 else 00075 mDistributionAnalyser.HandleOneChar(aBuf+i-1, charLen); 00076 } 00077 } 00078 00079 mLastChar[0] = aBuf[aLen-1]; 00080 00081 if (mState == eDetecting) 00082 if (mDistributionAnalyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD) 00083 mState = eFoundIt; 00084 // else 00085 // mDistributionAnalyser.HandleData(aBuf, aLen); 00086 00087 return mState; 00088 }
void nsEUCTWProber::Reset | ( | void | ) | [virtual] |
Implements nsCharSetProber.
Definition at line 40 of file nsEUCTWProber.cpp.
References eDetecting, mCodingSM, mDistributionAnalyser, mState, CharDistributionAnalysis::Reset(), and nsCodingStateMachine::Reset().
Referenced by nsEUCTWProber().
00041 { 00042 mCodingSM->Reset(); 00043 mState = eDetecting; 00044 mDistributionAnalyser.Reset(); 00045 //mContextAnalyser.Reset(); 00046 }
void nsEUCTWProber::SetOpion | ( | ) | [inline, virtual] |
nsCodingStateMachine* nsEUCTWProber::mCodingSM [protected] |
Definition at line 60 of file nsEUCTWProber.h.
Referenced by HandleData(), nsEUCTWProber(), Reset(), and ~nsEUCTWProber().
Definition at line 64 of file nsEUCTWProber.h.
Referenced by GetConfidence(), HandleData(), and Reset().
char nsEUCTWProber::mLastChar[2] [protected] |
Definition at line 65 of file nsEUCTWProber.h.
Referenced by HandleData().
nsProbingState nsEUCTWProber::mState [protected] |
Definition at line 61 of file nsEUCTWProber.h.
Referenced by GetState(), HandleData(), and Reset().