Click here to Skip to main content
15,884,099 members
Articles / Desktop Programming / MFC

How to wrap an MFC collection into an STL compliant iterator with the Boost iterator_facade

Rate me:
Please Sign up or sign in to vote.
4.56/5 (22 votes)
20 Oct 2008CPOL5 min read 55.5K   502   34  
How to wrap an MFC collection into an STL compliant iterator with the Boost iterator_facade.
// IterTestView.h : interface of the CIterTestView class
//


#pragma once


class CIterTestView : public CScrollView
{
protected: // create from serialization only
	CIterTestView();
	DECLARE_DYNCREATE(CIterTestView)

// Attributes
public:
	CIterTestDoc* GetDocument() const;

// Operations
public:

// Overrides
public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);

// Implementation
public:
	virtual ~CIterTestView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
   CArray <int> m_array_of_ints;
   CList <int> m_list_of_ints;

// Generated message map functions
protected:
	DECLARE_MESSAGE_MAP()
public:
   afx_msg void OnTestmfciteratorsTestcarrayiterator();
   virtual void OnInitialUpdate();
   afx_msg void OnTestmfciteratorsTestclistiterator();
   afx_msg LRESULT OnTestViewIter(WPARAM w, LPARAM l);
   afx_msg void OnTestmfciteratorsTestcdoctemplateiterator();
};

#ifndef _DEBUG  // debug version in IterTestView.cpp
inline CIterTestDoc* CIterTestView::GetDocument() const
   { return reinterpret_cast<CIterTestDoc*>(m_pDocument); }
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Robotz Software
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions