| 1 | /* -*- C++ -*- |
|---|---|
| 2 | SPDX-FileCopyrightText: 2008 Wang Kai <wkai@gmail.com> |
| 3 | |
| 4 | SPDX-License-Identifier: MIT |
| 5 | */ |
| 6 | |
| 7 | #ifndef UNICODEGROUPPROBER_H |
| 8 | #define UNICODEGROUPPROBER_H |
| 9 | |
| 10 | #include "nsCharSetProber.h" |
| 11 | #include "nsCodingStateMachine.h" |
| 12 | |
| 13 | #define NUM_OF_UNICODE_CHARSETS 3 |
| 14 | namespace kencodingprober |
| 15 | { |
| 16 | class KCODECS_NO_EXPORT UnicodeGroupProber : public nsCharSetProber |
| 17 | { |
| 18 | public: |
| 19 | UnicodeGroupProber(void); |
| 20 | ~UnicodeGroupProber(void) override; |
| 21 | nsProbingState HandleData(const char *aBuf, unsigned int aLen) override; |
| 22 | const char *GetCharSetName() override |
| 23 | { |
| 24 | return mDetectedCharset; |
| 25 | } |
| 26 | nsProbingState GetState(void) override |
| 27 | { |
| 28 | return mState; |
| 29 | } |
| 30 | void Reset(void) override; |
| 31 | float GetConfidence() override; |
| 32 | #ifdef DEBUG_PROBE |
| 33 | void DumpStatus() override; |
| 34 | #endif |
| 35 | |
| 36 | protected: |
| 37 | void GetDistribution(unsigned int aCharLen, const char *aStr); |
| 38 | |
| 39 | nsCodingStateMachine *mCodingSM[NUM_OF_UNICODE_CHARSETS]; |
| 40 | unsigned int mActiveSM; |
| 41 | nsProbingState mState; |
| 42 | const char *mDetectedCharset; |
| 43 | }; |
| 44 | } |
| 45 | #endif /* UNICODEGROUPPROBER_H */ |
| 46 |
