EnumEntry.hpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*=============================================================================
  2. Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
  3. Redistribution of this file, in original or modified form, without
  4. prior written consent of Allied Vision Technologies is prohibited.
  5. -------------------------------------------------------------------------------
  6. File: EnumEntry.hpp
  7. Description: Inline wrapper functions for class AVT::VmbAPI::EnumEntry.
  8. -------------------------------------------------------------------------------
  9. THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  10. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
  11. NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  12. DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  13. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  16. AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  17. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  18. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19. =============================================================================*/
  20. #ifndef AVT_VMBAPI_ENUMENTRY_HPP
  21. #define AVT_VMBAPI_ENUMENTRY_HPP
  22. //
  23. // Inline wrapper functions that allocate memory for STL objects in the application's context
  24. // and to pass data across DLL boundaries using arrays
  25. //
  26. inline VmbErrorType EnumEntry::GetName( std::string &rStrName ) const
  27. {
  28. VmbErrorType res;
  29. VmbUint32_t nLength;
  30. res = GetName( NULL, nLength );
  31. if ( VmbErrorSuccess == res )
  32. {
  33. if ( 0 != nLength )
  34. {
  35. try
  36. {
  37. std::vector<std::string::value_type> tmpName( nLength + 1, '\0' );
  38. res = GetName( &tmpName[0], nLength );
  39. if ( VmbErrorSuccess == res )
  40. {
  41. rStrName = &*tmpName.begin();
  42. }
  43. }
  44. catch(...)
  45. {
  46. return VmbErrorResources;
  47. }
  48. }
  49. else
  50. {
  51. rStrName.clear();
  52. }
  53. }
  54. return res;
  55. }
  56. inline VmbErrorType EnumEntry::GetDisplayName( std::string &rStrDisplayName ) const
  57. {
  58. VmbErrorType res;
  59. VmbUint32_t nLength;
  60. res = GetDisplayName( NULL, nLength );
  61. if ( VmbErrorSuccess == res )
  62. {
  63. if ( 0 != nLength )
  64. {
  65. try
  66. {
  67. std::vector<std::string::value_type> tmpName( nLength + 1, '\0' );
  68. res = GetDisplayName( &tmpName[0], nLength );
  69. if ( VmbErrorSuccess == res )
  70. {
  71. rStrDisplayName = &*tmpName.begin();
  72. }
  73. }
  74. catch(...)
  75. {
  76. return VmbErrorResources;
  77. }
  78. }
  79. else
  80. {
  81. rStrDisplayName.clear();
  82. }
  83. }
  84. return res;
  85. }
  86. inline VmbErrorType EnumEntry::GetDescription( std::string &rStrDescription ) const
  87. {
  88. VmbErrorType res;
  89. VmbUint32_t nLength;
  90. res = GetDescription( NULL, nLength );
  91. if ( VmbErrorSuccess == res )
  92. {
  93. if ( 0 != nLength )
  94. {
  95. try
  96. {
  97. std::vector<std::string::value_type> tmpDescription( nLength + 1, '\0' );
  98. res = GetDescription( &tmpDescription[0], nLength );
  99. if ( VmbErrorSuccess == res )
  100. {
  101. rStrDescription = &*tmpDescription.begin();
  102. }
  103. }
  104. catch(...)
  105. {
  106. return VmbErrorResources;
  107. }
  108. }
  109. else
  110. {
  111. rStrDescription.clear();
  112. }
  113. }
  114. return res;
  115. }
  116. inline VmbErrorType EnumEntry::GetTooltip( std::string &rStrTooltip ) const
  117. {
  118. VmbErrorType res;
  119. VmbUint32_t nLength;
  120. res = GetTooltip( NULL, nLength );
  121. if ( VmbErrorSuccess == res )
  122. {
  123. if ( 0 != nLength )
  124. {
  125. try
  126. {
  127. std::vector<std::string::value_type> tmpTooltip( nLength + 1, '\0' );
  128. res = GetTooltip( &tmpTooltip[0], nLength );
  129. if ( VmbErrorSuccess == res )
  130. {
  131. rStrTooltip = &*tmpTooltip.begin();
  132. }
  133. }
  134. catch(...)
  135. {
  136. return VmbErrorResources;
  137. }
  138. }
  139. else
  140. {
  141. rStrTooltip.clear();
  142. }
  143. }
  144. return res;
  145. }
  146. inline VmbErrorType EnumEntry::GetSFNCNamespace( std::string &rStrNamespace ) const
  147. {
  148. VmbErrorType res;
  149. VmbUint32_t nLength;
  150. res = GetSFNCNamespace( NULL, nLength );
  151. if ( VmbErrorSuccess == res )
  152. {
  153. if ( 0 != nLength )
  154. {
  155. try
  156. {
  157. std::vector<std::string::value_type> tmpNamespace( nLength + 1, '\0' );
  158. res = GetSFNCNamespace( &tmpNamespace[0], nLength );
  159. if ( VmbErrorSuccess == res )
  160. {
  161. rStrNamespace =&*tmpNamespace.begin();
  162. }
  163. }
  164. catch(...)
  165. {
  166. return VmbErrorResources;
  167. }
  168. }
  169. else
  170. {
  171. rStrNamespace.clear();
  172. }
  173. }
  174. return res;
  175. }
  176. #endif