extensions/universalchardet/src/base/nsCharSetProber.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/extensions/universalchardet/src/base/nsCharSetProber.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,42 @@
     1.4 +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +#ifndef nsCharSetProber_h__
     1.9 +#define nsCharSetProber_h__
    1.10 +
    1.11 +#include "nscore.h"
    1.12 +
    1.13 +//#define DEBUG_chardet // Uncomment this for debug dump.
    1.14 +
    1.15 +typedef enum {
    1.16 +  eDetecting = 0,   //We are still detecting, no sure answer yet, but caller can ask for confidence.
    1.17 +  eFoundIt = 1,     //That's a positive answer
    1.18 +  eNotMe = 2        //Negative answer
    1.19 +} nsProbingState;
    1.20 +
    1.21 +#define SHORTCUT_THRESHOLD      (float)0.95
    1.22 +
    1.23 +class nsCharSetProber {
    1.24 +public:
    1.25 +  virtual ~nsCharSetProber() {}
    1.26 +  virtual const char* GetCharSetName() = 0;
    1.27 +  virtual nsProbingState HandleData(const char* aBuf, uint32_t aLen) = 0;
    1.28 +  virtual nsProbingState GetState(void) = 0;
    1.29 +  virtual void      Reset(void)  = 0;
    1.30 +  virtual float     GetConfidence(void) = 0;
    1.31 +
    1.32 +#ifdef DEBUG_chardet
    1.33 +  virtual void  DumpStatus() {};
    1.34 +#endif
    1.35 +
    1.36 +  // Helper functions used in the Latin1 and Group probers.
    1.37 +  // both functions Allocate a new buffer for newBuf. This buffer should be 
    1.38 +  // freed by the caller using PR_FREEIF.
    1.39 +  // Both functions return false in case of memory allocation failure.
    1.40 +  static bool FilterWithoutEnglishLetters(const char* aBuf, uint32_t aLen, char** newBuf, uint32_t& newLen);
    1.41 +  static bool FilterWithEnglishLetters(const char* aBuf, uint32_t aLen, char** newBuf, uint32_t& newLen);
    1.42 +
    1.43 +};
    1.44 +
    1.45 +#endif /* nsCharSetProber_h__ */

mercurial