Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Attributes | Private Attributes
nsSimpleStatis Class Reference
Inheritance diagram for nsSimpleStatis:
Inheritance graph
[legend]
Collaboration diagram for nsSimpleStatis:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsSimpleStatis (unsigned char aL, unsigned char aH, float aR, const char *aCharset)
virtual ~nsSimpleStatis ()
virtual PRBool HandleData (const char *aBuf, PRUint32 aLen)
virtual void DataEnd ()
virtual void Report ()

Protected Attributes

unsigned char mLWordHi
unsigned char mLWordLo

Private Attributes

PRUint32 mNumOf2Bytes
PRUint32 mNumOfLChar
float mR
const char * mCharset
PRBool mTailByte

Detailed Description

Definition at line 177 of file DetectCharset.cpp.


Constructor & Destructor Documentation

nsSimpleStatis::nsSimpleStatis ( unsigned char  aL,
unsigned char  aH,
float  aR,
const char *  aCharset 
)

Definition at line 194 of file DetectCharset.cpp.

{
    mNumOf2Bytes =  mNumOfLChar= 0;
    mTailByte =  PR_FALSE;
    mLWordHi = aH;
    mLWordLo = aL;
    mR = aR;
    mCharset = aCharset;
}
virtual nsSimpleStatis::~nsSimpleStatis ( ) [inline, virtual]

Definition at line 180 of file DetectCharset.cpp.

{};

Member Function Documentation

Implements nsStatis.

Definition at line 224 of file DetectCharset.cpp.

{
}
PRBool nsSimpleStatis::HandleData ( const char *  aBuf,
PRUint32  aLen 
) [virtual]

Implements nsStatis.

Definition at line 203 of file DetectCharset.cpp.

{
    for(PRUint32 i=0; i < aLen; i++)
    {
       if(mTailByte)
          mTailByte = PR_FALSE;
       else 
       {
          mTailByte = (0x80 == ( aBuf[i] & 0x80));
          if(mTailByte) 
          {
             mNumOf2Bytes++;
             unsigned char a = (unsigned char) aBuf[i];
             PRBool thisLChar = (( mLWordLo <= a) && (a <= mLWordHi));
             if(thisLChar)
                mNumOfLChar++;
          }
       }
    }
    return PR_TRUE;
}

Implements nsStatis.

Definition at line 227 of file DetectCharset.cpp.

{
    if(mNumOf2Bytes > 0)
    {
      float rate = (float) mNumOfLChar / (float) mNumOf2Bytes;
      float delta = (rate - mR) / mR;
      delta = delta * delta * (float)100;
#ifdef EXPERIMENT
      printf("Exp = %f \n",delta);
      if(delta < 1.0)
         printf("This is %s\n" ,mCharset);
#endif

    }
}

Member Data Documentation

Definition at line 191 of file DetectCharset.cpp.

unsigned char nsSimpleStatis::mLWordHi [protected]

Definition at line 185 of file DetectCharset.cpp.

unsigned char nsSimpleStatis::mLWordLo [protected]

Definition at line 186 of file DetectCharset.cpp.

Definition at line 188 of file DetectCharset.cpp.

Definition at line 189 of file DetectCharset.cpp.

float nsSimpleStatis::mR [private]

Definition at line 190 of file DetectCharset.cpp.

Definition at line 192 of file DetectCharset.cpp.


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