Click here to Skip to main content
15,889,838 members
Articles / Programming Languages / C#

An extensible math expression parser with plug-ins

Rate me:
Please Sign up or sign in to vote.
4.92/5 (147 votes)
13 Mar 2008CPOL51 min read 1.4M   29K   364  
Design and code for an extensible, maintainable, robust, and easy to use math parser.
// MathExprDlg.h : header file
//

#if !defined(AFX_MATHEXPRDLG_H__A71C510C_42B2_4A9C_8015_074901D2229D__INCLUDED_)
#define AFX_MATHEXPRDLG_H__A71C510C_42B2_4A9C_8015_074901D2229D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "../MTParserLib/MTParser.h"

/////////////////////////////////////////////////////////////////////////////
// CMathExprDlg dialog


class CMathExprDlg : public CDialog
{
// Construction
public:
	CMathExprDlg(CWnd* pParent = NULL);	// standard constructor

	MTParser m_mathExpr;
	int m_varXID, m_varYID, m_varZID;

// Dialog Data
	//{{AFX_DATA(CMathExprDlg)
	enum { IDD = IDD_MATHEXPR_DIALOG };
	CButton	m_benchBtn;
	CButton	m_evaluateBtn;
	CString	m_expr;
	CString	m_msg;
	double	m_varx;
	double	m_vary;
	double	m_varz;
	double	m_result;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMathExprDlg)
	public:
	virtual BOOL DestroyWindow();
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CMathExprDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	virtual void OnOK();
	afx_msg void OnEvaluate();
	afx_msg void OnQuit();
	afx_msg void OnSetexpr();
	afx_msg void OnChangeExpr();
	afx_msg void OnIndex();
	afx_msg void OnBenchmark();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MATHEXPRDLG_H__A71C510C_42B2_4A9C_8015_074901D2229D__INCLUDED_)

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
Web Developer
Canada Canada
Software Engineer working at a fun and smart startup company

Comments and Discussions