Click here to Skip to main content
15,894,291 members
Articles / Programming Languages / C++

ToDoList Add-on

Rate me:
Please Sign up or sign in to vote.
4.69/5 (6 votes)
20 Apr 2002CPOL3 min read 242.2K   2.9K   57  
A Visual Studio add-in to help navigate to TODO:, TASK: etc comments, as well as showing STL containers in debug mode such as std::string, std::list etc
/********************************************************************
  created:    2001/08/09
  created:    9:8:2001   10:19
  filename:   e:\My Projects\Own\ToDoCached\ToDoSTLDebug.h
  file path:  e:\My Projects\Own\ToDoCached
  file base:  ToDoSTLDebug
  file ext:   h
  author:     Alex Kucherenko
  
  purpose:    
*********************************************************************/

#if !defined(AFX_TODOSTLDEBUG_H__96A5AE81_CF5D_438B_BBA5_F389D13F7F31__INCLUDED_)
#define AFX_TODOSTLDEBUG_H__96A5AE81_CF5D_438B_BBA5_F389D13F7F31__INCLUDED_

# pragma once

#include "..\stldbg\stl_types.h"
#include "..\stldbg\stl_map.h"
#include "..\stldbg\stl_list.h"
#include "..\stldbg\stl_vector.h"
#include "..\stldbg\stl_string.h"
#include "dlg_resize.h"
#include "dlg_init.h"
#include "hhsupp.h"
#include "autofont.h"


//////////////////////////////////////////////////////////////////////////
// Macro which calculate array size 

#ifndef SIZEOF_ARRAY
# define SIZEOF_ARRAY(x) ( sizeof( x )/sizeof( x[0] ) )
#endif

#define DEF_OUTPUT_STRING_LENGTH  60
#define DEF_MAX_AUTOEVALUATE      m_lAutoExpand

//////////////////////////////////////////////////////////////////////////
// Difinition of suppported types
// NOTE: First must be classes and only after them simple types

typedef enum
{
  stdTypeString     = 0,
  stdTypeVector     /*= 1*/,
  stdTypeMap        /*= 2*/,
  stdTypeMultiMap   /*= 3*/,
  stdTypeSet        /*= 4*/,
  stdTypeMultiSet   /*= 5*/,
  stdTypeList       /*= 6*/,
  stdTypeCString    /*= 7*/, 
  stdTypeComBSTR    /*= 8*/,
  stdTypeBSTR       /*= 9*/,
  stdTypetBstr      /*=10*/,
  stdTypeCharStr,   // Must be allways last
} TSTLTypes;

//////////////////////////////////////////////////////////////////////////
//  

class CSTLDbgImpl
{
  public:
    CSTLDbgImpl( IDebugger *pDebug )
      : m_pMapDebug( NULL )
      , m_pListDebug( NULL )
      , m_pVecDebug( NULL )
      , m_pBSTR( NULL )
      , m_pComBSTR( NULL )
      , m_pCString( NULL )
      , m_pStdStr( NULL )
      , m_pTBSTR( NULL )
      , m_pDebugger( pDebug )
    {
      string name;
      m_pMapDebug = new CStdMap( m_pDebugger, name );
      m_pListDebug = new CStdList( m_pDebugger, name );
      m_pVecDebug = new CStdVector( m_pDebugger, name );
      m_pBSTR = new CStdBSTR( m_pDebugger, name );
      m_pComBSTR = new CStdComBSTR( m_pDebugger, name );
      m_pCString = new CStdCString( m_pDebugger, name );
      m_pStdStr = new CStdString( m_pDebugger, name );
      m_pTBSTR = new CStdTBSTR( m_pDebugger, name );
      m_pChar = new CStdChar( m_pDebugger, name );
    };

    virtual ~CSTLDbgImpl( )
    {
      delete m_pMapDebug, m_pMapDebug = NULL;
      delete m_pListDebug, m_pListDebug = NULL;
      delete m_pVecDebug, m_pVecDebug = NULL;
      delete m_pBSTR, m_pBSTR = NULL;
      delete m_pComBSTR, m_pComBSTR = NULL;
      delete m_pCString, m_pCString = NULL;
      delete m_pStdStr, m_pStdStr = NULL;
      delete m_pTBSTR, m_pTBSTR = NULL;
      delete m_pChar, m_pChar = NULL;
    };

    virtual IStdTypes *GetByIndex( TSTLTypes index )
    {
      switch( index )
      {
        case stdTypeString: return m_pStdStr;
        case stdTypeVector: return m_pVecDebug;
        case stdTypeMap:
        case stdTypeMultiMap:
        case stdTypeSet:
        case stdTypeMultiSet: return m_pMapDebug;
        case stdTypeList: return m_pListDebug;
        case stdTypeCString: return m_pCString;
        case stdTypeComBSTR: return m_pComBSTR;
        case stdTypeBSTR: return m_pBSTR;
        case stdTypetBstr: return m_pTBSTR;
        case stdTypeCharStr: return m_pChar;
      }
      
      return NULL;
    };
  
  private:
    CStdMap               *m_pMapDebug;   // std::map and std::set ( +multi )
    CStdList              *m_pListDebug;  // std::list
    CStdVector            *m_pVecDebug;   // std::vector
    CStdBSTR              *m_pBSTR;
    CStdComBSTR           *m_pComBSTR;
    CStdCString           *m_pCString;
    CStdString            *m_pStdStr;
    CStdTBSTR             *m_pTBSTR;
    CStdChar              *m_pChar;
    CComPtr<IDebugger>    m_pDebugger;    // pointer to Debugger interface

};

