mfc_atl.rst 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. ++++++++++++++++++++++++++++++++
  2. |Boost| Range MFC/ATL Extension
  3. ++++++++++++++++++++++++++++++++
  4. .. |Boost| image:: http://www.boost.org/libs/ptr_container/doc/boost.png
  5. :Author: Shunsuke Sogame
  6. :Contact: mb2act@yahoo.co.jp
  7. :date: 26th of May 2006
  8. :copyright: Shunsuke Sogame 2005-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__).
  9. __ http://www.boost.org/LICENSE_1_0.txt
  10. ========
  11. Overview
  12. ========
  13. Boost.Range MFC/ATL Extension provides `Boost.Range`_ support for MFC/ATL collection and string types.
  14. .. parsed-literal::
  15. CTypedPtrArray<CPtrArray, CList<CString> \*> myArray;
  16. ...
  17. BOOST_FOREACH (CList<CString> \*theList, myArray)
  18. {
  19. BOOST_FOREACH (CString& str, \*theList)
  20. {
  21. boost::to_upper(str);
  22. std::sort(boost::begin(str), boost::end(str));
  23. ...
  24. }
  25. }
  26. * `Requirements`_
  27. * `MFC Ranges`_
  28. * `ATL Ranges`_
  29. * `const Ranges`_
  30. * `References`_
  31. ============
  32. Requirements
  33. ============
  34. - `Boost C++ Libraries Version 1.34.0`__ or later (no compilation required)
  35. - Visual C++ 7.1 or Visual C++ 8.0
  36. __ Boost_
  37. ==========
  38. MFC Ranges
  39. ==========
  40. If the ``<boost/range/mfc.hpp>`` is included before or after `Boost.Range`_ headers,
  41. the MFC collections and strings become models of Range.
  42. The table below lists the Traversal Category and ``range_reference`` of MFC ranges.
  43. ============================= ================== =======================================
  44. ``Range`` Traversal Category ``range_reference<Range>::type``
  45. ============================= ================== =======================================
  46. ``CArray<T,A>`` Random Access ``T&``
  47. ----------------------------- ------------------ ---------------------------------------
  48. ``CList<T,A>`` Bidirectional ``T&``
  49. ----------------------------- ------------------ ---------------------------------------
  50. ``CMap<K,AK,M,AM>`` Forward ``Range::CPair&``
  51. ----------------------------- ------------------ ---------------------------------------
  52. ``CTypedPtrArray<B,T*>`` Random Access ``T* const``
  53. ----------------------------- ------------------ ---------------------------------------
  54. ``CTypedPtrList<B,T*>`` Bidirectional ``T* const``
  55. ----------------------------- ------------------ ---------------------------------------
  56. ``CTypedPtrMap<B,T*,V*>`` Forward ``std::pair<T*,V*> const``
  57. ----------------------------- ------------------ ---------------------------------------
  58. ``CByteArray`` Random Access ``BYTE&``
  59. ----------------------------- ------------------ ---------------------------------------
  60. ``CDWordArray`` Random Access ``DWORD&``
  61. ----------------------------- ------------------ ---------------------------------------
  62. ``CObArray`` Random Access ``CObject* &``
  63. ----------------------------- ------------------ ---------------------------------------
  64. ``CPtrArray`` Random Access ``void* &``
  65. ----------------------------- ------------------ ---------------------------------------
  66. ``CStringArray`` Random Access ``CString&``
  67. ----------------------------- ------------------ ---------------------------------------
  68. ``CUIntArray`` Random Access ``UINT&``
  69. ----------------------------- ------------------ ---------------------------------------
  70. ``CWordArray`` Random Access ``WORD&``
  71. ----------------------------- ------------------ ---------------------------------------
  72. ``CObList`` Bidirectional ``CObject* &``
  73. ----------------------------- ------------------ ---------------------------------------
  74. ``CPtrList`` Bidirectional ``void* &``
  75. ----------------------------- ------------------ ---------------------------------------
  76. ``CStringList`` Bidirectional ``CString&``
  77. ----------------------------- ------------------ ---------------------------------------
  78. ``CMapPtrToWord`` Forward ``std::pair<void*,WORD> const``
  79. ----------------------------- ------------------ ---------------------------------------
  80. ``CMapPtrToPtr`` Forward ``std::pair<void*,void*> const``
  81. ----------------------------- ------------------ ---------------------------------------
  82. ``CMapStringToOb`` Forward ``std::pair<String,CObject*> const``
  83. ----------------------------- ------------------ ---------------------------------------
  84. ``CMapStringToString`` Forward ``Range::CPair&``
  85. ----------------------------- ------------------ ---------------------------------------
  86. ``CMapWordToOb`` Forward ``std::pair<WORD,CObject*> const``
  87. ----------------------------- ------------------ ---------------------------------------
  88. ``CMapWordToPtr`` Forward ``std::pair<WORD,void*> const``
  89. ============================= ================== =======================================
  90. Other `Boost.Range`_ metafunctions are defined by the following.
  91. Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference<Range>::type``.
  92. ``range_value<Range>::type`` is the same as ``remove_reference<remove_const<Ref>::type>::type``,
  93. ``range_difference<Range>::type`` is the same as ``std::ptrdiff_t``, and
  94. ``range_pointer<Range>::type`` is the same as ``add_pointer<remove_reference<Ref>::type>::type``.
  95. As for ``const Range``, see `const Ranges`_.
  96. ==========
  97. ATL Ranges
  98. ==========
  99. If the ``<boost/range/atl.hpp>`` is included before or after `Boost.Range`_ headers,
  100. the ATL collections and strings become models of Range.
  101. The table below lists the Traversal Category and ``range_reference`` of ATL ranges.
  102. ============================= ================== =======================================
  103. ``Range`` Traversal Category ``range_reference<Range>::type``
  104. ============================= ================== =======================================
  105. ``CAtlArray<E,ET>`` Random Access ``E&``
  106. ----------------------------- ------------------ ---------------------------------------
  107. ``CAutoPtrArray<E>`` Random Access ``E&``
  108. ----------------------------- ------------------ ---------------------------------------
  109. ``CInterfaceArray<I,pi>`` Random Access ``CComQIPtr<I,pi>&``
  110. ----------------------------- ------------------ ---------------------------------------
  111. ``CAtlList<E,ET>`` Bidirectional ``E&``
  112. ----------------------------- ------------------ ---------------------------------------
  113. ``CAutoPtrList<E>`` Bidirectional ``E&``
  114. ----------------------------- ------------------ ---------------------------------------
  115. ``CHeapPtrList<E,A>`` Bidirectional ``E&``
  116. ----------------------------- ------------------ ---------------------------------------
  117. ``CInterfaceList<I,pi>`` Bidirectional ``CComQIPtr<I,pi>&``
  118. ----------------------------- ------------------ ---------------------------------------
  119. ``CAtlMap<K,V,KT,VT>`` Forward ``Range::CPair&``
  120. ----------------------------- ------------------ ---------------------------------------
  121. ``CRBTree<K,V,KT,VT>`` Bidirectional ``Range::CPair&``
  122. ----------------------------- ------------------ ---------------------------------------
  123. ``CRBMap<K,V,KT,VT>`` Bidirectional ``Range::CPair&``
  124. ----------------------------- ------------------ ---------------------------------------
  125. ``CRBMultiMap<K,V,KT,VT>`` Bidirectional ``Range::CPair&``
  126. ----------------------------- ------------------ ---------------------------------------
  127. ``CSimpleStringT<B,b>`` Random Access ``B&``
  128. ----------------------------- ------------------ ---------------------------------------
  129. ``CStringT<B,ST>`` Random Access ``B&``
  130. ----------------------------- ------------------ ---------------------------------------
  131. ``CFixedStringT<S,n>`` Random Access ``range_reference<S>::type``
  132. ----------------------------- ------------------ ---------------------------------------
  133. ``CStringT<B,ST>`` Random Access ``B&``
  134. ----------------------------- ------------------ ---------------------------------------
  135. ``CComBSTR`` Random Access ``OLECHAR&``
  136. ----------------------------- ------------------ ---------------------------------------
  137. ``CSimpleArray<T,TE>`` Random Access ``T&``
  138. ============================= ================== =======================================
  139. Other `Boost.Range`_ metafunctions are defined by the following.
  140. Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference<Range>::type``.
  141. ``range_value<Range>::type`` is the same as ``remove_reference<Ref>::type``,
  142. ``range_difference<Range>::type`` is the same as ``std::ptrdiff_t``, and
  143. ``range_pointer<Range>::type`` is the same as ``add_pointer<remove_reference<Ref>::type>::type``.
  144. As for ``const Range``, see `const Ranges`_.
  145. ============
  146. const Ranges
  147. ============
  148. ``range_reference<const Range>::type`` is defined by the following algorithm.
  149. Let ``Range`` be any type listed above and ``ReF`` be the same as ``range_reference<Range>::type``.
  150. .. parsed-literal::
  151. if (Range is CObArray || Range is CObList)
  152. return CObject const \* &
  153. else if (Range is CPtrArray || Range is CPtrList)
  154. return void const \* &
  155. else if (there is a type X such that X& is the same as ReF)
  156. return X const &
  157. else if (there is a type X such that X* const is the same as ReF)
  158. return X const \* const
  159. else
  160. return ReF
  161. Other `Boost.Range`_ metafunctions are defined by the following.
  162. ``range_value<const Range>::type`` is the same as ``range_value<Range>::type``,
  163. ``range_difference<const Range>::type`` is the same as ``std::ptrdiff_t``, and
  164. ``range_pointer<const Range>::type`` is the same as ``add_pointer<remove_reference<range_reference<const Range>::type>::type>::type``.
  165. ==========
  166. References
  167. ==========
  168. - `Boost.Range`_
  169. - `MFC Collections`__
  170. - `ATL Collection Classes`__
  171. __ http://msdn2.microsoft.com/en-us/library/942860sh.aspx
  172. __ http://msdn2.microsoft.com/en-US/library/15e672bd.aspx
  173. .. _Boost C++ Libraries: http://www.boost.org/
  174. .. _Boost: `Boost C++ Libraries`_
  175. .. _Boost.Range: ../index.html
  176. .. _forward: range.html#forward_range
  177. .. _bidirectional: range.html#forward_range
  178. .. _random access: range.html#random_access_range