HLexicon.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /***********************************************************
  2. * File generated by the HALCON-Compiler hcomp version 20.11
  3. * Usage: Interface to C++
  4. *
  5. * Software by: MVTec Software GmbH, www.mvtec.com
  6. ***********************************************************/
  7. #ifndef HCPP_HLEXICON
  8. #define HCPP_HLEXICON
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of a lexicon.
  12. class LIntExport HLexicon : public HHandle
  13. {
  14. public:
  15. // Create an uninitialized instance
  16. HLexicon():HHandle() {}
  17. // Copy constructor
  18. HLexicon(const HLexicon& source) : HHandle(source) {}
  19. // Copy constructor
  20. HLexicon(const HHandle& handle);
  21. // Create HLexicon from handle, taking ownership
  22. explicit HLexicon(Hlong handle);
  23. bool operator==(const HHandle& obj) const
  24. {
  25. return HHandleBase::operator==(obj);
  26. }
  27. bool operator!=(const HHandle& obj) const
  28. {
  29. return HHandleBase::operator!=(obj);
  30. }
  31. protected:
  32. // Verify matching semantic type ('lexicon')!
  33. virtual void AssertType(Hphandle handle) const;
  34. public:
  35. /*****************************************************************************
  36. * Operator-based class constructors
  37. *****************************************************************************/
  38. // import_lexicon: Create a lexicon from a text file.
  39. explicit HLexicon(const HString& Name, const HString& FileName);
  40. // import_lexicon: Create a lexicon from a text file.
  41. explicit HLexicon(const char* Name, const char* FileName);
  42. #ifdef _WIN32
  43. // import_lexicon: Create a lexicon from a text file.
  44. explicit HLexicon(const wchar_t* Name, const wchar_t* FileName);
  45. #endif
  46. // create_lexicon: Create a lexicon from a tuple of words.
  47. explicit HLexicon(const HString& Name, const HTuple& Words);
  48. // create_lexicon: Create a lexicon from a tuple of words.
  49. explicit HLexicon(const char* Name, const HTuple& Words);
  50. #ifdef _WIN32
  51. // create_lexicon: Create a lexicon from a tuple of words.
  52. explicit HLexicon(const wchar_t* Name, const HTuple& Words);
  53. #endif
  54. /***************************************************************************
  55. * Operators *
  56. ***************************************************************************/
  57. // Clear a lexicon.
  58. void ClearLexicon() const;
  59. // Find a similar word in a lexicon.
  60. HString SuggestLexicon(const HString& Word, Hlong* NumCorrections) const;
  61. // Find a similar word in a lexicon.
  62. HString SuggestLexicon(const char* Word, Hlong* NumCorrections) const;
  63. #ifdef _WIN32
  64. // Find a similar word in a lexicon.
  65. HString SuggestLexicon(const wchar_t* Word, Hlong* NumCorrections) const;
  66. #endif
  67. // Check if a word is contained in a lexicon.
  68. Hlong LookupLexicon(const HString& Word) const;
  69. // Check if a word is contained in a lexicon.
  70. Hlong LookupLexicon(const char* Word) const;
  71. #ifdef _WIN32
  72. // Check if a word is contained in a lexicon.
  73. Hlong LookupLexicon(const wchar_t* Word) const;
  74. #endif
  75. // Query all words from a lexicon.
  76. HTuple InspectLexicon() const;
  77. // Create a lexicon from a text file.
  78. void ImportLexicon(const HString& Name, const HString& FileName);
  79. // Create a lexicon from a text file.
  80. void ImportLexicon(const char* Name, const char* FileName);
  81. #ifdef _WIN32
  82. // Create a lexicon from a text file.
  83. void ImportLexicon(const wchar_t* Name, const wchar_t* FileName);
  84. #endif
  85. // Create a lexicon from a tuple of words.
  86. void CreateLexicon(const HString& Name, const HTuple& Words);
  87. // Create a lexicon from a tuple of words.
  88. void CreateLexicon(const char* Name, const HTuple& Words);
  89. #ifdef _WIN32
  90. // Create a lexicon from a tuple of words.
  91. void CreateLexicon(const wchar_t* Name, const HTuple& Words);
  92. #endif
  93. };
  94. // forward declarations and types for internal array implementation
  95. template<class T> class HSmartPtr;
  96. template<class T> class HHandleBaseArrayRef;
  97. typedef HHandleBaseArrayRef<HLexicon> HLexiconArrayRef;
  98. typedef HSmartPtr< HLexiconArrayRef > HLexiconArrayPtr;
  99. // Represents multiple tool instances
  100. class LIntExport HLexiconArray : public HHandleBaseArray
  101. {
  102. public:
  103. // Create empty array
  104. HLexiconArray();
  105. // Create array from native array of tool instances
  106. HLexiconArray(HLexicon* classes, Hlong length);
  107. // Copy constructor
  108. HLexiconArray(const HLexiconArray &tool_array);
  109. // Destructor
  110. virtual ~HLexiconArray();
  111. // Assignment operator
  112. HLexiconArray &operator=(const HLexiconArray &tool_array);
  113. // Clears array and all tool instances
  114. virtual void Clear();
  115. // Get array of native tool instances
  116. const HLexicon* Tools() const;
  117. // Get number of tools
  118. virtual Hlong Length() const;
  119. // Create tool array from tuple of handles
  120. virtual void SetFromTuple(const HTuple& handles);
  121. // Get tuple of handles for tool array
  122. virtual HTuple ConvertToTuple() const;
  123. protected:
  124. // Smart pointer to internal data container
  125. HLexiconArrayPtr *mArrayPtr;
  126. };
  127. }
  128. #endif