You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

239 lines
7.4 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: mfcstl/collections/carray_traits.hpp (derived from mfcstl/carray_adaptors.hpp)
  3. *
  4. * Purpose: Definition of the CArray_traits traits class.
  5. *
  6. * Created: 1st December 2002
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2002-2009, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright notice, this
  18. * list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  23. * any contributors may be used to endorse or promote products derived from
  24. * this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * ////////////////////////////////////////////////////////////////////// */
  39. /** \file mfcstl/collections/carray_traits.hpp
  40. *
  41. * \brief [C++ only] Definition of the mfcstl::CArray_traits traits class
  42. * (\ref group__library__collections "Collections" Library).
  43. */
  44. #ifndef MFCSTL_INCL_MFCSTL_COLLECTIONS_HPP_CARRAY_TRAITS
  45. #define MFCSTL_INCL_MFCSTL_COLLECTIONS_HPP_CARRAY_TRAITS
  46. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  47. # define MFCSTL_VER_MFCSTL_COLLECTIONS_HPP_CARRAY_TRAITS_MAJOR 2
  48. # define MFCSTL_VER_MFCSTL_COLLECTIONS_HPP_CARRAY_TRAITS_MINOR 0
  49. # define MFCSTL_VER_MFCSTL_COLLECTIONS_HPP_CARRAY_TRAITS_REVISION 1
  50. # define MFCSTL_VER_MFCSTL_COLLECTIONS_HPP_CARRAY_TRAITS_EDIT 12
  51. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  52. /* /////////////////////////////////////////////////////////////////////////
  53. * Compatibility
  54. */
  55. /*
  56. [Incompatibilies-start]
  57. [Incompatibilies-end]
  58. */
  59. /* /////////////////////////////////////////////////////////////////////////
  60. * Includes
  61. */
  62. #ifndef MFCSTL_INCL_MFCSTL_HPP_MFCSTL
  63. # include <mfcstl/mfcstl.hpp>
  64. #endif /* !MFCSTL_INCL_MFCSTL_HPP_MFCSTL */
  65. #if defined(STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT) && \
  66. !defined(MFCSTL_NO_INCLUDE_AFXTEMPL_BY_DEFAULT)
  67. # include <afxtempl.h>
  68. #endif /* STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT && !MFCSTL_NO_INCLUDE_AFXTEMPL_BY_DEFAULT */
  69. #ifdef STLSOFT_UNITTEST
  70. # include <stlsoft/meta/is_same_type.hpp>
  71. #endif /* STLSOFT_UNITTEST */
  72. /* /////////////////////////////////////////////////////////////////////////
  73. * Namespace
  74. */
  75. #ifndef _MFCSTL_NO_NAMESPACE
  76. # if defined(_STLSOFT_NO_NAMESPACE) || \
  77. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  78. /* There is no stlsoft namespace, so must define ::mfcstl */
  79. namespace mfcstl
  80. {
  81. # else
  82. /* Define stlsoft::mfcstl_project */
  83. namespace stlsoft
  84. {
  85. namespace mfcstl_project
  86. {
  87. # endif /* _STLSOFT_NO_NAMESPACE */
  88. #endif /* !_MFCSTL_NO_NAMESPACE */
  89. /* /////////////////////////////////////////////////////////////////////////
  90. * Classes
  91. */
  92. #ifdef STLSOFT_DOCUMENTATION_SKIP_SECTION
  93. /** \brief Traits for CArray_adaptor_base
  94. *
  95. * \ingroup group__library__collections
  96. */
  97. template <ss_typename_param_k C>
  98. struct CArray_traits
  99. {
  100. /// \brief Typedef that defines the type of the elements in the array
  101. typedef ???? value_type;
  102. /// \brief Typedef that defines the type of the arguments to the methods of the array
  103. typedef ???? arg_type;
  104. /// \brief Typedef that identifies the actual class type used to parameterise the traits
  105. typedef ???? array_type;
  106. };
  107. #else /* ? STLSOFT_DOCUMENTATION_SKIP_SECTION */
  108. template <ss_typename_param_k C>
  109. struct CArray_traits;
  110. STLSOFT_TEMPLATE_SPECIALISATION
  111. struct CArray_traits<CByteArray>
  112. {
  113. typedef BYTE value_type;
  114. typedef BYTE arg_type;
  115. typedef CByteArray array_type;
  116. };
  117. STLSOFT_TEMPLATE_SPECIALISATION
  118. struct CArray_traits<CDWordArray>
  119. {
  120. typedef DWORD value_type;
  121. typedef DWORD arg_type;
  122. typedef CDWordArray array_type;
  123. };
  124. STLSOFT_TEMPLATE_SPECIALISATION
  125. struct CArray_traits<CUIntArray>
  126. {
  127. typedef UINT value_type;
  128. typedef UINT arg_type;
  129. typedef CUIntArray array_type;
  130. };
  131. STLSOFT_TEMPLATE_SPECIALISATION
  132. struct CArray_traits<CWordArray>
  133. {
  134. typedef WORD value_type;
  135. typedef WORD arg_type;
  136. typedef CWordArray array_type;
  137. };
  138. STLSOFT_TEMPLATE_SPECIALISATION
  139. struct CArray_traits<CPtrArray>
  140. {
  141. typedef void* value_type;
  142. typedef void* arg_type;
  143. typedef CPtrArray array_type;
  144. };
  145. STLSOFT_TEMPLATE_SPECIALISATION
  146. struct CArray_traits<CObArray>
  147. {
  148. typedef CObject* value_type;
  149. typedef CObject* arg_type;
  150. typedef CObArray array_type;
  151. };
  152. STLSOFT_TEMPLATE_SPECIALISATION
  153. struct CArray_traits<CStringArray>
  154. {
  155. typedef CString value_type;
  156. # if 0
  157. typedef CString const& arg_type;
  158. # else /* ? 0 */
  159. typedef LPCTSTR arg_type;
  160. # endif /* 0 */
  161. typedef CStringArray array_type;
  162. };
  163. # if defined(__AFXTEMPL_H__) && \
  164. defined(STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT)
  165. template <class V, class A>
  166. struct CArray_traits<CArray<V, A> >
  167. {
  168. typedef V value_type;
  169. typedef A arg_type;
  170. typedef CArray<V, A> array_type;
  171. };
  172. # endif /* __AFXTEMPL_H__ && STLSOFT_CF_TEMPLATE_PARTIAL_SPECIALISATION_SUPPORT */
  173. #endif /* STLSOFT_DOCUMENTATION_SKIP_SECTION */
  174. /** \brief Traits type for specific setting of value_type and arg_type
  175. *
  176. * \ingroup group__library__collections
  177. */
  178. template< ss_typename_param_k V
  179. , ss_typename_param_k A
  180. , ss_typename_param_k C
  181. >
  182. struct CArray_specific_traits
  183. {
  184. typedef V value_type;
  185. typedef A arg_type;
  186. typedef C array_type;
  187. };
  188. ////////////////////////////////////////////////////////////////////////////
  189. // Unit-testing
  190. #ifdef STLSOFT_UNITTEST
  191. # include "./unittest/carray_traits_unittest_.h"
  192. #endif /* STLSOFT_UNITTEST */
  193. /* ////////////////////////////////////////////////////////////////////// */
  194. #ifndef _MFCSTL_NO_NAMESPACE
  195. # if defined(_STLSOFT_NO_NAMESPACE) || \
  196. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  197. } // namespace mfcstl
  198. # else
  199. } // namespace mfcstl_project
  200. } // namespace stlsoft
  201. # endif /* _STLSOFT_NO_NAMESPACE */
  202. #endif /* !_MFCSTL_NO_NAMESPACE */
  203. /* ////////////////////////////////////////////////////////////////////// */
  204. #endif /* !MFCSTL_INCL_MFCSTL_COLLECTIONS_HPP_CARRAY_TRAITS */
  205. /* ///////////////////////////// end of file //////////////////////////// */