ADBLib  0.5
A simple library for rapid robot code development
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
ADBLib::Equation Class Reference

#include <Equation.h>

Collaboration diagram for ADBLib::Equation:

Public Member Functions

 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...
 

Protected Member Functions

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...
 

Protected Attributes

queue< class TokenoutputQueue
 

Detailed Description

Equation class for handling simple equations (PEMDAS) when the equation is not known at compile-time.

Exceptions
parse_error

Constructor & Destructor Documentation

ADBLib::Equation::Equation ( )
inline
ADBLib::Equation::Equation ( string  newEqu)

Constructor. Lets you parse a new equation upon construction.

Parameters
newEquAn equation as a string.

Here is the call graph for this function:

Member Function Documentation

long double ADBLib::Equation::evaluate ( long double  value)

Evaluate the parsed equation, replacing "x" with the given value.

Parameters
valueThe value to substitue "x" for.
Returns
The value of the evaluated equation
Exceptions
parse_error

Here is the call graph for this function:

operations ADBLib::Equation::getOType ( string::iterator  iter) const
inlineprotected

Converts a character as an operator to one of the enumerated operations.

Parameters
iterAn iterator to a character in an equation.
Returns
The type of operator this is.
Exceptions
parse_error

Here is the caller graph for this function:

tokenType ADBLib::Equation::getTType ( string::iterator  iter) const
inlineprotected

Determines what type of token a given character is.

Parameters
iterAn iterator to a character in an equation.
Returns
The type of token this is (variable, value, operator).
Exceptions
parse_error

Here is the caller graph for this function:

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
iterAn iterator to the start of a number in the sequence.
equationAn equation as a string.
Returns
The value of the number.

Here is the caller graph for this function:

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
newEquAn equation as a string.
Exceptions
parse_error
Note
You MUST load an equation with this function before using evaluate()!

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

queue<class Token> ADBLib::Equation::outputQueue
protected

The documentation for this class was generated from the following files: