00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00053 #ifndef WINSTL_INCL_WINSTL_MEMORY_HPP_HEAPWALK_SEQUENCE
00054 #define WINSTL_INCL_WINSTL_MEMORY_HPP_HEAPWALK_SEQUENCE
00055
00056 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00057 # define WINSTL_VER_WINSTL_MEMORY_HPP_HEAPWALK_SEQUENCE_MAJOR 4
00058 # define WINSTL_VER_WINSTL_MEMORY_HPP_HEAPWALK_SEQUENCE_MINOR 0
00059 # define WINSTL_VER_WINSTL_MEMORY_HPP_HEAPWALK_SEQUENCE_REVISION 3
00060 # define WINSTL_VER_WINSTL_MEMORY_HPP_HEAPWALK_SEQUENCE_EDIT 62
00061 #endif
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 #ifndef WINSTL_INCL_WINSTL_H_WINSTL
00076 # include <winstl/winstl.h>
00077 #endif
00078 #ifndef STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER
00079 # include <stlsoft/util/std/iterator_helper.hpp>
00080 #endif
00081 #ifndef STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS
00082 # include <stlsoft/collections/util/collections.hpp>
00083 #endif
00084
00085 #ifdef STLSOFT_UNITTEST
00086 # include <algorithm>
00087 #endif
00088
00089
00090
00091
00092
00093 #ifndef _WINSTL_NO_NAMESPACE
00094 # if defined(_STLSOFT_NO_NAMESPACE) || \
00095 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00096
00097 namespace winstl
00098 {
00099 # else
00100
00101
00102 namespace stlsoft
00103 {
00104
00105 namespace winstl_project
00106 {
00107
00108 # endif
00109 #endif
00110
00111
00112
00113
00114
00115 class heapwalk_sequence_const_iterator;
00116
00117
00118
00119
00120
00121
00156 class heapwalk_sequence
00157 : public stlsoft_ns_qual(stl_collection_tag)
00158 {
00161 private:
00162 typedef PROCESS_HEAP_ENTRY entry_type;
00163 public:
00165 typedef heapwalk_sequence class_type;
00167 typedef entry_type const& value_type;
00169 typedef heapwalk_sequence_const_iterator const_iterator;
00171 typedef entry_type const& const_reference;
00173
00176 public:
00178 heapwalk_sequence();
00182 ss_explicit_k heapwalk_sequence(HANDLE hHeap);
00184 ~heapwalk_sequence() stlsoft_throw_0();
00186
00189 public:
00193 const_iterator begin() const;
00197 const_iterator end() const;
00199
00202 private:
00203 friend class heapwalk_sequence_const_iterator;
00205
00208 private:
00209 HANDLE m_hHeap;
00211
00214 private:
00215 heapwalk_sequence(class_type const&);
00216 heapwalk_sequence const& operator =(class_type const&);
00218 };
00219
00220
00226 class heapwalk_sequence_const_iterator
00227 : public stlsoft_ns_qual(iterator_base) < winstl_ns_qual_std(forward_iterator_tag)
00228 , PROCESS_HEAP_ENTRY const
00229 , ws_ptrdiff_t
00230 , PROCESS_HEAP_ENTRY const*
00231 , PROCESS_HEAP_ENTRY const&>
00232 {
00235 private:
00236 typedef PROCESS_HEAP_ENTRY entry_type;
00237 public:
00239 typedef entry_type const value_type;
00241 typedef heapwalk_sequence_const_iterator class_type;
00243
00246 private:
00247 heapwalk_sequence_const_iterator(heapwalk_sequence const& l, entry_type const& value)
00248 : m_list(&l)
00249 , m_value(value)
00250 {}
00251 heapwalk_sequence_const_iterator(heapwalk_sequence const& l);
00252 public:
00254 heapwalk_sequence_const_iterator();
00256 heapwalk_sequence_const_iterator(class_type const& rhs);
00258 ~heapwalk_sequence_const_iterator() stlsoft_throw_0();
00259
00261 heapwalk_sequence_const_iterator& operator =(class_type const& rhs);
00263
00266 public:
00268 class_type& operator ++();
00270 class_type const operator ++(int);
00272 value_type& operator *() const;
00274 ws_bool_t operator ==(class_type const& rhs) const;
00276 ws_bool_t operator !=(class_type const& rhs) const;
00278
00281 private:
00282 friend class heapwalk_sequence;
00284
00287 private:
00288 heapwalk_sequence const* const m_list;
00289 entry_type m_value;
00291 };
00292
00294
00295 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00296
00297
00298
00299 inline heapwalk_sequence::heapwalk_sequence()
00300 : m_hHeap(::GetProcessHeap())
00301 {}
00302
00303 inline heapwalk_sequence::heapwalk_sequence(HANDLE hHeap)
00304 : m_hHeap(hHeap)
00305 {}
00306
00307 inline heapwalk_sequence::~heapwalk_sequence() stlsoft_throw_0()
00308 {}
00309
00310 inline heapwalk_sequence::const_iterator heapwalk_sequence::begin() const
00311 {
00312 entry_type value;
00313
00314 value.lpData = NULL;
00315
00316 if(::HeapWalk(m_hHeap, &value))
00317 {
00318 return const_iterator(*this, value);
00319 }
00320 else
00321 {
00322 return const_iterator(*this);
00323 }
00324 }
00325
00326 inline heapwalk_sequence::const_iterator heapwalk_sequence::end() const
00327 {
00328 return const_iterator(*this);
00329 }
00330
00331
00332
00333 inline heapwalk_sequence_const_iterator::heapwalk_sequence_const_iterator()
00334 : m_list(NULL)
00335 {
00336 m_value.lpData = reinterpret_cast<LPVOID>(-1);
00337 }
00338
00339 inline heapwalk_sequence_const_iterator::heapwalk_sequence_const_iterator(heapwalk_sequence const& l)
00340 : m_list(&l)
00341 {
00342 m_value.lpData = reinterpret_cast<LPVOID>(-1);
00343 }
00344
00345 inline heapwalk_sequence_const_iterator::heapwalk_sequence_const_iterator(class_type const& rhs)
00346 : m_list(rhs.m_list)
00347 , m_value(rhs.m_value)
00348 {}
00349
00350 inline heapwalk_sequence_const_iterator::class_type& heapwalk_sequence_const_iterator::operator =(const heapwalk_sequence_const_iterator::class_type& rhs)
00351 {
00352 WINSTL_ASSERT(m_list == rhs.m_list);
00353
00354 m_value = rhs.m_value;
00355
00356 return *this;
00357 }
00358
00359 inline heapwalk_sequence_const_iterator::~heapwalk_sequence_const_iterator() stlsoft_throw_0()
00360 {}
00361
00362 inline heapwalk_sequence_const_iterator::class_type& heapwalk_sequence_const_iterator::operator ++()
00363 {
00364 if( NULL != m_list &&
00365 !::HeapWalk(m_list->m_hHeap, &m_value))
00366 {
00367 m_value.lpData = reinterpret_cast<LPVOID>(-1);
00368 }
00369
00370 return *this;
00371 }
00372
00373 inline heapwalk_sequence_const_iterator::class_type const heapwalk_sequence_const_iterator::operator ++(int)
00374 {
00375 class_type it(*this);
00376
00377 operator ++();
00378
00379 return it;
00380 }
00381
00382 inline heapwalk_sequence_const_iterator::value_type &heapwalk_sequence_const_iterator::operator *() const
00383 {
00384 return m_value;
00385 }
00386
00387 inline ws_bool_t heapwalk_sequence_const_iterator::operator ==(class_type const& rhs) const
00388 {
00389 ws_bool_t eq;
00390
00391 WINSTL_ASSERT(m_list == rhs.m_list);
00392
00393
00394 if(m_value.lpData != rhs.m_value.lpData)
00395 {
00396 eq = ws_false_v;
00397 }
00398 else
00399 {
00400 eq = ws_true_v;
00401 }
00402
00403 return eq;
00404 }
00405
00406 inline ws_bool_t heapwalk_sequence_const_iterator::operator !=(class_type const& rhs) const
00407 {
00408 return ! operator ==(rhs);
00409 }
00410
00411 #endif
00412
00414
00415
00416 #ifdef STLSOFT_UNITTEST
00417 # include "./unittest/heapwalk_sequence_unittest_.h"
00418 #endif
00419
00420
00421
00422 #ifndef _WINSTL_NO_NAMESPACE
00423 # if defined(_STLSOFT_NO_NAMESPACE) || \
00424 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00425 }
00426 # else
00427 }
00428 }
00429 # endif
00430 #endif
00431
00432
00433
00434 #endif
00435
00436