|
SDL2lazy
|
#include <SlValueParser.h>
Public Member Functions | |
| SlValueParser (int width, int height) | |
| SlValueParser () | |
| ~SlValueParser () | |
| SlValueParser & | operator= (const SlValueParser &rhs) |
| SlValueParser (const SlValueParser &toCopy) | |
| void | doubleFromString (const std::string &value, double &i) |
| void | parseFormula (const std::vector< std::string > &stringValues, unsigned int &i, double &value) |
| void | setDimensions (const int &width, const int &height) |
| void | stringsToDoubles (const std::vector< std::string > &stringValues, double *values, unsigned int length) |
| template<typename T > | |
| void | stringsToNumbers (const std::vector< std::string > &stringValues, T *array, unsigned int length) |
| bool | stringsToRenderOptions (const std::vector< std::string > &stringValues, int &options) |
| int | screenWidth () |
| int | screenHeight () |
Private Member Functions | |
| std::string | assembleFormula (const std::vector< std::string > &stringValues, unsigned int &i) |
| double | calculateFormula (std::queue< SlFormulaItem > &outputQueue) |
| SlFormulaItem | getNextItem (std::string &formula) |
| std::queue< SlFormulaItem > | shuntFormula (std::string &formula) |
Private Attributes | |
| int | screen_width_ = 0 |
| int | screen_height_ = 0 |
Translate string input from configuration files to int output.
| SlValueParser::SlValueParser | ( | int | width, |
| int | height | ||
| ) |
screen_width_ and screen_height_ are set in the constructor.
|
inline |
Default constructor
|
inline |
Default destructor
| SlValueParser::SlValueParser | ( | const SlValueParser & | toCopy | ) |
Copy constructor.
|
private |
Generates the formula string from stringValues.
| std::invalid_argument | if the end of the formula can't be found. |
< already determined position 0 is '"'
< Remove trailing '"'
< This is where stringsToInts will continue
|
private |
Uses the outputQueue from shuntFormula() to calculate the result of the equation.
| std::runtime_error | if the items in the provided queue do not match the expected Reverse Polish notation or if an unknown operator is encountered. |
< number
< need two numbers to use operator
| void SlValueParser::doubleFromString | ( | const std::string & | value, |
| double & | i | ||
| ) |
Returns the double value for a string. Understands SCREEN_WIDTH and SCREEN_HEIGHT.
| std::runtime_error | if the string can't be converted to double. |
< account for unary -
|
private |
Extracts the next item from the given string, and cuts the corresponding part from the input string.
| SlValueParser & SlValueParser::operator= | ( | const SlValueParser & | rhs | ) |
Assignment.
| void SlValueParser::parseFormula | ( | const std::vector< std::string > & | stringValues, |
| unsigned int & | i, | ||
| double & | value | ||
| ) |
Calculates the results of a formula (only + and - implemented).
| std::invalid_argument | if the formula can't be calculated (unknown operator). |
|
inline |
Window height.
|
inline |
Window width.
| void SlValueParser::setDimensions | ( | const int & | width, |
| const int & | height | ||
| ) |
Sets the values used for keywords SCREEN_WIDTH, SCREEN_HEIGHT.
|
private |
Parses equation from assembleFormula() in infix notation and sorts it into Reverse Polish notation.
< Check for leading unary -.
< Leading unary - (or plus)
< Should be '(' on top, discard.
| void SlValueParser::stringsToDoubles | ( | const std::vector< std::string > & | stringValues, |
| double * | values, | ||
| unsigned int | length | ||
| ) |
Takes a vector of strings, converts the strings to ints and returns them as an array.
| std::invalid_argument | if the size of stringValues is less than length, i.e. to few parameters given. |
Skip trailing whitespace at end of line otherwise causes exception.
| void SlValueParser::stringsToNumbers | ( | const std::vector< std::string > & | stringValues, |
| T * | array, | ||
| unsigned int | length | ||
| ) |
Takes a vector of strings, converts the strings to type T (floating point or integer types) and returns them as an array.
| bool SlValueParser::stringsToRenderOptions | ( | const std::vector< std::string > & | stringValues, |
| int & | options | ||
| ) |
Translates strings into SlRenderOptions.
|
private |
Screen dimensions are needed to define a texture as having the dimensions of the window.
|
private |
Screen dimensions are needed to define a texture as having the dimensions of the window.
1.8.9.1