annotate DEPENDENCIES/generic/include/boost/range/mfc.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 #ifndef BOOST_RANGE_MFC_HPP
Chris@16 2 #define BOOST_RANGE_MFC_HPP
Chris@16 3
Chris@16 4
Chris@16 5
Chris@16 6
Chris@16 7 // Boost.Range MFC Extension
Chris@16 8 //
Chris@16 9 // Copyright Shunsuke Sogame 2005-2006.
Chris@16 10 // Distributed under the Boost Software License, Version 1.0.
Chris@16 11 // (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 12 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 13
Chris@16 14
Chris@16 15
Chris@16 16
Chris@16 17 // config
Chris@16 18 //
Chris@16 19
Chris@16 20
Chris@16 21 #include <afx.h> // _MFC_VER
Chris@16 22
Chris@16 23
Chris@16 24 #if !defined(BOOST_RANGE_MFC_NO_CPAIR)
Chris@16 25 #if (_MFC_VER < 0x0700) // dubious
Chris@16 26 #define BOOST_RANGE_MFC_NO_CPAIR
Chris@16 27 #endif
Chris@16 28 #endif
Chris@16 29
Chris@16 30
Chris@16 31 #if !defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
Chris@16 32 #if (_MFC_VER < 0x0700) // dubious
Chris@16 33 #define BOOST_RANGE_MFC_HAS_LEGACY_STRING
Chris@16 34 #endif
Chris@16 35 #endif
Chris@16 36
Chris@16 37
Chris@16 38 // A const collection of old MFC doesn't return const reference.
Chris@16 39 //
Chris@16 40 #if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
Chris@16 41 #if (_MFC_VER < 0x0700) // dubious
Chris@16 42 #define BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF
Chris@16 43 #endif
Chris@16 44 #endif
Chris@16 45
Chris@16 46
Chris@16 47
Chris@16 48
Chris@16 49 // forward declarations
Chris@16 50 //
Chris@16 51
Chris@16 52
Chris@16 53 template< class Type, class ArgType >
Chris@16 54 class CArray;
Chris@16 55
Chris@16 56 template< class Type, class ArgType >
Chris@16 57 class CList;
Chris@16 58
Chris@16 59 template< class Key, class ArgKey, class Mapped, class ArgMapped >
Chris@16 60 class CMap;
Chris@16 61
Chris@16 62 template< class BaseClass, class PtrType >
Chris@16 63 class CTypedPtrArray;
Chris@16 64
Chris@16 65 template< class BaseClass, class PtrType >
Chris@16 66 class CTypedPtrList;
Chris@16 67
Chris@16 68 template< class BaseClass, class KeyPtrType, class MappedPtrType >
Chris@16 69 class CTypedPtrMap;
Chris@16 70
Chris@16 71
Chris@16 72
Chris@16 73
Chris@16 74 // extended customizations
Chris@16 75 //
Chris@16 76
Chris@16 77
Chris@16 78 #include <cstddef> // ptrdiff_t
Chris@16 79 #include <utility> // pair
Chris@16 80 #include <boost/assert.hpp>
Chris@16 81 #include <boost/mpl/if.hpp>
Chris@16 82 #include <boost/range/atl.hpp>
Chris@16 83 #include <boost/range/begin.hpp>
Chris@16 84 #include <boost/range/const_iterator.hpp>
Chris@16 85 #include <boost/range/detail/microsoft.hpp>
Chris@16 86 #include <boost/range/end.hpp>
Chris@16 87 #include <boost/iterator/iterator_adaptor.hpp>
Chris@16 88 #include <boost/iterator/iterator_categories.hpp>
Chris@16 89 #include <boost/iterator/iterator_facade.hpp>
Chris@16 90 #include <boost/iterator/transform_iterator.hpp>
Chris@16 91 #include <boost/type_traits/is_const.hpp>
Chris@16 92 #include <boost/type_traits/remove_pointer.hpp>
Chris@16 93 #include <boost/utility/addressof.hpp>
Chris@16 94 #include <afx.h> // legacy CString
Chris@16 95 #include <afxcoll.h> // CXXXArray, CXXXList, CMapXXXToXXX
Chris@16 96 #include <tchar.h>
Chris@16 97
Chris@16 98
Chris@16 99 namespace boost { namespace range_detail_microsoft {
Chris@16 100
Chris@16 101
Chris@16 102 // mfc_ptr_array_iterator
Chris@16 103 //
Chris@16 104 // 'void **' is not convertible to 'void const **',
Chris@16 105 // so we define...
Chris@16 106 //
Chris@16 107
Chris@16 108 template< class ArrayT, class PtrType >
Chris@16 109 struct mfc_ptr_array_iterator;
Chris@16 110
Chris@16 111 template< class ArrayT, class PtrType >
Chris@16 112 struct mfc_ptr_array_iterator_super
Chris@16 113 {
Chris@16 114 typedef iterator_adaptor<
Chris@16 115 mfc_ptr_array_iterator<ArrayT, PtrType>,
Chris@16 116 std::ptrdiff_t, // Base!
Chris@16 117 PtrType, // Value
Chris@16 118 random_access_traversal_tag,
Chris@16 119 use_default,
Chris@16 120 std::ptrdiff_t // Difference
Chris@16 121 > type;
Chris@16 122 };
Chris@16 123
Chris@16 124 template< class ArrayT, class PtrType >
Chris@16 125 struct mfc_ptr_array_iterator :
Chris@16 126 mfc_ptr_array_iterator_super<ArrayT, PtrType>::type
Chris@16 127 {
Chris@16 128 private:
Chris@16 129 typedef mfc_ptr_array_iterator self_t;
Chris@16 130 typedef typename mfc_ptr_array_iterator_super<ArrayT, PtrType>::type super_t;
Chris@16 131 typedef typename super_t::reference ref_t;
Chris@16 132
Chris@16 133 public:
Chris@16 134 explicit mfc_ptr_array_iterator()
Chris@16 135 { }
Chris@16 136
Chris@16 137 explicit mfc_ptr_array_iterator(ArrayT& arr, INT_PTR index) :
Chris@16 138 super_t(index), m_parr(boost::addressof(arr))
Chris@16 139 { }
Chris@16 140
Chris@16 141 template< class, class > friend struct mfc_ptr_array_iterator;
Chris@16 142 template< class ArrayT_, class PtrType_ >
Chris@16 143 mfc_ptr_array_iterator(mfc_ptr_array_iterator<ArrayT_, PtrType_> const& other) :
Chris@16 144 super_t(other.base()), m_parr(other.m_parr)
Chris@16 145 { }
Chris@16 146
Chris@16 147 private:
Chris@16 148 ArrayT *m_parr;
Chris@16 149
Chris@16 150 friend class iterator_core_access;
Chris@16 151 ref_t dereference() const
Chris@16 152 {
Chris@16 153 BOOST_ASSERT(0 <= this->base() && this->base() < m_parr->GetSize() && "out of range");
Chris@16 154 return *( m_parr->GetData() + this->base() );
Chris@16 155 }
Chris@16 156
Chris@16 157 bool equal(self_t const& other) const
Chris@16 158 {
Chris@16 159 BOOST_ASSERT(m_parr == other.m_parr && "iterators incompatible");
Chris@16 160 return this->base() == other.base();
Chris@16 161 }
Chris@16 162 };
Chris@16 163
Chris@16 164 struct mfc_ptr_array_functions
Chris@16 165 {
Chris@16 166 template< class Iterator, class X >
Chris@16 167 Iterator begin(X& x)
Chris@16 168 {
Chris@16 169 return Iterator(x, 0);
Chris@16 170 }
Chris@16 171
Chris@16 172 template< class Iterator, class X >
Chris@16 173 Iterator end(X& x)
Chris@16 174 {
Chris@16 175 return Iterator(x, x.GetSize());
Chris@16 176 }
Chris@16 177 };
Chris@16 178
Chris@16 179
Chris@16 180 // arrays
Chris@16 181 //
Chris@16 182
Chris@16 183 template< >
Chris@16 184 struct customization< ::CByteArray > :
Chris@16 185 array_functions
Chris@16 186 {
Chris@16 187 template< class X >
Chris@16 188 struct meta
Chris@16 189 {
Chris@16 190 typedef BYTE val_t;
Chris@16 191
Chris@16 192 typedef val_t *mutable_iterator;
Chris@16 193 typedef val_t const *const_iterator;
Chris@16 194 };
Chris@16 195 };
Chris@16 196
Chris@16 197
Chris@16 198 template< >
Chris@16 199 struct customization< ::CDWordArray > :
Chris@16 200 array_functions
Chris@16 201 {
Chris@16 202 template< class X >
Chris@16 203 struct meta
Chris@16 204 {
Chris@16 205 typedef DWORD val_t;
Chris@16 206
Chris@16 207 typedef val_t *mutable_iterator;
Chris@16 208 typedef val_t const *const_iterator;
Chris@16 209 };
Chris@16 210 };
Chris@16 211
Chris@16 212
Chris@16 213 template< >
Chris@16 214 struct customization< ::CObArray > :
Chris@16 215 mfc_ptr_array_functions
Chris@16 216 {
Chris@16 217 template< class X >
Chris@16 218 struct meta
Chris@16 219 {
Chris@16 220 typedef mfc_ptr_array_iterator<X, CObject *> mutable_iterator;
Chris@16 221 typedef mfc_ptr_array_iterator<X const, CObject const *> const_iterator;
Chris@16 222 };
Chris@16 223 };
Chris@16 224
Chris@16 225
Chris@16 226 template< >
Chris@16 227 struct customization< ::CPtrArray > :
Chris@16 228 mfc_ptr_array_functions
Chris@16 229 {
Chris@16 230 template< class X >
Chris@16 231 struct meta
Chris@16 232 {
Chris@16 233 typedef mfc_ptr_array_iterator<X, void *> mutable_iterator;
Chris@16 234 typedef mfc_ptr_array_iterator<X const, void const *> const_iterator;
Chris@16 235 };
Chris@16 236 };
Chris@16 237
Chris@16 238
Chris@16 239 template< >
Chris@16 240 struct customization< ::CStringArray > :
Chris@16 241 array_functions
Chris@16 242 {
Chris@16 243 template< class X >
Chris@16 244 struct meta
Chris@16 245 {
Chris@16 246 typedef ::CString val_t;
Chris@16 247
Chris@16 248 typedef val_t *mutable_iterator;
Chris@16 249 typedef val_t const *const_iterator;
Chris@16 250 };
Chris@16 251 };
Chris@16 252
Chris@16 253
Chris@16 254 template< >
Chris@16 255 struct customization< ::CUIntArray > :
Chris@16 256 array_functions
Chris@16 257 {
Chris@16 258 template< class X >
Chris@16 259 struct meta
Chris@16 260 {
Chris@16 261 typedef UINT val_t;
Chris@16 262
Chris@16 263 typedef val_t *mutable_iterator;
Chris@16 264 typedef val_t const *const_iterator;
Chris@16 265 };
Chris@16 266 };
Chris@16 267
Chris@16 268
Chris@16 269 template< >
Chris@16 270 struct customization< ::CWordArray > :
Chris@16 271 array_functions
Chris@16 272 {
Chris@16 273 template< class X >
Chris@16 274 struct meta
Chris@16 275 {
Chris@16 276 typedef WORD val_t;
Chris@16 277
Chris@16 278 typedef val_t *mutable_iterator;
Chris@16 279 typedef val_t const *const_iterator;
Chris@16 280 };
Chris@16 281 };
Chris@16 282
Chris@16 283
Chris@16 284 // lists
Chris@16 285 //
Chris@16 286
Chris@16 287 template< >
Chris@16 288 struct customization< ::CObList > :
Chris@16 289 list_functions
Chris@16 290 {
Chris@16 291 template< class X >
Chris@16 292 struct meta
Chris@16 293 {
Chris@16 294 typedef list_iterator<X, ::CObject *> mutable_iterator;
Chris@16 295 #if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
Chris@16 296 typedef list_iterator<X const, ::CObject const *> const_iterator;
Chris@16 297 #else
Chris@16 298 typedef list_iterator<X const, ::CObject const * const, ::CObject const * const> const_iterator;
Chris@16 299 #endif
Chris@16 300 };
Chris@16 301 };
Chris@16 302
Chris@16 303
Chris@16 304 template< >
Chris@16 305 struct customization< ::CPtrList > :
Chris@16 306 list_functions
Chris@16 307 {
Chris@16 308 template< class X >
Chris@16 309 struct meta
Chris@16 310 {
Chris@16 311 typedef list_iterator<X, void *> mutable_iterator;
Chris@16 312 #if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
Chris@16 313 typedef list_iterator<X const, void const *> const_iterator;
Chris@16 314 #else
Chris@16 315 typedef list_iterator<X const, void const * const, void const * const> const_iterator;
Chris@16 316 #endif
Chris@16 317 };
Chris@16 318 };
Chris@16 319
Chris@16 320
Chris@16 321 template< >
Chris@16 322 struct customization< ::CStringList > :
Chris@16 323 list_functions
Chris@16 324 {
Chris@16 325 template< class X >
Chris@16 326 struct meta
Chris@16 327 {
Chris@16 328 typedef ::CString val_t;
Chris@16 329
Chris@16 330 typedef list_iterator<X, val_t> mutable_iterator;
Chris@16 331 #if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
Chris@16 332 typedef list_iterator<X const, val_t const> const_iterator;
Chris@16 333 #else
Chris@16 334 typedef list_iterator<X const, val_t const, val_t const> const_iterator;
Chris@16 335 #endif
Chris@16 336 };
Chris@16 337 };
Chris@16 338
Chris@16 339
Chris@16 340 // mfc_map_iterator
Chris@16 341 //
Chris@16 342
Chris@16 343 template< class MapT, class KeyT, class MappedT >
Chris@16 344 struct mfc_map_iterator;
Chris@16 345
Chris@16 346 template< class MapT, class KeyT, class MappedT >
Chris@16 347 struct mfc_map_iterator_super
Chris@16 348 {
Chris@16 349 typedef iterator_facade<
Chris@16 350 mfc_map_iterator<MapT, KeyT, MappedT>,
Chris@16 351 std::pair<KeyT, MappedT>,
Chris@16 352 forward_traversal_tag,
Chris@16 353 std::pair<KeyT, MappedT> const
Chris@16 354 > type;
Chris@16 355 };
Chris@16 356
Chris@16 357 template< class MapT, class KeyT, class MappedT >
Chris@16 358 struct mfc_map_iterator :
Chris@16 359 mfc_map_iterator_super<MapT, KeyT, MappedT>::type
Chris@16 360 {
Chris@16 361 private:
Chris@16 362 typedef mfc_map_iterator self_t;
Chris@16 363 typedef typename mfc_map_iterator_super<MapT, KeyT, MappedT>::type super_t;
Chris@16 364 typedef typename super_t::reference ref_t;
Chris@16 365
Chris@16 366 public:
Chris@16 367 explicit mfc_map_iterator()
Chris@16 368 { }
Chris@16 369
Chris@16 370 explicit mfc_map_iterator(MapT const& map, POSITION pos) :
Chris@16 371 m_pmap(boost::addressof(map)), m_posNext(pos)
Chris@16 372 {
Chris@16 373 increment();
Chris@16 374 }
Chris@16 375
Chris@16 376 explicit mfc_map_iterator(MapT const& map) :
Chris@16 377 m_pmap(&map), m_pos(0) // end iterator
Chris@16 378 { }
Chris@16 379
Chris@16 380 template< class, class, class > friend struct mfc_map_iterator;
Chris@16 381 template< class MapT_, class KeyT_, class MappedT_>
Chris@16 382 mfc_map_iterator(mfc_map_iterator<MapT_, KeyT_, MappedT_> const& other) :
Chris@16 383 m_pmap(other.m_pmap),
Chris@16 384 m_pos(other.m_pos), m_posNext(other.m_posNext),
Chris@16 385 m_key(other.m_key), m_mapped(other.m_mapped)
Chris@16 386 { }
Chris@16 387
Chris@16 388 private:
Chris@16 389 MapT const *m_pmap;
Chris@16 390 POSITION m_pos, m_posNext;
Chris@16 391 KeyT m_key; MappedT m_mapped;
Chris@16 392
Chris@16 393 friend class iterator_core_access;
Chris@16 394 ref_t dereference() const
Chris@16 395 {
Chris@16 396 BOOST_ASSERT(m_pos != 0 && "out of range");
Chris@16 397 return std::make_pair(m_key, m_mapped);
Chris@16 398 }
Chris@16 399
Chris@16 400 void increment()
Chris@16 401 {
Chris@16 402 BOOST_ASSERT(m_pos != 0 && "out of range");
Chris@16 403
Chris@16 404 if (m_posNext == 0) {
Chris@16 405 m_pos = 0;
Chris@16 406 return;
Chris@16 407 }
Chris@16 408
Chris@16 409 m_pos = m_posNext;
Chris@16 410 m_pmap->GetNextAssoc(m_posNext, m_key, m_mapped);
Chris@16 411 }
Chris@16 412
Chris@16 413 bool equal(self_t const& other) const
Chris@16 414 {
Chris@16 415 BOOST_ASSERT(m_pmap == other.m_pmap && "iterators incompatible");
Chris@16 416 return m_pos == other.m_pos;
Chris@16 417 }
Chris@16 418 };
Chris@16 419
Chris@16 420 struct mfc_map_functions
Chris@16 421 {
Chris@16 422 template< class Iterator, class X >
Chris@16 423 Iterator begin(X& x)
Chris@16 424 {
Chris@16 425 return Iterator(x, x.GetStartPosition());
Chris@16 426 }
Chris@16 427
Chris@16 428 template< class Iterator, class X >
Chris@16 429 Iterator end(X& x)
Chris@16 430 {
Chris@16 431 return Iterator(x);
Chris@16 432 }
Chris@16 433 };
Chris@16 434
Chris@16 435
Chris@16 436 #if !defined(BOOST_RANGE_MFC_NO_CPAIR)
Chris@16 437
Chris@16 438
Chris@16 439 // mfc_cpair_map_iterator
Chris@16 440 //
Chris@16 441 // used by ::CMap and ::CMapStringToString
Chris@16 442 //
Chris@16 443
Chris@16 444 template< class MapT, class PairT >
Chris@16 445 struct mfc_cpair_map_iterator;
Chris@16 446
Chris@16 447 template< class MapT, class PairT >
Chris@16 448 struct mfc_pget_map_iterator_super
Chris@16 449 {
Chris@16 450 typedef iterator_facade<
Chris@16 451 mfc_cpair_map_iterator<MapT, PairT>,
Chris@16 452 PairT,
Chris@16 453 forward_traversal_tag
Chris@16 454 > type;
Chris@16 455 };
Chris@16 456
Chris@16 457 template< class MapT, class PairT >
Chris@16 458 struct mfc_cpair_map_iterator :
Chris@16 459 mfc_pget_map_iterator_super<MapT, PairT>::type
Chris@16 460 {
Chris@16 461 private:
Chris@16 462 typedef mfc_cpair_map_iterator self_t;
Chris@16 463 typedef typename mfc_pget_map_iterator_super<MapT, PairT>::type super_t;
Chris@16 464 typedef typename super_t::reference ref_t;
Chris@16 465
Chris@16 466 public:
Chris@16 467 explicit mfc_cpair_map_iterator()
Chris@16 468 { }
Chris@16 469
Chris@16 470 explicit mfc_cpair_map_iterator(MapT& map, PairT *pp) :
Chris@16 471 m_pmap(boost::addressof(map)), m_pp(pp)
Chris@16 472 { }
Chris@16 473
Chris@16 474 template< class, class > friend struct mfc_cpair_map_iterator;
Chris@16 475 template< class MapT_, class PairT_>
Chris@16 476 mfc_cpair_map_iterator(mfc_cpair_map_iterator<MapT_, PairT_> const& other) :
Chris@16 477 m_pmap(other.m_pmap), m_pp(other.m_pp)
Chris@16 478 { }
Chris@16 479
Chris@16 480 private:
Chris@16 481 MapT *m_pmap;
Chris@16 482 PairT *m_pp;
Chris@16 483
Chris@16 484 friend class iterator_core_access;
Chris@16 485 ref_t dereference() const
Chris@16 486 {
Chris@16 487 BOOST_ASSERT(m_pp != 0 && "out of range");
Chris@16 488 return *m_pp;
Chris@16 489 }
Chris@16 490
Chris@16 491 void increment()
Chris@16 492 {
Chris@16 493 BOOST_ASSERT(m_pp != 0 && "out of range");
Chris@16 494 m_pp = m_pmap->PGetNextAssoc(m_pp);
Chris@16 495 }
Chris@16 496
Chris@16 497 bool equal(self_t const& other) const
Chris@16 498 {
Chris@16 499 BOOST_ASSERT(m_pmap == other.m_pmap && "iterators incompatible");
Chris@16 500 return m_pp == other.m_pp;
Chris@16 501 }
Chris@16 502 };
Chris@16 503
Chris@16 504 struct mfc_cpair_map_functions
Chris@16 505 {
Chris@16 506 template< class Iterator, class X >
Chris@16 507 Iterator begin(X& x)
Chris@16 508 {
Chris@16 509 // Workaround:
Chris@16 510 // Assertion fails if empty.
Chris@16 511 // MFC document is wrong.
Chris@16 512 #if !defined(NDEBUG)
Chris@16 513 if (x.GetCount() == 0)
Chris@16 514 return Iterator(x, 0);
Chris@16 515 #endif
Chris@16 516
Chris@16 517 return Iterator(x, x.PGetFirstAssoc());
Chris@16 518 }
Chris@16 519
Chris@16 520 template< class Iterator, class X >
Chris@16 521 Iterator end(X& x)
Chris@16 522 {
Chris@16 523 return Iterator(x, 0);
Chris@16 524 }
Chris@16 525 };
Chris@16 526
Chris@16 527
Chris@16 528 #endif // !defined(BOOST_RANGE_MFC_NO_CPAIR)
Chris@16 529
Chris@16 530
Chris@16 531 // maps
Chris@16 532 //
Chris@16 533
Chris@16 534 template< >
Chris@16 535 struct customization< ::CMapPtrToWord > :
Chris@16 536 mfc_map_functions
Chris@16 537 {
Chris@16 538 template< class X >
Chris@16 539 struct meta
Chris@16 540 {
Chris@16 541 typedef void *key_t;
Chris@16 542 typedef WORD mapped_t;
Chris@16 543
Chris@16 544 typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
Chris@16 545 typedef mutable_iterator const_iterator;
Chris@16 546 };
Chris@16 547 };
Chris@16 548
Chris@16 549
Chris@16 550 template< >
Chris@16 551 struct customization< ::CMapPtrToPtr > :
Chris@16 552 mfc_map_functions
Chris@16 553 {
Chris@16 554 template< class X >
Chris@16 555 struct meta
Chris@16 556 {
Chris@16 557 typedef void *key_t;
Chris@16 558 typedef void *mapped_t;
Chris@16 559
Chris@16 560 typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
Chris@16 561 typedef mutable_iterator const_iterator;
Chris@16 562 };
Chris@16 563 };
Chris@16 564
Chris@16 565
Chris@16 566 template< >
Chris@16 567 struct customization< ::CMapStringToOb > :
Chris@16 568 mfc_map_functions
Chris@16 569 {
Chris@16 570 template< class X >
Chris@16 571 struct meta
Chris@16 572 {
Chris@16 573 typedef ::CString key_t;
Chris@16 574 typedef ::CObject *mapped_t;
Chris@16 575
Chris@16 576 typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
Chris@16 577 typedef mutable_iterator const_iterator;
Chris@16 578 };
Chris@16 579 };
Chris@16 580
Chris@16 581
Chris@16 582 template< >
Chris@16 583 struct customization< ::CMapStringToPtr > :
Chris@16 584 mfc_map_functions
Chris@16 585 {
Chris@16 586 template< class X >
Chris@16 587 struct meta
Chris@16 588 {
Chris@16 589 typedef ::CString key_t;
Chris@16 590 typedef void *mapped_t;
Chris@16 591
Chris@16 592 typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
Chris@16 593 typedef mutable_iterator const_iterator;
Chris@16 594 };
Chris@16 595 };
Chris@16 596
Chris@16 597
Chris@16 598 template< >
Chris@16 599 struct customization< ::CMapStringToString > :
Chris@16 600 #if !defined(BOOST_RANGE_MFC_NO_CPAIR)
Chris@16 601 mfc_cpair_map_functions
Chris@16 602 #else
Chris@16 603 mfc_map_functions
Chris@16 604 #endif
Chris@16 605 {
Chris@16 606 template< class X >
Chris@16 607 struct meta
Chris@16 608 {
Chris@16 609 #if !defined(BOOST_RANGE_MFC_NO_CPAIR)
Chris@16 610 typedef typename X::CPair pair_t;
Chris@16 611
Chris@16 612 typedef mfc_cpair_map_iterator<X, pair_t> mutable_iterator;
Chris@16 613 typedef mfc_cpair_map_iterator<X const, pair_t const> const_iterator;
Chris@16 614 #else
Chris@16 615 typedef ::CString key_t;
Chris@16 616 typedef ::CString mapped_t;
Chris@16 617
Chris@16 618 typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
Chris@16 619 typedef mutable_iterator const_iterator;
Chris@16 620 #endif
Chris@16 621 };
Chris@16 622 };
Chris@16 623
Chris@16 624
Chris@16 625 template< >
Chris@16 626 struct customization< ::CMapWordToOb > :
Chris@16 627 mfc_map_functions
Chris@16 628 {
Chris@16 629 template< class X >
Chris@16 630 struct meta
Chris@16 631 {
Chris@16 632 typedef WORD key_t;
Chris@16 633 typedef ::CObject *mapped_t;
Chris@16 634
Chris@16 635 typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
Chris@16 636 typedef mutable_iterator const_iterator;
Chris@16 637 };
Chris@16 638 };
Chris@16 639
Chris@16 640
Chris@16 641 template< >
Chris@16 642 struct customization< ::CMapWordToPtr > :
Chris@16 643 mfc_map_functions
Chris@16 644 {
Chris@16 645 template< class X >
Chris@16 646 struct meta
Chris@16 647 {
Chris@16 648 typedef WORD key_t;
Chris@16 649 typedef void *mapped_t;
Chris@16 650
Chris@16 651 typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
Chris@16 652 typedef mutable_iterator const_iterator;
Chris@16 653 };
Chris@16 654 };
Chris@16 655
Chris@16 656
Chris@16 657 // templates
Chris@16 658 //
Chris@16 659
Chris@16 660 template< class Type, class ArgType >
Chris@16 661 struct customization< ::CArray<Type, ArgType> > :
Chris@16 662 array_functions
Chris@16 663 {
Chris@16 664 template< class X >
Chris@16 665 struct meta
Chris@16 666 {
Chris@16 667 typedef Type val_t;
Chris@16 668
Chris@16 669 typedef val_t *mutable_iterator;
Chris@16 670 typedef val_t const *const_iterator;
Chris@16 671 };
Chris@16 672 };
Chris@16 673
Chris@16 674
Chris@16 675 template< class Type, class ArgType >
Chris@16 676 struct customization< ::CList<Type, ArgType> > :
Chris@16 677 list_functions
Chris@16 678 {
Chris@16 679 template< class X >
Chris@16 680 struct meta
Chris@16 681 {
Chris@16 682 typedef Type val_t;
Chris@16 683
Chris@16 684 typedef list_iterator<X, val_t> mutable_iterator;
Chris@16 685 #if !defined(BOOST_RANGE_MFC_CONST_COL_RETURNS_NON_REF)
Chris@16 686 typedef list_iterator<X const, val_t const> const_iterator;
Chris@16 687 #else
Chris@16 688 typedef list_iterator<X const, val_t const, val_t const> const_iterator;
Chris@16 689 #endif
Chris@16 690 };
Chris@16 691 };
Chris@16 692
Chris@16 693
Chris@16 694 template< class Key, class ArgKey, class Mapped, class ArgMapped >
Chris@16 695 struct customization< ::CMap<Key, ArgKey, Mapped, ArgMapped> > :
Chris@16 696 #if !defined(BOOST_RANGE_MFC_NO_CPAIR)
Chris@16 697 mfc_cpair_map_functions
Chris@16 698 #else
Chris@16 699 mfc_map_functions
Chris@16 700 #endif
Chris@16 701 {
Chris@16 702 template< class X >
Chris@16 703 struct meta
Chris@16 704 {
Chris@16 705 #if !defined(BOOST_RANGE_MFC_NO_CPAIR)
Chris@16 706 typedef typename X::CPair pair_t;
Chris@16 707
Chris@16 708 typedef mfc_cpair_map_iterator<X, pair_t> mutable_iterator;
Chris@16 709 typedef mfc_cpair_map_iterator<X const, pair_t const> const_iterator;
Chris@16 710 #else
Chris@16 711 typedef Key key_t;
Chris@16 712 typedef Mapped mapped_t;
Chris@16 713
Chris@16 714 typedef mfc_map_iterator<X, key_t, mapped_t> mutable_iterator;
Chris@16 715 typedef mutable_iterator const_iterator;
Chris@16 716 #endif
Chris@16 717 };
Chris@16 718 };
Chris@16 719
Chris@16 720
Chris@16 721 template< class BaseClass, class PtrType >
Chris@16 722 struct customization< ::CTypedPtrArray<BaseClass, PtrType> >
Chris@16 723 {
Chris@16 724 template< class X >
Chris@16 725 struct fun
Chris@16 726 {
Chris@16 727 typedef typename remove_pointer<PtrType>::type val_t;
Chris@16 728
Chris@16 729 typedef typename mpl::if_< is_const<X>,
Chris@16 730 val_t const,
Chris@16 731 val_t
Chris@16 732 >::type val_t_;
Chris@16 733
Chris@16 734 typedef val_t_ * const result_type;
Chris@16 735
Chris@16 736 template< class PtrType_ >
Chris@16 737 result_type operator()(PtrType_ p) const
Chris@16 738 {
Chris@16 739 return static_cast<result_type>(p);
Chris@16 740 }
Chris@16 741 };
Chris@16 742
Chris@16 743 template< class X >
Chris@16 744 struct meta
Chris@16 745 {
Chris@16 746 typedef typename compatible_mutable_iterator<BaseClass>::type miter_t;
Chris@16 747 typedef typename range_const_iterator<BaseClass>::type citer_t;
Chris@16 748
Chris@16 749 typedef transform_iterator<fun<X>, miter_t> mutable_iterator;
Chris@16 750 typedef transform_iterator<fun<X const>, citer_t> const_iterator;
Chris@16 751 };
Chris@16 752
Chris@16 753 template< class Iterator, class X >
Chris@16 754 Iterator begin(X& x)
Chris@16 755 {
Chris@16 756 return Iterator(boost::begin<BaseClass>(x), fun<X>());
Chris@16 757 }
Chris@16 758
Chris@16 759 template< class Iterator, class X >
Chris@16 760 Iterator end(X& x)
Chris@16 761 {
Chris@16 762 return Iterator(boost::end<BaseClass>(x), fun<X>());
Chris@16 763 }
Chris@16 764 };
Chris@16 765
Chris@16 766
Chris@16 767 template< class BaseClass, class PtrType >
Chris@16 768 struct customization< ::CTypedPtrList<BaseClass, PtrType> > :
Chris@16 769 list_functions
Chris@16 770 {
Chris@16 771 template< class X >
Chris@16 772 struct meta
Chris@16 773 {
Chris@16 774 typedef typename remove_pointer<PtrType>::type val_t;
Chris@16 775
Chris@16 776 // not l-value
Chris@16 777 typedef list_iterator<X, val_t * const, val_t * const> mutable_iterator;
Chris@16 778 typedef list_iterator<X const, val_t const * const, val_t const * const> const_iterator;
Chris@16 779 };
Chris@16 780 };
Chris@16 781
Chris@16 782
Chris@16 783 template< class BaseClass, class KeyPtrType, class MappedPtrType >
Chris@16 784 struct customization< ::CTypedPtrMap<BaseClass, KeyPtrType, MappedPtrType> > :
Chris@16 785 mfc_map_functions
Chris@16 786 {
Chris@16 787 template< class X >
Chris@16 788 struct meta
Chris@16 789 {
Chris@16 790 typedef mfc_map_iterator<X, KeyPtrType, MappedPtrType> mutable_iterator;
Chris@16 791 typedef mutable_iterator const_iterator;
Chris@16 792 };
Chris@16 793 };
Chris@16 794
Chris@16 795
Chris@16 796 // strings
Chris@16 797 //
Chris@16 798
Chris@16 799 #if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
Chris@16 800
Chris@16 801 template< >
Chris@16 802 struct customization< ::CString >
Chris@16 803 {
Chris@16 804 template< class X >
Chris@16 805 struct meta
Chris@16 806 {
Chris@16 807 // LPTSTR/LPCTSTR is not always defined in <tchar.h>.
Chris@16 808 typedef TCHAR *mutable_iterator;
Chris@16 809 typedef TCHAR const *const_iterator;
Chris@16 810 };
Chris@16 811
Chris@16 812 template< class Iterator, class X >
Chris@16 813 typename mutable_<Iterator, X>::type begin(X& x)
Chris@16 814 {
Chris@16 815 return x.GetBuffer(0);
Chris@16 816 }
Chris@16 817
Chris@16 818 template< class Iterator, class X >
Chris@16 819 Iterator begin(X const& x)
Chris@16 820 {
Chris@16 821 return x;
Chris@16 822 }
Chris@16 823
Chris@16 824 template< class Iterator, class X >
Chris@16 825 Iterator end(X& x)
Chris@16 826 {
Chris@16 827 return begin<Iterator>(x) + x.GetLength();
Chris@16 828 }
Chris@16 829 };
Chris@16 830
Chris@16 831 #endif // defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
Chris@16 832
Chris@16 833
Chris@16 834 } } // namespace boost::range_detail_microsoft
Chris@16 835
Chris@16 836
Chris@16 837
Chris@16 838
Chris@16 839 // range customizations
Chris@16 840 //
Chris@16 841
Chris@16 842
Chris@16 843 // arrays
Chris@16 844 //
Chris@16 845 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 846 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 847 BOOST_PP_NIL, CByteArray
Chris@16 848 )
Chris@16 849
Chris@16 850 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 851 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 852 BOOST_PP_NIL, CDWordArray
Chris@16 853 )
Chris@16 854
Chris@16 855 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 856 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 857 BOOST_PP_NIL, CStringArray
Chris@16 858 )
Chris@16 859
Chris@16 860 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 861 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 862 BOOST_PP_NIL, CUIntArray
Chris@16 863 )
Chris@16 864
Chris@16 865 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 866 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 867 BOOST_PP_NIL, CWordArray
Chris@16 868 )
Chris@16 869
Chris@16 870
Chris@16 871 // lists
Chris@16 872 //
Chris@16 873 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 874 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 875 BOOST_PP_NIL, CObList
Chris@16 876 )
Chris@16 877
Chris@16 878 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 879 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 880 BOOST_PP_NIL, CPtrList
Chris@16 881 )
Chris@16 882
Chris@16 883 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 884 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 885 BOOST_PP_NIL, CStringList
Chris@16 886 )
Chris@16 887
Chris@16 888 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 889 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 890 BOOST_PP_NIL, CObArray
Chris@16 891 )
Chris@16 892
Chris@16 893 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 894 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 895 BOOST_PP_NIL, CPtrArray
Chris@16 896 )
Chris@16 897
Chris@16 898
Chris@16 899 // maps
Chris@16 900 //
Chris@16 901 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 902 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 903 BOOST_PP_NIL, CMapPtrToWord
Chris@16 904 )
Chris@16 905
Chris@16 906 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 907 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 908 BOOST_PP_NIL, CMapPtrToPtr
Chris@16 909 )
Chris@16 910
Chris@16 911 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 912 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 913 BOOST_PP_NIL, CMapStringToOb
Chris@16 914 )
Chris@16 915
Chris@16 916 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 917 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 918 BOOST_PP_NIL, CMapStringToPtr
Chris@16 919 )
Chris@16 920
Chris@16 921 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 922 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 923 BOOST_PP_NIL, CMapStringToString
Chris@16 924 )
Chris@16 925
Chris@16 926 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 927 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 928 BOOST_PP_NIL, CMapWordToOb
Chris@16 929 )
Chris@16 930
Chris@16 931 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 932 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 933 BOOST_PP_NIL, CMapWordToPtr
Chris@16 934 )
Chris@16 935
Chris@16 936
Chris@16 937 // templates
Chris@16 938 //
Chris@16 939 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
Chris@16 940 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 941 BOOST_PP_NIL, CArray, 2
Chris@16 942 )
Chris@16 943
Chris@16 944 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
Chris@16 945 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 946 BOOST_PP_NIL, CList, 2
Chris@16 947 )
Chris@16 948
Chris@16 949 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
Chris@16 950 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 951 BOOST_PP_NIL, CMap, 4
Chris@16 952 )
Chris@16 953
Chris@16 954 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
Chris@16 955 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 956 BOOST_PP_NIL, CTypedPtrArray, 2
Chris@16 957 )
Chris@16 958
Chris@16 959 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
Chris@16 960 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 961 BOOST_PP_NIL, CTypedPtrList, 2
Chris@16 962 )
Chris@16 963
Chris@16 964 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TEMPLATE(
Chris@16 965 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 966 BOOST_PP_NIL, CTypedPtrMap, 3
Chris@16 967 )
Chris@16 968
Chris@16 969
Chris@16 970 // strings
Chris@16 971 //
Chris@16 972 #if defined(BOOST_RANGE_MFC_HAS_LEGACY_STRING)
Chris@16 973
Chris@16 974 BOOST_RANGE_DETAIL_MICROSOFT_CUSTOMIZATION_TYPE(
Chris@16 975 boost::range_detail_microsoft::using_type_as_tag,
Chris@16 976 BOOST_PP_NIL, CString
Chris@16 977 )
Chris@16 978
Chris@16 979 #endif
Chris@16 980
Chris@16 981
Chris@16 982
Chris@16 983
Chris@16 984 #endif