www.pudn.com > MathHead > MathSys.h


#pragma once 
 
#include "MathNode.h" 
 
using std::list; 
using std::list::iterator; 
 
#define MATHSYS__SUCCESS		0 
#define MATHSYS__FAILURE		1 
#define MATHSYS__BAD_INPUT		2 
#define MATHSYS__NULL_INPUT		3 
#define MATHSYS__UNKNOWN_INPUT	4 
 
#define MATHSYS__MAX_TOKEN_BUFFER	1024 
 
class CMathSys 
{ 
private: 
 
	// Builds a tree from a list of items 
	static int MakeTree(list* pList, CMathNode ** ppTree); 
 
	// Builds a list of CMathNode's from a string 
	static int BuildList(wchar_t * wszInput, list** pList); 
 
	// Frees a list of nodes 
	static void FreeNodeList(list* pList); 
 
public: 
 
	// Parses a mathematical expression 
	static int ParseString(wchar_t * wszInput, CMathNode ** pTree); 
 
	class Algebra 
	{ 
 
	public: 
 
		// Replaces a variable with an expression 
		static int SubVariable(CMathNode * pExpr, CMathNode * pVarName, CMathNode * pValue); 
		static int SubVariable(CMathNode * pExpr, wchar_t wcVarName, CMathNode * pValue); 
	}; 
};