extensions/universalchardet/src/base/nsUniversalDetector.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #ifndef nsUniversalDetector_h__
     7 #define nsUniversalDetector_h__
     9 class nsCharSetProber;
    11 #define NUM_OF_CHARSET_PROBERS  3
    13 typedef enum {
    14   ePureAscii = 0,
    15   eEscAscii  = 1,
    16   eHighbyte  = 2
    17 } nsInputState;
    19 #define NS_FILTER_CHINESE_SIMPLIFIED  0x01
    20 #define NS_FILTER_CHINESE_TRADITIONAL 0x02
    21 #define NS_FILTER_JAPANESE            0x04
    22 #define NS_FILTER_KOREAN              0x08
    23 #define NS_FILTER_NON_CJK             0x10
    24 #define NS_FILTER_ALL                 0x1F
    25 #define NS_FILTER_CHINESE (NS_FILTER_CHINESE_SIMPLIFIED | \
    26                            NS_FILTER_CHINESE_TRADITIONAL)
    27 #define NS_FILTER_CJK (NS_FILTER_CHINESE_SIMPLIFIED | \
    28                        NS_FILTER_CHINESE_TRADITIONAL | \
    29                        NS_FILTER_JAPANESE | \
    30                        NS_FILTER_KOREAN)
    32 class nsUniversalDetector {
    33 public:
    34    nsUniversalDetector(uint32_t aLanguageFilter);
    35    virtual ~nsUniversalDetector();
    36    virtual nsresult HandleData(const char* aBuf, uint32_t aLen);
    37    virtual void DataEnd(void);
    39 protected:
    40    virtual void Report(const char* aCharset) = 0;
    41    virtual void Reset();
    42    nsInputState  mInputState;
    43    bool    mDone;
    44    bool    mInTag;
    45    bool    mStart;
    46    bool    mGotData;
    47    char    mLastChar;
    48    const char *  mDetectedCharset;
    49    int32_t mBestGuess;
    50    uint32_t mLanguageFilter;
    52    nsCharSetProber  *mCharSetProbers[NUM_OF_CHARSET_PROBERS];
    53    nsCharSetProber  *mEscCharSetProber;
    54 };
    56 #endif

mercurial