#ifndef _INFIXEVAL_H
#define _INFIXEVAL_H

#include <string>
#include <iostream>
#include <stack>
#include <vector>

#define SCREEN_WIDTH 25

class TreeNode {
public:
  std::string element;
  TreeNode *left;
  TreeNode *right;
};

class InfixEvaluator {
public:
  std::string toPostfix(std::string expr);
  TreeNode *postfixToTree(std::string expr);
  void outputTree(TreeNode &root);
  void outputTreeExpr(std::string expr);
protected:
  static const std::string operators;
  static const std::string operands;

  int maxLevel(TreeNode &node);
  bool allNull(std::vector<TreeNode*> nodes);
  void InfixEvaluator::outputSpaces(int number);
  void outputNode(std::vector<TreeNode*> nodes, int level, int maxlev);
  int getPrecedence(char op);

  bool isOperator(char val) {
    return operators.find(val) != std::string::npos;
  }
  bool isOperand(char val) {
    return operands.find(val) != std::string::npos;
  }
};

#endif