www.pudn.com > Calculate20060802.rar > MathStack.h


#pragma once 
 
#include  
using namespace std; 
 
extern char* pFunctions[]; 
 
bool IsNumeric(LPCSTR lpcs); 
CString TrimFloat(double f); 
void OptimizeSign(CString& str); 
void Optimize(CString& str); 
void InsertTabs(CString& str); 
char *GetClose(char *p); 
int GetFunction(LPCSTR pOpen); 
int GetOperator(IN LPCSTR lpcs, IN LPCSTR lpcsOperators[]); 
 
struct ExpressionItem 
{ 
	ExpressionItem(LPCSTR lpcsInput) 
	{ 
		m_strInput = lpcsInput; 
		m_cOperator = 0; 
		m_nFunction = -1; 
		m_nOutput = 0; 
		m_nSign = 1; 
	} 
	CString GetInput() 
	{ 
		if(IsNumeric(m_strInput) == false && m_strInput.FindOneOf("+-/*^") != -1) 
			return '('+m_strInput+')'; 
		return m_strInput; 
	} 
	char m_cOperator; 
	CString m_strInput; 
	CString m_strOutput; 
	double m_nOutput; 
	CString m_strStack; 
	int m_nFunction; 
	int m_nSign; 
	void GetDifferentiation(); 
	// return error number, 0 on success 
	int GetCalculation(bool bValue = false); 
}; 
 
int FillStack(LPCSTR lpcsInput, vector& vStack);