extensions/universalchardet/src/base/nsCharSetProber.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: 4; 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/. */
     5 #ifndef nsCharSetProber_h__
     6 #define nsCharSetProber_h__
     8 #include "nscore.h"
    10 //#define DEBUG_chardet // Uncomment this for debug dump.
    12 typedef enum {
    13   eDetecting = 0,   //We are still detecting, no sure answer yet, but caller can ask for confidence.
    14   eFoundIt = 1,     //That's a positive answer
    15   eNotMe = 2        //Negative answer
    16 } nsProbingState;
    18 #define SHORTCUT_THRESHOLD      (float)0.95
    20 class nsCharSetProber {
    21 public:
    22   virtual ~nsCharSetProber() {}
    23   virtual const char* GetCharSetName() = 0;
    24   virtual nsProbingState HandleData(const char* aBuf, uint32_t aLen) = 0;
    25   virtual nsProbingState GetState(void) = 0;
    26   virtual void      Reset(void)  = 0;
    27   virtual float     GetConfidence(void) = 0;
    29 #ifdef DEBUG_chardet
    30   virtual void  DumpStatus() {};
    31 #endif
    33   // Helper functions used in the Latin1 and Group probers.
    34   // both functions Allocate a new buffer for newBuf. This buffer should be 
    35   // freed by the caller using PR_FREEIF.
    36   // Both functions return false in case of memory allocation failure.
    37   static bool FilterWithoutEnglishLetters(const char* aBuf, uint32_t aLen, char** newBuf, uint32_t& newLen);
    38   static bool FilterWithEnglishLetters(const char* aBuf, uint32_t aLen, char** newBuf, uint32_t& newLen);
    40 };
    42 #endif /* nsCharSetProber_h__ */

mercurial