| 1 |
// © 2016 and later: Unicode, Inc. and others. |
| 2 |
// License & terms of use: http://www.unicode.org/copyright.html |
| 3 |
/* |
| 4 |
********************************************************************** |
| 5 |
* Copyright (C) 2005-2012, International Business Machines |
| 6 |
* Corporation and others. All Rights Reserved. |
| 7 |
********************************************************************** |
| 8 |
*/ |
| 9 |
|
| 10 |
#ifndef __CSMATCH_H |
| 11 |
#define __CSMATCH_H |
| 12 |
|
| 13 |
#include "unicode/uobject.h" |
| 14 |
|
| 15 |
#if !UCONFIG_NO_CONVERSION |
| 16 |
|
| 17 |
U_NAMESPACE_BEGIN |
| 18 |
|
| 19 |
class InputText; |
| 20 |
class CharsetRecognizer; |
| 21 |
|
| 22 |
/* |
| 23 |
* CharsetMatch represents the results produced by one Charset Recognizer for one input text |
| 24 |
* Any confidence > 0 indicates a possible match, meaning that the input bytes |
| 25 |
* are at least legal. |
| 26 |
* |
| 27 |
* The full results of a detect are represented by an array of these |
| 28 |
* CharsetMatch objects, each representing a possible matching charset. |
| 29 |
* |
| 30 |
* Note that a single charset recognizer may detect multiple closely related |
| 31 |
* charsets, and set different names depending on the exact input bytes seen. |
| 32 |
*/ |
| 33 |
class CharsetMatch : public UMemory |
| 34 |
{ |
| 35 |
private: |
| 36 |
InputText *textIn; |
| 37 |
int32_t confidence; |
| 38 |
const char *fCharsetName; |
| 39 |
const char *fLang; |
| 40 |
|
| 41 |
public: |
| 42 |
CharsetMatch(); |
| 43 |
|
| 44 |
/** |
| 45 |
* fully set the state of this CharsetMatch. |
| 46 |
* Called by the CharsetRecognizers to record match results. |
| 47 |
* Default (nullptr) parameters for names will be filled by calling the |
| 48 |
* corresponding getters on the recognizer. |
| 49 |
*/ |
| 50 |
void set(InputText *input, |
| 51 |
const CharsetRecognizer *cr, |
| 52 |
int32_t conf, |
| 53 |
const char *csName=nullptr, |
| 54 |
const char *lang=nullptr); |
| 55 |
|
| 56 |
/** |
| 57 |
* Return the name of the charset for this Match |
| 58 |
*/ |
| 59 |
const char *getName() const; |
| 60 |
|
| 61 |
const char *getLanguage()const; |
| 62 |
|
| 63 |
int32_t getConfidence()const; |
| 64 |
|
| 65 |
int32_t getUChars(char16_t *buf, int32_t cap, UErrorCode *status) const; |
| 66 |
}; |
| 67 |
|
| 68 |
U_NAMESPACE_END |
| 69 |
|
| 70 |
#endif |
| 71 |
#endif /* __CSMATCH_H */ |