/////////////////////////////////////////////////////////////////////////////
// CToDoSTLDebug dialog

class CToDoSTLDebug 
  : public CHHDialog/*CDialog*/
  , public CResizeImpl
  , public CSTLDbgImpl
  , public CInitDialogImpl
{
  public:
    // standard constructor
    CToDoSTLDebug( CWnd* pParent = NULL, IDebugger *pDebug = NULL, CRegistryEx *pReg = NULL );
    virtual ~CToDoSTLDebug();

    void SetVariable( CString strName )
    {
      m_strValue = strName;
      if( m_cValue.m_hWnd != NULL ) UpdateData( FALSE );
    };

  //{{AFX_DATA(CToDoSTLDebug)
	enum { IDD = IDD_DEBUGSTL_DLG };
	CEdit	m_cFilterBy;
    CComboBox       m_cValue;
    CProgressCtrl   m_cProgress;
    CButton         m_cCopy;
    CEdit           m_cSizeTo;
    CEdit           m_cSizeFrom;
    CSpinButtonCtrl m_cSpinTo;
    CSpinButtonCtrl m_cSpinFrom;
    CComboBox       m_cViewType;
    CListCtrl       m_cResultView;
    CComboBox       m_cValueType;
    CString         m_strSizeFrom;
    CString         m_strSizeTo;
    CString         m_strValue;
	//}}AFX_DATA

  protected:

    // evaluate functions
    virtual CString GetContanerSize( TSTLTypes tType );
    virtual void CreateValueView( TSTLTypes tType, long lMin, long lMax );
    virtual BOOL ExpandSTLType( long lMin, long lMax );
    virtual BOOL ExpandSTLPairShow( void );
    virtual BOOL ExpandSTLSingleShow( void );
    virtual BOOL ExpandStringsShow( void );
    virtual CString CheckSTLType( IStdTypes *pType );
    virtual void GetInitSettings();
    virtual void SetInitSettings();

  
  private:
    const static CString  m_strFill[];    // array of supported types
    const static ULONG    m_lFillSize;    // size of array
    CAutoFont             *m_pFont;
    
    IStdTypes             *m_pSTLDebugg;  // interface pointer
    TStrArray             m_arrHistory;   // history array
    ULONG                 m_lHistoryLim;  // max records in history
    ULONG                 m_lAutoExpand;
    BOOL                  m_bAutoExpand;

    ULONG                 m_lMaxCount;    // Max size of element
    BOOL                  m_bAutoFind;    // if TRUE class will try to find STL type automaticaly
    BOOL                  m_bChangeToSpc; // if TRUE then symols less 0x20 will be changed to \0xNN

  //{{AFX_VIRTUAL(CToDoSTLDebug)
  protected:
    virtual void DoDataExchange(CDataExchange* pDX);
  //}}AFX_VIRTUAL

  protected:
  //{{AFX_MSG(CToDoSTLDebug)
    afx_msg void OnEvaluate();
    virtual void OnCancel();
    afx_msg void OnCopy();
    virtual BOOL OnInitDialog();
    afx_msg void OnSelchangeType();
    afx_msg void OnAbort();
    afx_msg LRESULT OnEvaluateFinish( WPARAM, LPARAM );
    afx_msg void OnSize(UINT nType, int cx, int cy);
    afx_msg void OnDestroy();
	  afx_msg void OnFindAutoType();
	  afx_msg void OnSelchangeValue();
	  afx_msg void OnEditchangeValue();
	afx_msg void OnChangeFilter();
	//}}AFX_MSG

  afx_msg void OnGetMinMaxInfo( MINMAXINFO *pMinMax );
    
  DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}

#endif // !defined(AFX_TODOSTLDEBUG_H__96A5AE81_CF5D_438B_BBA5_F389D13F7F31__INCLUDED_)

//:> end of file

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
CEO ArtfulBits Inc.
Ukraine Ukraine
Name:Kucherenko Oleksandr

Born:September 20, 1979

Platforms: Win32, Linux; - well known and MS-DOS; Win16; OS/2 - old time not touched;

Hardware: IBM PC

Programming Languages: Assembler (for Intel 80386); Borland C/C++; Borland Pascal; Object Pascal; Borland C++Builder; Delphi; Perl; Java; Visual C++; Visual J++; UML; XML/XSL; C#; VB.NET; T-SQL; PL/SQL; and etc.

Development Environments: MS Visual Studio 2001-2008; MS Visual C++; Borland Delphi; Borland C++Builder; C/C++ any; Rational Rose; GDPro; Together and etc.

Libraries: STL, ATL, WTL, MFC, NuMega Driver Works, VCL; .NET 1.0, 1.1, 2.0, 3.5; and etc.

Technologies: Client/Server; COM; DirectX; DirectX Media; BDE; HTML/DHTML; ActiveX; Java Servlets; DCOM; COM+; ADO; CORBA; .NET; Windows Forms; GDI/GDI+; and etc.

Application Skills: Databases - design and maintain, support, programming; GUI Design; System Programming, Security; Business Software Development. Win/Web Services development and etc.

Comments and Discussions