Source code of Windows XP (NT5)
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.

436 lines
12 KiB

  1. /*-----------------------------------------------------------------------------
  2. Microsoft Confidential
  3. Copyright 1995-2000 Microsoft Corporation. All Rights Reserved.
  4. Copyright (c) 1995 by P.J. Plauger. ALL RIGHTS RESERVED.
  5. Copyright (c) 1994
  6. Hewlett-Packard Company
  7. Permission to use, copy, modify, distribute and sell this
  8. software and its documentation for any purpose is hereby
  9. granted without fee, provided that the above copyright notice
  10. appear in all copies and that both that copyright notice and
  11. this permission notice appear in supporting documentation.
  12. Hewlett-Packard Company makes no representations about the
  13. suitability of this software for any purpose. It is provided
  14. "as is" without express or implied warranty.
  15. @doc external
  16. @module CFusionPointerIterator
  17. @owner a-JayK
  18. -----------------------------------------------------------------------------*/
  19. #pragma once
  20. #include "CFusionPointerIterator.h"
  21. //namespace NVseeLibContainer
  22. //{
  23. /*
  24. Name: CFusionPointerIterator::CFusionPointerIterator
  25. @mfunc
  26. This constructs the iterator, making it equivalent (at least its value,
  27. not quite its interface) to the pointer passed in.
  28. @owner a-JayK
  29. */
  30. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  31. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::CFusionPointerIterator
  32. (
  33. Pointer p // @arg set the iterator to this initially.
  34. ) throw()
  35. : m_current(p)
  36. {
  37. }
  38. /*
  39. Name: CFusionPointerIterator::CFusionPointerIterator
  40. @mfunc
  41. This copy constructs an iterator, but it is not necessarily
  42. the "default" copy constructor. If the iterator is const, this
  43. copy constructor constructs it from a non const iterator. The
  44. reverse conversion (const to non const) is invalid and disallowed.
  45. If the iterator is not const, this does end up being the usual
  46. copy constructor.
  47. @owner a-JayK
  48. */
  49. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  50. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::CFusionPointerIterator
  51. (
  52. const CFusionPointerIterator
  53. <
  54. T,
  55. Distance,
  56. MutablePointer,
  57. MutableReference,
  58. MutablePointer,
  59. MutableReference
  60. >& x
  61. ) throw()
  62. : m_current(x.PtBase())
  63. {
  64. }
  65. /*
  66. Name: CFusionPointerIterator::PtBase
  67. @mfunc
  68. This returns the value of the pointer underlying the iterator.
  69. It is in std::_Ptrit, but should not be needed by clients,
  70. but it used once internally.
  71. @owner a-JayK
  72. */
  73. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  74. inline Pointer
  75. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::PtBase
  76. (
  77. ) const throw()
  78. {
  79. return (m_current);
  80. }
  81. /*
  82. Name: CFusionPointerIterator::operator*
  83. @mfunc
  84. This dereferences the iterator, which is exactly like
  85. dereferencing the underlying pointer.
  86. @owner a-JayK
  87. */
  88. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  89. inline Reference
  90. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator*
  91. (
  92. ) const throw()
  93. {
  94. return (*m_current);
  95. }
  96. /*
  97. Name: CFusionPointerIterator::operator->
  98. @mfunc
  99. This dereferences the underlying pointer, but in the way
  100. that can be followed by the name of a member datum or
  101. member function.
  102. @owner a-JayK
  103. */
  104. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  105. inline Pointer
  106. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator->
  107. (
  108. ) const throw()
  109. {
  110. return (&**this);
  111. }
  112. /*
  113. Name: CFusionPointerIterator::operator++
  114. @mfunc
  115. This increments the iterator, and returns the new value.
  116. It is pre increment.
  117. @owner a-JayK
  118. */
  119. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  120. inline CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>&
  121. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator++
  122. (
  123. ) throw()
  124. {
  125. ++m_current;
  126. return (*this);
  127. }
  128. /*
  129. Name: CFusionPointerIterator::operator++
  130. @mfunc
  131. This increments the iterator, and returns the old value.
  132. It is post increment.
  133. @owner a-JayK
  134. */
  135. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  136. inline CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>
  137. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator++
  138. (
  139. int
  140. ) throw()
  141. {
  142. CFusionPointerIterator tmp = *this;
  143. ++m_current;
  144. return (tmp);
  145. }
  146. /*
  147. Name: CFusionPointerIterator::operator--
  148. @mfunc
  149. This decrements the iterator, and returns the new value.
  150. It is pre decrement.
  151. @owner a-JayK
  152. */
  153. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  154. inline CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>&
  155. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator--
  156. (
  157. ) throw()
  158. {
  159. --m_current;
  160. return (*this);
  161. }
  162. /*
  163. Name: CFusionPointerIterator::operator--
  164. @mfunc
  165. This decrements the iterator, and returns the old value.
  166. It is post decrement.
  167. @owner a-JayK
  168. */
  169. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  170. inline CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>
  171. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator--
  172. (
  173. int
  174. ) throw()
  175. {
  176. CFusionPointerIterator tmp = *this;
  177. --m_current;
  178. return (tmp);
  179. }
  180. /*
  181. Name: CFusionPointerIterator::operator==
  182. @mfunc
  183. This compares an iterator for equality with an integer.
  184. It is totally type unsafe and I don't know why std::_Ptrit
  185. provides it. Maybe for comparison to NULL?..no, that doesn't
  186. make sense, you should only compare iterators with other iterators,
  187. including the return value of Container::end().
  188. @owner a-JayK
  189. */
  190. /* FUTURE Why is this in xutility
  191. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  192. inline bool
  193. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator==(int y) const
  194. {
  195. return (m_current == reinterpret_cast<Pointer>(y));
  196. }
  197. */
  198. /*
  199. Name: CFusionPointerIterator::operator==
  200. @mfunc
  201. @owner a-JayK
  202. */
  203. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  204. inline bool
  205. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator==
  206. (
  207. const CFusionPointerIterator& y // @arg
  208. ) const throw()
  209. {
  210. return (m_current == y.m_current);
  211. }
  212. /*
  213. Name: CFusionPointerIterator::operator!=
  214. @mfunc
  215. @owner a-JayK
  216. */
  217. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  218. inline bool
  219. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator!=
  220. (
  221. const CFusionPointerIterator& y
  222. ) const throw()
  223. {
  224. return (!(*this == y));
  225. }
  226. /*
  227. Name: CFusionPointerIterator::operator+=
  228. @mfunc
  229. @owner a-JayK
  230. */
  231. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  232. inline CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>&
  233. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator+=
  234. (
  235. Distance n // @arg
  236. ) throw()
  237. {
  238. m_current += n;
  239. return (*this);
  240. }
  241. /*
  242. Name: CFusionPointerIterator::operator+
  243. @mfunc
  244. @owner a-JayK
  245. */
  246. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  247. inline CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>
  248. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator+
  249. (
  250. Distance n // @arg
  251. ) const throw()
  252. {
  253. return (CFusionPointerIterator(m_current + n));
  254. }
  255. /*
  256. Name: CFusionPointerIterator::operator-=
  257. @mfunc
  258. @owner a-JayK
  259. */
  260. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  261. inline CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>&
  262. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator-=
  263. (
  264. Distance n // @arg
  265. ) throw()
  266. {
  267. m_current -= n;
  268. return (*this);
  269. }
  270. /*
  271. Name: CFusionPointerIterator::operator-
  272. @mfunc
  273. @owner a-JayK
  274. */
  275. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  276. inline CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>
  277. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator-
  278. (
  279. Distance n // @arg
  280. ) const throw()
  281. {
  282. return (CFusionPointerIterator(m_current - n));
  283. }
  284. /*
  285. Name: CFusionPointerIterator::operator[]
  286. @mfunc
  287. @owner a-JayK
  288. */
  289. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  290. inline Reference
  291. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator[]
  292. (
  293. Distance n // @arg
  294. ) const throw()
  295. {
  296. return (*(*this + n));
  297. }
  298. /*
  299. Name: CFusionPointerIterator::operator<
  300. @mfunc
  301. @owner a-JayK
  302. */
  303. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  304. inline bool
  305. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator<
  306. (
  307. const CFusionPointerIterator& y // @arg
  308. ) const throw()
  309. {
  310. return (m_current < y.m_current);
  311. }
  312. /*
  313. Name: CFusionPointerIterator::operator>
  314. @mfunc
  315. @owner a-JayK
  316. */
  317. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  318. inline bool
  319. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator>
  320. (
  321. const CFusionPointerIterator& y // @arg
  322. ) const throw()
  323. {
  324. return (y < *this);
  325. }
  326. /*
  327. Name: CFusionPointerIterator::operator<=
  328. @mfunc
  329. @owner a-JayK
  330. */
  331. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  332. inline bool
  333. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator<=
  334. (
  335. const CFusionPointerIterator& y // @arg
  336. ) const throw()
  337. {
  338. return (!(y < *this));
  339. }
  340. /*
  341. Name: CFusionPointerIterator::operator>=
  342. @mfunc
  343. @owner a-JayK
  344. */
  345. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  346. inline bool
  347. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator>=
  348. (
  349. const CFusionPointerIterator& y // @arg
  350. ) const throw()
  351. {
  352. return (!(*this < y));
  353. }
  354. /*
  355. Name: CFusionPointerIterator::operator-
  356. @mfunc
  357. @owner a-JayK
  358. */
  359. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  360. inline Distance
  361. CFusionPointerIterator<T,Distance,Pointer,Reference,MutablePointer,MutableReference>::operator-
  362. (
  363. const CFusionPointerIterator& y // @arg
  364. ) const throw()
  365. {
  366. // static_cast, say, __int64 down to int
  367. return static_cast<Distance>(m_current - y.m_current);
  368. }
  369. /*
  370. Name: operator+
  371. @func
  372. @owner a-JayK
  373. */
  374. template<typename T, typename Distance, typename Pointer, typename Reference, typename MutablePointer, typename MutableReference>
  375. inline CFusionPointerIterator<T, Distance, Pointer, Reference, MutablePointer, MutableReference>
  376. operator+
  377. (
  378. Distance n, // @arg
  379. const CFusionPointerIterator<T, Distance, Pointer, Reference, MutablePointer, MutableReference>& y // @arg
  380. ) throw()
  381. {
  382. return (y + n);
  383. }
  384. //} // namespace