#include <Equation.h>
|
| | Equation () |
| |
| | Equation (string newEqu) |
| | Constructor. Lets you parse a new equation upon construction. More...
|
| |
| void | parse (string newEqu) |
| | Parses an equation into more easily processable form (RPN). Write equations like you would in C++, but with ^ for exponents and forward slashes ONLY for division. More...
|
| |
| long double | evaluate (long double value) |
| | Evaluate the parsed equation, replacing "x" with the given value. More...
|
| |
|
| tokenType | getTType (string::iterator iter) const |
| | Determines what type of token a given character is. More...
|
| |
| operations | getOType (string::iterator iter) const |
| | Converts a character as an operator to one of the enumerated operations. More...
|
| |
| long double | getValue (string::iterator &iter, string &equation) const |
| | Given an iterator to the start of a number, converts the string number to a long double number, and advances the iterator to the end of the number. More...
|
| |
Equation class for handling simple equations (PEMDAS) when the equation is not known at compile-time.
- Exceptions
-
| ADBLib::Equation::Equation |
( |
| ) |
|
|
inline |
| ADBLib::Equation::Equation |
( |
string |
newEqu | ) |
|
Constructor. Lets you parse a new equation upon construction.
- Parameters
-
| newEqu | An equation as a string. |
| long double ADBLib::Equation::evaluate |
( |
long double |
value | ) |
|
Evaluate the parsed equation, replacing "x" with the given value.
- Parameters
-
| value | The value to substitue "x" for. |
- Returns
- The value of the evaluated equation
- Exceptions
-
| operations ADBLib::Equation::getOType |
( |
string::iterator |
iter | ) |
const |
|
inlineprotected |
Converts a character as an operator to one of the enumerated operations.
- Parameters
-
| iter | An iterator to a character in an equation. |
- Returns
- The type of operator this is.
- Exceptions
-
| tokenType ADBLib::Equation::getTType |
( |
string::iterator |
iter | ) |
const |
|
inlineprotected |
Determines what type of token a given character is.
- Parameters
-
| iter | An iterator to a character in an equation. |
- Returns
- The type of token this is (variable, value, operator).
- Exceptions
-
| long double ADBLib::Equation::getValue |
( |
string::iterator & |
iter, |
|
|
string & |
equation |
|
) |
| const |
|
protected |
Given an iterator to the start of a number, converts the string number to a long double number, and advances the iterator to the end of the number.
- Parameters
-
| iter | An iterator to the start of a number in the sequence. |
| equation | An equation as a string. |
- Returns
- The value of the number.
| void ADBLib::Equation::parse |
( |
string |
newEqu | ) |
|
Parses an equation into more easily processable form (RPN). Write equations like you would in C++, but with ^ for exponents and forward slashes ONLY for division.
- Parameters
-
| newEqu | An equation as a string. |
- Exceptions
-
- Note
- You MUST load an equation with this function before using evaluate()!
| queue<class Token> ADBLib::Equation::outputQueue |
|
protected |
The documentation for this class was generated from the following files: