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