HFile.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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_HFILE
  8. #define HCPP_HFILE
  9. namespace HalconCpp
  10. {
  11. // Represents an instance of a file.
  12. class LIntExport HFile : public HHandle
  13. {
  14. public:
  15. // Create an uninitialized instance
  16. HFile():HHandle() {}
  17. // Copy constructor
  18. HFile(const HFile& source) : HHandle(source) {}
  19. // Copy constructor
  20. HFile(const HHandle& handle);
  21. // Create HFile from handle, taking ownership
  22. explicit HFile(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 ('file')!
  33. virtual void AssertType(Hphandle handle) const;
  34. public:
  35. /*****************************************************************************
  36. * Operator-based class constructors
  37. *****************************************************************************/
  38. // open_file: Open a file in text or binary format.
  39. explicit HFile(const HString& FileName, const HTuple& FileType);
  40. // open_file: Open a file in text or binary format.
  41. explicit HFile(const HString& FileName, const HString& FileType);
  42. // open_file: Open a file in text or binary format.
  43. explicit HFile(const char* FileName, const char* FileType);
  44. #ifdef _WIN32
  45. // open_file: Open a file in text or binary format.
  46. explicit HFile(const wchar_t* FileName, const wchar_t* FileType);
  47. #endif
  48. /***************************************************************************
  49. * Operators *
  50. ***************************************************************************/
  51. // Open a file in text or binary format.
  52. void OpenFile(const HString& FileName, const HTuple& FileType);
  53. // Open a file in text or binary format.
  54. void OpenFile(const HString& FileName, const HString& FileType);
  55. // Open a file in text or binary format.
  56. void OpenFile(const char* FileName, const char* FileType);
  57. #ifdef _WIN32
  58. // Open a file in text or binary format.
  59. void OpenFile(const wchar_t* FileName, const wchar_t* FileType);
  60. #endif
  61. // Write strings and numbers into a text file.
  62. void FwriteString(const HTuple& String) const;
  63. // Write strings and numbers into a text file.
  64. void FwriteString(const HString& String) const;
  65. // Write strings and numbers into a text file.
  66. void FwriteString(const char* String) const;
  67. #ifdef _WIN32
  68. // Write strings and numbers into a text file.
  69. void FwriteString(const wchar_t* String) const;
  70. #endif
  71. // Read a character line from a text file.
  72. HString FreadLine(Hlong* IsEOF) const;
  73. // Read a string from a text file.
  74. HString FreadString(Hlong* IsEOF) const;
  75. // Read one character from a text file.
  76. HString FreadChar() const;
  77. // Write a line break and clear the output buffer.
  78. void FnewLine() const;
  79. // Closing a text file.
  80. static void CloseFile(const HFileArray& FileHandle);
  81. // Closing a text file.
  82. void CloseFile() const;
  83. // Read bytes from a binary file.
  84. HTuple FreadBytes(Hlong NumberOfBytes, Hlong* IsEOF) const;
  85. // Write bytes to a binary file.
  86. Hlong FwriteBytes(const HTuple& DataToWrite) const;
  87. };
  88. // forward declarations and types for internal array implementation
  89. template<class T> class HSmartPtr;
  90. template<class T> class HHandleBaseArrayRef;
  91. typedef HHandleBaseArrayRef<HFile> HFileArrayRef;
  92. typedef HSmartPtr< HFileArrayRef > HFileArrayPtr;
  93. // Represents multiple tool instances
  94. class LIntExport HFileArray : public HHandleBaseArray
  95. {
  96. public:
  97. // Create empty array
  98. HFileArray();
  99. // Create array from native array of tool instances
  100. HFileArray(HFile* classes, Hlong length);
  101. // Copy constructor
  102. HFileArray(const HFileArray &tool_array);
  103. // Destructor
  104. virtual ~HFileArray();
  105. // Assignment operator
  106. HFileArray &operator=(const HFileArray &tool_array);
  107. // Clears array and all tool instances
  108. virtual void Clear();
  109. // Get array of native tool instances
  110. const HFile* Tools() const;
  111. // Get number of tools
  112. virtual Hlong Length() const;
  113. // Create tool array from tuple of handles
  114. virtual void SetFromTuple(const HTuple& handles);
  115. // Get tuple of handles for tool array
  116. virtual HTuple ConvertToTuple() const;
  117. protected:
  118. // Smart pointer to internal data container
  119. HFileArrayPtr *mArrayPtr;
  120. };
  121. }
  122. #endif