csmatch.h 2.1 KB

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